Skip to content

A few extensions I've needed of ndarray #178

Open
@daniel-vainsencher

Description

@daniel-vainsencher

Relevant to any dimension:

trait MyArr<S: Data<Elem=A>, A: NdFloat, D: Dimension>
{
    // Yes, trivial with from_elem, but useful enough.
    fn ones(dim: D) -> ArrayBase<S,D>;
    // Also very common stuff
    fn powf(&self, exp: A) -> ArrayBase<Vec<A>,D>;
    fn sqr(&self) -> ArrayBase<Vec<A>,D>;
    fn norm(&self) -> A;
    fn max(&self) -> A;
}

Relevant to matrices only:

trait Mat<D: NdFloat> {
    fn sum_sqr_cw(&self) -> VE; // column wise sum of squares

    // Copy out a submatrix selecting arbitrary rows and columns from self.
    fn submatrix(&self, rows: &Vec<Ix>, columns: &Vec<Ix>) -> MA;
}

BTW, I receive a warning that fold is deprecated because it forces a particular order. I am not sure what you mean by that, and what is a good replacement for it.

I can submit a PR for those if welcome.

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