Notation for axis_iter_mut with zip and for_each

The Code below throws an error, there are no examples for this online, anywhere, its disappointing. Four iterators set to run in lockstep but sequentially, no parallel. Any ideas?

    let mut array_runner = Array2::<f64>::zeros((n,14));
    array_runner.axis_iter_mut(Axis(0)).zip(to_trade_big.axis_iter(Axis(0))).zip(to_trade_small.axis_iter(Axis(0))).enumerate().for_each(|(i,(mut array_i,(big_i,small_i))))| {

When using ndarray, please prefer to use its Zip which is made for efficient traversal of 1-6 arrays, including built-in support for parallelism with the rayon feature.

If there is an error you'd like us to take a look at, please include the error message.

1 Like

I appreciate the response, i'm trying to zip the following and then loop through them zipped as rows, and then eventually add a parallel function. Can you s how me how to zip them,then also how it would be to use a into_par_iter().

The documentation example-wise on this topic is ridiculously bad. unexplainable. The rayon crate and the ndarray crate and the zip crate LACK EXAMPLES!!!

    let mut products_big = array![[14.0, 2.0, 0.0],[3.0, 0.0, 0.0],[0.0, 1.0, 0.0],[0.0, 2.0, 0.0]];
    let products_bigg = array![[12.0, 2.0, 0.0],[5.0, 0.0, 0.0],[0.0, 1.0, 0.0],[0.0, 2.0, 0.0]];
    let products_biggg = array![[144.0, 2.0, 0.0],[6.0, 0.0, 0.0],[0.0, 1.0, 0.0],[0.0, 2.0, 0.0]];
    let products_bigggg = array![[164.0, 2.0, 0.0],[9.0, 0.0, 0.0],[0.0, 1.0, 0.0],[0.0, 2.0, 0.0]];
    Zip::from(&mut products_big.rows()).and(&products_bigg.rows()).and(&products_biggg).for_each(|j,k,l| {
        println!("fucker1 {:?}",(l));
        println!("fucker2 {:?}",(j));
        println!("fucker3 {:?}",(k));
    });

Well that makes me sad that you think so, I think there are examples in ndarray::parallel - Rust

With that said, maybe there are much better crates out there, look into how nalgebra solves this?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.