Skip to content

Quaternions and Abstract Algebra

Anders Peterson edited this page Dec 7, 2017 · 7 revisions

The org.ojalgo.algebra package contain a collection of interfaces related to abstract algebra: Group, Field, Ring, VectorSpace... The definition of these concepts are very abstract, but they've been turned into Java interfaces that are actually used throughout ojAlgo.

In ojAlgo there is a org.ojalgo.scalar.Quaternion class that extends java.lang.Number and implements org.ojalgo.scalar.Scalar which in turn extends a number of the interfaces from the org.ojalgo.algebra package. Quaternions are not widely used nor generally well understood. In ojAlgo they're tagging along as just another Scalar, and there is quite a lot of code that works with any Scalar...

org.ojalgo.array

You can create 1-, 2- or N-dimensional, sparse or dense, arrays of Quaternion:s – and they can be arbitrarily large (using long indices). The ojAlgo array classes are quite feature rich, and all of it works with Quaternion:s. Have a look at Working with arrays for some examples.

org.ojalgo.function

There is a large set of implemented Quaternion valued functions QuaternionFunction and QuaternionAggregator.

org.ojalgo.matrix

Anything you can do with matrices and vectors in ojAlgo, you can do with Quaternion elements. This includes calculating various matrix decompositions. Potentially you can do things like SVD:s or EvD:s using Quaternion elements.

The are most likely other/more parts of ojAlgo that can easily be extended to also work with Quaternion:s.

Be aware that Quaternion functionality is just "tagging along". Large parts of the code base was written for ComplexNumber and then generalised to work for any Scalar. The real number implementations are generally well tested, rational number and complex number implementations are somewhat tested, but there are typically few tests that explicitly test quaternions. If you plan to use ojAlgo's Quaternion you should probably start by writing some tests.