Previous: Type residue-class, Up: Types of Numbers [Contents][Index]
The type ‘quatern’ is an abstract C type for integral elements of the quaternion division algebra. The actual C type (‘quatern’) is pseudo-implemented as a struct of 4 MP-integers, which are based on either GMP-MPZ or BSD-MP.
Lisp objects can be tested for the type ‘quatern’ by the following predicate.
Return t
if object is a quaternion, nil
otherwise.
The read syntax of ‘quatern’s is similar to the read syntax for
complex numbers. The lisp reader interprets
a+bi+cj+dk
as ‘quatern’ whenever
a, b, c and d are all rational integers. We
call a the z-part, b the i-part, c the j-part
and d the k-part of the quaternion.
As for complex or gaussian numbers, there exists a constructor
make-quatern
which may be used to compose a quaternion by its
components.
Return the Quaternion whose z-component is z, whose i-, j-, and k-components are i, j and k, respectively.
2+4i+3j+k ⇒ 2+4i+3j+1k 0-I-J-K ⇒ 0-1i-1j-1k (make-quatern 2 1 2 0) ⇒ 2+1i+2j+0k
And again, the single linear factors of a quaternion are regainable
by the accessor functions quatern-z
, quatern-i
,
quatern-j
and quatern-k
.
Return quatern’s z-component.
Return quatern’s i-component.
Return quatern’s j-component.
Return quatern’s k-component.
(quatern-z 1+2i-3j-k) ⇒ 1 (quatern-i 1+2i-3j-k) ⇒ 2 (quatern-j 1+2i-3j-k) ⇒ -3 (quatern-k 1+2i-3j-k) ⇒ -1