Closed davibarreira closed 1 year ago
I've documented all functions, even the ones that belong to internal implementation details. basegrade
is such an implementation detail, because it deals with the internal multi-vector basis and not the user-exposed basis. The user can construct his own multi-vector basis from the underlying one-vector basis. So I'm surprised that you're using basegrade
. What is your use-case?
I would be very happy to receive good example code that demonstrates the library. So please, go ahead and make a pull request.
I'm implementing the algorithm to find the meet and join of two blades. The algorithm uses the symmetric difference, which is computed as $\langle A B \rangle_{max}$, which is the largest non-null grade.
Here is the implementation:
"""
maxgrade(A::MultiVector)
Returns the maximum grade ``k`` of a multivector A
with non-null value, i.e. ``\\langle A \\rangle_{max}``
is equal to `grade(A,maxgrade(A))`.
"""
function maxgrade(A::MultiVector)
k = findlast(x -> !(x ≈ 0), vector(A))
if isnothing(k)
return 0
end
return basegrade(algebra(A), k)
end
I see. There is another problem with this implementation on the user side: vector
is meant to provide a vector space homomorphism and there is no guarantee that the coefficients in that vector are in the same order as the internal basis. In the current implementation this works, but as an implementation detail, this may change in the future.
There is also no guarantee that the internal basis orders basis multi-vectors with increasing grade, which you are also relying on.
The proper way to implement maxgrade
on the user side would be using something like
findlast(!isapprox(0), norm_sqr(grade(mv,k)) for k in 0:D)
which gives you either maxgrade+1
or nothing and where D
is the dimension of the one-vector space.
I see that there's no function for querying D
, so I will add that. And while I am at it, I will probably add something like maxgrade
or the projection onto the corresponding grade subspace.
I've pushed a new commit to master that introduces maxgrade
and mingrade
. Please let me know if this works for you.
Thanks!
Hello, me again. I noticed that the
basegrade
function is in the docs, but it's not actually exported in the package. Is there a reason behind it? I'm using thebasegrade
function, so having it exported would be nice. In a similar note, I'm writing some code regarding Clifford Algebras and the Conformal Model. Are you interested in Pull requests to give more examples of how to use the package?