Grassmann algebra, Clifford algebra, and conformal geometric algebra are powerful algebraic tools

To help bring conformal geometric algebra to julia, the `Grassmann`

library now provides most of the basic tools needed to begin working with a fully generalized `MultiVector`

algebra.

This package is a work in progress providing the necessary tools to work with arbitrary dual `MultiVector`

elements with optional origin. Due to the parametric type system for the generating `VectorSpace`

, the Julia compiler can fully preallocate and often cache values efficiently. Both static and mutable vector types are supported.

It is currently possible to do both high-performance numerical computations with `Grassmann`

and it is also currently possible to use symbolic scalar coefficients when the `Reduce`

package is also loaded.

Fully general products available for high-performance and sparse computation include `β§,β¨,β
,*`

(exterior, regressive, interior, geometric). Some unary operations include `complementleft`

, `complementright`

, `reverse`

, `involve`

, `conj`

, and `adjoint`

.

### Notable features

Whatβs particularly special about `Grassmann`

is its ability to handle caching and code generation in a tiered multi-stage setup and the ability to easily handle the creation of extra specialized methods to replace composite or dynamic dispatch scenarios with more efficient code.

This can work up to `N=62`

indices in the `VectorSpace`

, reaching a `4,611,686,018,427,387,904`

dimensional `TensorAlgebra`

space, which is much beyond what Julia arrays can handle natively.

```
julia> using Grassmann
julia> i,j,k = complementright.((-Ξ(3).v1,-Ξ(3).v2,-Ξ(3).v3))
(-1vββ, 1vββ, -1vββ)
julia> @btime i^2, j^2, k^2, i*j*k
158.925 ns (5 allocations: 112 bytes)
(-1v, -1v, -1v, -1v)
julia> @btime -(j+k) * (j+k)
176.233 ns (8 allocations: 240 bytes)
2
julia> @btime -(j+k) * i
111.394 ns (6 allocations: 192 bytes)
0 - 1vββ - 1vββ
```

The `Grassmann`

package is fully general, and includes number systems such as quaternions `1,i,j,k`

.

#### Design, code generation

Due to the abstract generality of the product algebra code generation, it is possible to extend the `Grassmann`

library to include additional high performance products with few extra definitions. Operations on ultra-sparse representations for very high dimensional algebras will be gaining further performance enhancements in future updates, while the standard lower dimensional algebras already are highly performant and optimized. Thanks to the design of the product algebra code generation, any additional optimizations to the type stability will automatically enhance all the different products simultaneously. Likewise, any new product formulas will be able to quickly gain from the setup of all of the existing optimizations.

#### Calculating some bivectors

There are are a variety of resources online which help with the introduction to the subject. One notable video useful for just about anybody interested in geometric algebra was posted by @waldyrious

Some of the examples in that video can be verified `using Reduce, Grassmann`

in julia

```
julia> using Reduce,Grassmann; basis"4"
Reduce (Free CSL version, revision 4590), 11-May-18 ...
(β¨++++β©, v, vβ, vβ, vβ, vβ, vββ, vββ, vββ, vββ, vββ, vββ, vβββ, vβββ, vβββ, vβββ, vββββ)
julia> P,Q = :px*v1 + :py*v2 + :pz* v3 + v4, :qx*v1 + :qy*v2 + :qz*v3 + v4
(pxvβ + pyvβ + pzvβ + 1.0vβ, qxvβ + qyvβ + qzvβ + 1.0vβ)
julia> Pβ§Q
0.0 + (px * qy - py * qx)vββ + (px * qz - pz * qx)vββ + (px - qx)vββ + (py * qz - pz * qy)vββ + (py - qy)vββ + (pz - qz)vββ
julia> R = :rx*v1 + :ry*v2 + :rz*v3 + v4
rxvβ + ryvβ + rzvβ + 1.0vβ
julia> Pβ§Qβ§R
0.0 + ((px * qy - py * qx) * rz - ((px * qz - pz * qx) * ry - (py * qz - pz * qy) * rx))vβββ + (((px * qy - py * qx) + (py - qy) * rx) - (px - qx) * ry)vβββ + (((px * qz - pz * qx) + (pz - qz) * rx) - (px - qx) * rz)vβββ + (((py * qz - pz * qy) + (pz - qz) * ry) - (py - qy) * rz)vβββ
```

In this example, the exterior product of points is inspected and compared with inner,cross products.

It is my hope to use absorb of the feedback from the geomtric algebra community when making ongoing improvements to help refine the packageβs source code generation and sparse specialization.