I'm new to Rust (and Arrayfire) and working on a small project. I'm trying to convert an Arrayfire Array (only real) back to a Rust Vec.
After some research, I wasn't able to find a solution. The Rust Arrayfire documentation section to indexing only shows (as far as I can see) methods which return another Array.
I found this post talking about the C++ Arrayfire but the Rust Arrayfire Array does not implement the indexing trait.
Is there a way to convert an an Arrayfire Array to a Rust Vec or a method to index an Array returning one element (for example one i64) like v[0] does?
You use the host
function of Array
. Something like this should work:
let mut buffer = Vec::<f64>::new();
buffer.resize(ar.elements());
ar.host(&mut buffer);
// Buffer now contains a copy of the data.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.