C library for algebra, arithmetic, and analysis on algebras resulting from the Cayley-Dickson procedure over various fields
  • C 99.5%
  • Makefile 0.5%
Find a file
2026-05-10 17:31:55 -04:00
art added features based on matrix algebra 2026-05-09 23:10:28 -04:00
include improved memory safety and added documentation 2026-05-10 17:28:52 -04:00
src improved memory safety and added documentation 2026-05-10 17:28:52 -04:00
tests improved memory safety and added documentation 2026-05-10 17:28:52 -04:00
LICENSE.md v0.1.0 2026-05-10 11:02:48 -04:00
Makefile v0.1.0 2026-05-10 11:02:48 -04:00
README.md Update README.md 2026-05-10 17:31:55 -04:00

Quaternionic - v1.0.0

Quaternionic is a mathematics library written from scratch in C offering implementations of the algebra and arithmetic of algebras resulting from the Cayley-Dickson construction. Supported base fields include the rationals, the reals, complex numbers, arbitrary finite fields, and arbitrary number fields. Quaternionic mainly focuses on quaternion algebras and, secondarily, octonion algebras, but it supports basic algebra and arithmetic for sedenions, trigitaduonions, and arbitrary Cayley-Dickson algebras as well.

While it is meant to be suitable for standalone use, Quaternionic has been designed with incorporation into Bestiary as an ultimate goal. It makes use of built-in libraries for fraction arithmetic, complex numbers, linear algebra, and field arithmetic so that it can be used in a fully independent manner, with no additional dependencies. However, for ease of use in research applications, it is recommended to be used within Bestiary once it is incorporated, which is being worked on currently.

Quaternionic is currently in active development. Since it is itself just a C library, it may be assumed to have full support for any platform using LibC. Those interested in contributing code, providing bug reports, or suggesting new features are invited to do so on the git page.

Features

Basic features include:

  • Support for basic field arithmetic via the Field and FieldElement structs
  • A homemade implementation of basic matrix and vector math
  • Fraction arithmetic, complex number arithmetic, and field element formatting for supported fields
  • Constructing arbitrary Cayley-Dickson algebras via constructCDAlgebra
  • Constructing quaternion and octonion algebras via constructQuaternionAlgebra and constructOctonionAlgebra
  • Constructing elements of Cayley-Dickson, quaternion, and octonion algebras
  • Adding, subtracting, multiplying, conjugating, and scalar multiplying Cayley-Dickson elements
  • Computing Cayley-Dickson inverses, norms, left division, and right division
  • Computing the commutator (cdCommutator) and associator (cdAssociator) of Cayley-Dickson elements
  • Converting Cayley-Dickson elements to and from coordinate vectors over the base field
  • Computing left and right multiplication matrices, commutator matrices, and associator matrices
  • Computing bases for spans, centers, nuclei, generated subalgebras, generated left ideals, generated right ideals, and generated two-sided ideals
  • Detecting left and right zero divisors and computing bases for left and right annihilators
  • Representing generated ideals and subalgebras as structured CDIdeal and CDSubalgebra objects
  • Ideal arithmetic and intersection logic for subalgebras
  • Constructing the standard matrix representation of a quaternion algebra over F(sqrt(a))

Building

Quaternionic is built with a C11 compiler and the C standard library. The only extra system library linked by the test binaries is the math library, libm.

From the root of the repository, run:

make all

This creates the build/ directory, compiles all source objects from src/, and builds all test binaries.

To build and run the full test suite, run:

make test-all

Individual test targets are also available:

make test-field
make test-matrix
make test-cd
make test-quaternion
make test-octonion

To remove generated objects and test binaries, run:

make clean

License and Attribution

Quaternionic and all associated code are licensed under the GPLv3. A copy of this license is included in the main repository as the LICENSE.md file.