As far as I know, Rust’s arrays are stack based and have fixed lenght. Vectors, on the contrary, hold their data on the heap, have variable lenght, and add some overhead w.r.t. plain arrays. I hope up to here I got it right.
I have been wondering about whether the
ndarray are more similar to standard arrays or to vectors, and whether they introduce overhead. Still, I could not find any answer on
ndarray documentation or elsewhere.
What makes me suspicious is that the dimension of an
ndarray can be decided when the array is initialized, rather than being encoded in its type (like standard arrays do). I suspect that would require to hold the data on the heap (though I don’t know much about memory models).
On the practical side: in a performance-critical scenario, should I avoid
ndarray and rely solely on standard arrays?