Skip to content

grade selection syntax #101

@ajahraus

Description

@ajahraus

When getting the elements of a MultiVector, you can use parentheses to select the grade, i.e.

A = 1 + 2v1 + 3v12 + 4v123 # 1 + 2v₁ + 3v₁₂ + 4v₁₂₃
typeof(A) # MultiVector{⟨1,1,1⟩, Int64, 8}
sizeof(A) # 64
A(0) # 1v

However, if the type if a Chain, then the parentheses act as an indexing operation, and only into the elements that are non-zero in the Chain. Attempting to access the scalar part of a Chain via `(0) returns an index error.

B =  3v12 + 4v23 #  B = 3v₁₂ + 0v₁₃ + 4v₂₃
typeof(B) # Chain{⟨1,1,1⟩, 2, Int64, 3}
sizeof(B) # 24
B(0) # BoundsError: attempt to access 3-element Vector{UInt64} at index [0]

There is a work-around for this, it is to wrap the Chain in a MultiVector, but a MultiVector is (depending on the basis) many times the size of a Chain. It seems to me that this behaviour of Chain is useful for the internal implementation, but at the user level, the difference between a Chain and a MultiVector should be abstracted away.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions