Skip to content

MatrixObj: add StandardBasisVector (or so) helper #6239

@fingolfin

Description

@fingolfin

The basic idea is that StandardBasisVector(filter, len, k, basedomain) would produce vector in the given filter of length len over ring with zero everywhere except at position k it has a 1.

For convenience, StandardBasisVector(len, k, basedomain) could be short for StandardBasisVector(DefaultVectorRepForBaseDomain(basedomain), len, k, basedomain) (whether it would be implemented like that is another question)

There is lots of code which uses IdentityMat(len, ring) to get such vectors. Such a use case could be replaced by List([1..len], k-> StandardBasisVector(len, k, ring))

Implementation would be simple enough:

v:=ZeroVector(filter, len, basedomain);
v[k]:=One(basedomain);

This might be the strongest argument against it: it is so easy to do that... But I think the added convenience is real; I've encountered lots of code where it would have been nice to have StandardBasisVector.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind: enhancementLabel for issues suggesting enhancements; and for pull requests implementing enhancementstopic: library

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions