Skip to content

Convenience code for matrices #129

Closed

Description

@vbarrielle

It could be nice to have some shortcuts when working with matrices (and possibly for vectors too).

For instance, if a is a matrix, it might be convenient to use a.rows() instead of a.shape()[0].
Also exposing a type alias for matrices can be nice, something like pub type MatrixView<A> = ArrayView<A, (Ix, Ix)>.

There are probably other goodies we might want, but I don't know them yet.

Activity

  1. daniel-vainsencher commented on Mar 12, 2016

    @daniel-vainsencher
    Contributor

    👍

    I am using pub type MA = OwnedArray<f64, (Ix,Ix)>; I think having some fixed shortcuts in ndarray would be nice to avoid each using package inventing its own.

  2. bluss commented on Mar 12, 2016

    @bluss
    Member

    Since we have OwnedArray, RcArray, ArrayView, ArrayViewMut I've been a bit hesitant, I don't know how the API will eventually end up.. It is plausible we could add some terse type aliases, preferably finding a nice shorthand system.

    Maybe if someone has a generic scheme for type aliases they are already using and wants to propose. I don't use too much aliases, but type Ix2 = (Ix, Ix) is pretty common!

    Maybe it's unrelated, but racer doesn't do the world's best job with ndarray. Racer has a lot of things that can go wrong and make it not complete. In some files I can't get it to complete anything I try, I guess because it doesn't know the types of any of the array variables.

  3. bluss commented on Mar 12, 2016

    @bluss
    Member

    The type alias Array being deprecated, I've said it's up for grabs in a future version.

    Some shortlist candidates are (A) ArrayBase becomes Array, (B) OwnedArray becomes Array, (C) A new trait is made and called Array. Now issue #145

  4. bluss commented on Mar 15, 2016

    @bluss
    Member

    I have some natural resistance to dimensionality-specific methods.

    What I most often use instead of .rows() is just

    let (m, n) = array.dim();

    Which is even terser, but indeed the code is not as self documenting.

  5. bluss commented on Mar 17, 2016

    @bluss
    Member

    rows, cols are now fixed. We can open a new specific issue for type aliases.

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