Skip to content

How to create a 2D ArrayBase or RcArray from a Vec<Vec<f64>>? #197

Closed

Description

@cgarciae

I am parsing a csv and need to create a matrix, haven't found this in the docs. I've seen rcarr2 but that works with arrays, not vectors.

Activity

  1. vbarrielle commented on May 31, 2016

    @vbarrielle
    Contributor

    Maybe you can use something like the stack! macro to create an OwnedArray, and from there go to an RcArray if that's what you want.

  2. bluss commented on Jun 1, 2016

    @bluss
    Member

    I would concatenate it to a single flat Vec and then call OwnedArray::from_shape_vec((m, n), v) where v is the single dimensional vector, and m the number of rows, n the number of columns. The method returns a Result and you can use unwrap for example to get the array.

  3. cgarciae commented on Jun 4, 2016

    @cgarciae
    Author

    Thanks! Found @bluss 's method by myself last week.

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