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 (with a few exceptions restricted to some dimensionnalities constraints) 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). Note that except for real and complex this is NOT b/a.
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.
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, mul, div and ldiv. These version are multiparameters and can also use KUMI tuples. Also plus and minus can be used for unary versions.
The left division sometimes necessary if the cayley dimensionality is greater than 2 is given as ldiv.
The multiplication to the left by i or -i (i*i=-1) can be done calling respectively muli and mulmi which ensure optimization. With the right option the multiplication is done to the right.
Most KYOSU callables are usable with all cayley_dickson_like types. The exceptions mainly being rotation related quaternion usage.
Also many functions as sqrt nthroot or log are the principal value of a multiple valued inverse of an analytic function. Most of these functions can use a second parameter that allows to choose another branch.
All these kinds of functions called with a floating value in the kyosu namespace will return a complex value.
However, many of those functions provide a real_only option that allows to call them with floating value typed parameters (NOT cayley_dickson_like with null pure part) and returns the floating value of the same type which is the eve call result.
For example, eve::acos(2.0) and kyosu::acoskyosu::real_only will returns a NaN value, but kyosu::acos(2.0) will return the pure imaginary complex number \(i\log(2+\sqrt{3})\)
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.
The extension scheme is the following for a function \(f(z)\) defined on complex input \(z\). If c is an arbitrary cayley_dickson entry:
Moreover some functions are defined that does not pertain to EVE because they never return real results for real entries. (For instance exp_i).
Callables usable with quaternion, complex and real only
These functions are related to \(\mathbb{R}^3\) rotations
| rot_angle | rot_axis | rotate_vec |
fnan(as<Z>()) returns a cayley-dickson like in which all parts are nans.