Skip to content

Create 2d array from matrix product of 1d arrays #1298

Closed
@ModProg

Description

@ModProg

I have two vectors, and want to multiply them to a 2d matrix by transposing one of them.

Currently I am using nalgebra + ndarray for that:

let a = // the 1d ndarray
let a = Vector::from(a.to_vec()); // convert to nalgebra
let a_adjoint = a.adjoint(); // transpose
let b = a * a_adjoint;  // create matrix in nalgebra
let b = Array2::from_shape_fn((a_len, a_len), |i| b [i]);

Both better integration with nalgebra (adding some From implementations through a feature flag) or supporting this operation directly would help.

Maybe there is a better way to do this I'm not seeing.

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