Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grade selection syntax #101

Open
ajahraus opened this issue May 27, 2022 · 6 comments
Open

grade selection syntax #101

ajahraus opened this issue May 27, 2022 · 6 comments
Labels

Comments

@ajahraus
Copy link

ajahraus commented May 27, 2022

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.

@chakravala chakravala changed the title Using the grade selection operation on a Chain type does not return the grade, but rather only the element at the index specified grade selection syntax May 27, 2022
@chakravala
Copy link
Owner

chakravala commented May 27, 2022

No, you are mistaken. That is not a grade selection syntax. The grade selection syntax is handled with the grade function:

julia> grade(v1+v2,0)
𝟎

julia> grade(v1+v2,Val(0))
𝟎

The scalar part of an element is obtained with the scalar function:

julia> scalar(v1+v2)
𝟎

Note that you may have to use Grassmann v0.8 or later to reproduce these exact results.

@ajahraus
Copy link
Author

ajahraus commented May 27, 2022

That still doesn't work for me, I get a method error

MethodError: no method matching grade(::Grassmann.MultiVector{⟨1,1,1⟩, Int64, 8})

I'm importing using Grassmann, LinearAlgebra, AbstractTensors, Leibniz

@ajahraus
Copy link
Author

Also, your documentation reads:

Taking a projection into a specific grade of a MultiVector is usually written $\langle A\rangle_n$

and can be done using the soft brackets, like so

julia> A(0)
1v

julia> A(1)
2v₁ + 0v₂ + 0v₃

julia> A(2)
3v₁₂ + 0v₁₃ + 0v₂₃

Which is the only example of selecting elements of a grade I can find, and it fails if the type happens to be a Chain rather than a MultiVector

@chakravala
Copy link
Owner

That still doesn't work for me, I get a method error
MethodError: no method matching grade(::Grassmann.MultiVector{⟨1,1,1⟩, Int64, 8})

Are you using Grassmann v0.8? That's the only currently supported version of Grassmann older versions are not supported.

Also, your documentation reads:
...
and can be done using the soft brackets, like so

No, converting \langle and \rangle sandwhich into a parenthesis prefix argument form is grammatically not implied anywhere.

@ajahraus
Copy link
Author

ajahraus commented May 27, 2022

The line which shows this syntax in your documentation is here.

@chakravala
Copy link
Owner

I see, this is why I don't want to document any features that are works in progress. This package is not v1.0 yet, and is basically my scratch pad which is ever evolving. The syntax for grade selection is not yet firmly settled on a standard and is in flux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants