ndarray
ndarray copied to clipboard
`par_map_axis`?
The documentation recommends collecting into a Vec when performing parallel axis operations, https://docs.rs/ndarray/0.15.4/ndarray/parallel/index.html#axis-iterators. This is far from ideal when further ndarray operations are required. It would be helpful if axis could be mapped in parallel like how map_axis maps sequentially.
I tried using
let arr: Array1<_> = a.axis_iter(Axis(0)).into_par_iter().map(|row| row.sum()).collect();
instead but I got the following error
the trait bound
ArrayBase<OwnedRepr<_>, ndarray::Dim<[usize; 1]>>: rayon::iter::FromParallelIterator<{float}>is not satisfied
Replace Array1<_> with Vec<_> and it works. This is somewhat surprising, as one would think that it should work with Array1! Maybe one of the maintainer know why?
In the meantime, you can create a ndarray with Array1::from(v) or ArrayView1::from(v)
In the meantime, you can create a ndarray with
Array1::from(v)orArrayView1::from(v)
That only works with static dimensionality, not D::Smaller as in map_axis.