Closed davibarreira closed 1 year ago
Your implementation is mostly correct. I would enforce a
and b
be from the same algebra. You can also use coefficient
to extract the coefficients without reference to the properties:
function Base.:≈(a::MultiVector{CA},b::MultiVector{CA}) where {CA}
K = order(CA)
N = 2^K
for n = 1:N
if !isapprox(coefficient(a,n), coefficient(b,n))
return false
end
end
return true
end
However, for large algebras you may want to use the sparse encoding of the multi vectors, which can be accessed using coefficients
and baseindices
. With this, you can check if the coefficients of a and b are approximately the same for the intersection of their respective base indices and approximately zero for the set differences.
This is clearly more complicated than the code above, but may be worth it if you need the performance.
Hey, me again. So, I'm writing some auxiliary functions, such as
isapprox
. I was wondering what is the "correct" way of iterating over a multivector. For example, it would be nice to havemap(f, a::Multivector)
.Based on the last answer you gave me, it's not advisable to use the
vector
function to turn the multivector into an iterable vector. My question is, what is the correct way of doing this? Here is my naive implementation of theisapprox
function:Now,