Featuring included generators:
complex-numbers
dual-numbers
quaternions
clifford-algebras
Examples of generated GLSL code can be found in the examples/ directory.
> algl quaternions
> algl --out ./glsl/ clifford-algebra cga2d '1 1 1 -1'
In this example we use the complex-numbers
and clifford-algebra
generators together
in sequence to generate functions for a Clifford algebra with the complex numbers as its
base ring:
> algl --glslify --out ./glsl/ complex-numbers clifford-algebra --base C GAComplex '1 1 1 -1'
The --base
option passed to the clifford-algebra
generator specifies that the base struct
for this Clifford algebra should be C
, the name of the struct outputted by complex-numbers
.
The --glslify
option passed at the beginning creates an index.glsl
file with
glslify-import directives for importing all of the
generated glslify files in the order they were generated.
Use the --help
option!
> algl --help
> algl <COMMAND> --help
I made alglbraic
with geometric algebra in mind but the underlying library is flexible
enough to generate GLSL code for any algebra you can get SymPy to print. If you're
interested in other algebras I recommend reading the code in alglbraic/algebras.
The code generated by this library is not optimized in any special way! It just bakes out all of the math into GLSL code. If you find it to be quick that's only because it's running on the GPU and everything is happening in parallel.
This tool probably isn't a good fit for generic computations of operations for algebras with more than 32 or maybe 64 basis dimensions.
To get started you'll need to install Poetry.
> poetry shell
followed by
> poetry install
> pytest
or:
> ptw
If you change something in a way that breaks the snapshots, the only way I've found to update them
is by carefully deleting the snapshot file for the thing that's changed and re-running pytest
.