Is there multi unzip in rayon?

Hello,

Rayon has multizip to create tuples of N elements from N vectors.

Is there multi unzip to split tuples into 3 separate vectors?

let vec1 = vec![(0, 5, 99), (1, 7, 88), (2, 8, 44), (3, 9, 77)];

let (vec2, vec3): (Vec<_>, Vec<_>) = vec1.par_iter().cloned().map(|(a,b,c)| (a,b)).unzip();

let (vec3, vec4): (Vec<_>, Vec<_>) = vec1.par_iter().cloned().map(|(a,b,c)| (b,c)).unzip();

println!("vec2 {:?}",vec2);
println!("vec3 {:?}",vec3);
println!("vec4 {:?}",vec4);

It supports nested unzip, so you can do it by mapping the triple to ((a, b), c) or (a, (b, c)), and unzip to the corresponding nesting of Vecs in tuples.

Hopefully, you'll do this with some computation involved, because data movement alone will easily saturate the memory bus, underutilizing the threads.

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.