next up previous contents
Next: Creating and accessing fixed Up: Fixed size matrices Previous: Fixed size matrices   Contents


Definitions of fixed size matrice

To use $3\times 4$ matrices or $3\times 3$ matrices include the header files
      #include <gandalf/linalg/3x4matrix.h> /* OR */
      #include <gandalf/linalg/3x3matrix.h>
respectively. This is for double precision matrix elements. The files to include for single precision elements are
      #include <gandalf/linalg/3x4matrixf.h> /* OR */
      #include <gandalf/linalg/3x3matrixf.h>
A double precision $3\times 4$ matrix is defined as
      typedef struct Gan_Matrix34
      {
         double xx, xy, xz, xw,
                yx, yy, yz, yw,
                zx, zy, zz, zw;
      } Gan_Matrix34;
A $3\times 3$ matrix is similarly defined as
      typedef struct Gan_Matrix33
      {
         double xx, xy, xz,
                yx, yy, yz,
                zx, zy, zz;
      } Gan_Matrix33;
For square matrices there is also a specific structure to handle symmetric and triangular matrix structures, as follows:
      #ifndef NDEBUG
      /* square matrix type, for setting and checking in debug mode */
      typedef enum { GAN_SYMMETRIC_MATRIX33, GAN_LOWER_TRI_MATRIX33 }
       Gan_SquMatrix33Type;
      #endif /* #ifndef NDEBUG */

      /* structure definition for square 3x3 matrix */
      typedef struct Gan_SquMatrix33
      {
      #ifndef NDEBUG
         /* square matrix type, for setting and checking in debug mode */
         Gan_SquMatrix33Type type;
      #endif /* #ifndef NDEBUG */

         /* matrix data */
         double xx,
                yx, yy,
                zx, zy, zz;
      } Gan_SquMatrix33;
Note that the matrix type field Gan_SquMatrix33 is only used in debug compilation mode (NDEBUG not defined). The type field is actually invisible to the programmers' interface to the Gandalf functions, and is used merely for internal checking. Note also that Gandalf does not provide explicit support for upper triangular fixed size matrices (although it does for general size matrices; see Section 3.2). Any operations involving upper triangular matrices can be implemented using implicit transpose of a lower triangular matrix.

Single precision structures are defined similarly, with the names changed to Gan_Matrix34_f, Gan_SquMatrix33_f etc.


next up previous contents
Next: Creating and accessing fixed Up: Fixed size matrices Previous: Fixed size matrices   Contents
2006-03-17