Previous: , Up: Types of Numbers   [Contents][Index]


63.2.10 The Type ‘quatern

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.

Function: quaternp object

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.

Function: make-quatern z i j k

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.

Function: quatern-z quatern

Return quatern’s z-component.

Function: quatern-i quatern

Return quatern’s i-component.

Function: quatern-j quatern

Return quatern’s j-component.

Function: quatern-k quatern

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