Skip to content

Iterate through two axis: flat_map? #320

Description

@UnderTheCarpet

Given a [n0, n1, n2, n3] array, I'd like an iterator going through the first two axis. Is this possible? I'd like to use this to parallely go through all components of a matrix-field, where n0 times n1 is the size of the matrix and n2 times n3 the number of grid points.

So kind of what

for mut ax0 in a.outer_iter_mut() {
    for mut ax1 in ax0.outer_iter_mut() {
        //...
    }
}

gives me, but as a flat iterator.

So something along the lines of

a.outer_iter_mut().flat_map(|ax| ax.outer_iter_mut()).par_iter_mut().etc()

which does not work. I'm a bit lost here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions