Skip to content

Zip indexed rows from 2d arrays #995

@vikigenius

Description

@vikigenius

Say, I have two Array2 objects:

type M = Array2<f32>;
let mut a = M::eye(2);
let mut b = 2.0 * a;

I want to iterate over the rows of a and b in lockstep, but also have the row index simultaneously:

for example:
(ridx, (row_a, row_b)) in Zip(a.rows(), b.rows()).enumerate()

I should get

(0, ([1.0, 0], [2.0, 0]))
(1, ([0, 1.0], [0, 2.0]))

How can I do this efficiently? Also can i do the same thing in parallel (over row indices) ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions