[ANN]: Multivectors.jl

Very cool, glad to see more packages exploring this space! If you’re interested, I’d be happy to collaborate with you at some point on this package if you’re interested. What sort of work would you like to see happen in this space in the near future?

One thing I’ve noticed is that it seems that your Multivectors are not of a static dimensionality. That’s an interesting choice and while I can see advantages, I think there are great advantages to having the dimension of the algebra be encoded in the type of the Multivector. This lets you do things like unroll multiplications between multivectors, and I don’t think it’s an especially common usecase to multiply elements of geometric algebras of different dimensions. There was a discussion of this here: Encoding group elements and operations - #17 by Mason

where I showed the advantage of the unrolling. Here’s a comparison between the multiplication I hackily implemented in https://github.com/MasonProtter/GeometricAlgebras.jl and the multiplication in Multivectors.jl for a 3 dimensional geometric algebra:

using GeometricAlgebras
s, γ1, γ2, γ3 = basis_vectors(3)

A = s + γ1 + 2γ2 - γ3
B = γ1*γ2 - 3s
#--------------------------------
using Multivectors
@generate_basis("+++")

C = 1 + 1e₁ + 2e₂ - 1e₃
D = 1e₁*1e₂ - 3
#--------------------------------
f(A, B) = A*(A*A + B*B)*B

julia> @btime f($A, $B)
  92.291 ns (0 allocations: 0 bytes)
-75.0 + -115.0γ₁ + -55.0γ₂ + 45.0γ₃ + 45.0γ₁γ₂ + -35.0γ₁γ₂γ₃

julia> @btime f($C, $D)
  70.279 μs (1190 allocations: 33.17 KiB)
Multivector{Int64,3}
⟨-75⟩₀ + ⟨-55e₂,-115e₁,45e₃⟩₁ + ⟨45e₁₂,0e₁₃,0e₂₃⟩₂ + ⟨-35e₁₂₃⟩₃

One could maybe think of what I did as being like StaticArrays.jl, whereas your Multivectors are more akin to regular, dynamically sized arrays.

3 Likes