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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With