KYOSU is an unified implementation of the complex, quaternions, octonions and more generally all \(\mathbb{R}\)-Cayley-Dickson algebras in an SIMD aware context provided by EVE
The Cayley-Dickson construction scheme defines a new algebra as a Cartesian product of an algebra with itself, with multiplication defined in a specific way (different from the componentwise multiplication) and an involution known as conjugation.
We currently only implement the Cayley-Dickson algebras based on the IEEE float and double representations of real numbers.
Kyosu proper usable objects are all in the namespace kyosu
.
These are algebras over the real numbers with an involution named conjugation. The product of an element by its conjugate is 'real' and its positive square root is a norm on the vector space defined by the algebra.
Starting from the real numbers (supported by type T float or double) we define:
Let \(\mathbb{K}\) be a Cayley-Dickson algebra of dimension N its elements can be mathematically written
\(\displaystyle z=\sum_0^{N-1} z_i\;e_i\)
where \(e_0=1\) and \((e_i)_{i>1}\) satisfy \(e_i^2 = -1\) and a proper multiplication table relating them.
In the documentation we will sometimes use the following notations:
These datas with different dimensions can be freely mixed with the obvious semantic that if N <M an element of cayley_dickson<N> will be considered as having its components from N to M-1, null as an element of cayley_dickson<M>
Higher are the dimensions weirder are these algebras
The functions commutator (resp. associator) can be used to see if two (resp. three) Cayley-Dickson value commute (resp. associate).
Greater dimensions are not even alternative but keep power-associativity which allows to define most elementary functions.
All operators and functions implemented can receive a mix of scalar or simd of cayley-dickson and reals of various dimensionnality and are defined in the namespace kyosu.
Of course the algebra operation +, -, * and / are provided, but as \ is not an usable C++ character as an operator, the left division a \ b
is provided as the call ldiv(a,b).
complex and quaternion can be constructed using callables facilities complex
and quaternion
.
complex can also be constructed from their polar representation
quaternion from various parametrizations of \(\mathbb{R}^4\) or from \(\mathbb{R}^3\) rotations:
angle and axis | from_angle_axis | to_angle_axis |
cylindrical | from_cylindrical | to_cylindrical |
cylindrospherical | from_cylindrospherical | to_cylindrospherical |
euler | from_euler | to_euler |
multipolar | from_multipolar | to_multipolar |
rotation matrix | from_rotation_matrix | to_rotation_matrix |
semipolar | from_semipolar | to_semipolar |
spherical | from_spherical | to_spherical |
two vectors | align |
The third column references to the corresponding to_xxx version that gives back the chosen representation from a quaternion input.
TODO cayley_dickson<N> construction by a function.
Operators (as said before) +
, -
, *
and /
can be used in infix form and can mix cayley-dickson values of different dimensionalities. Of course the biggest dimensionlity is recovered in the output.
Prefix forms are also provided as add
, sub
, multiply
and div
. Also plus and minus for unary versions.
The left division sometimes necessary if the dimensionality is greater than 2 is given as ldiv
.
The left multiplication to the left by i or -i (i*i=-1) can be done calling respectively muli and mulmi
Most KYOSU callables are usable with all cayley_dickson types. The exceptions mainly being rotation related quaternion usage.
acos
DOES NOT ever provide the same result if called in EVE or KYOSU context.eve::acos(2.0) wil returns a NaN value, but kyosu::acos(2.0) will return the pure imaginary complex number \(i\;\log(2+\sqrt{3})\)
All these kinds of functions called with a floating value in the kyosu namespace will return a complex value.
callables usable with all cayley_dickson types
Most EVE arithmetic and math functions are provided. In particular, real analytic functions of one variable can be quite naturally extended using the polar form described above from a mere complex implementation.
| rising_factorial | sec| secpi | | sech | sign | sin | sinc | sincos | | sinpi | sinpicospi | sinh | sinhcosh | slerp | | sqr | sqr_abs | sqrt | tan | tanpi | | tanh | to_polar | tgamma | trunc | zeta |
Bessel functions
They deserve a separate list to avoid verbosity:
Callables usable with quaternion, complex and real only
These functions are related to \(\mathbb{R}^3\) rotations
rot_angle | rot_axis | rotate_vec |