next up previous contents
Next: Creating and freeing general Up: General size matrices and Previous: Rescaling a general size   Contents


General size matrices

The structure and functions for general size matrices are declared in the header file
      #include <gandalf/linalg/mat_gen.h>
The structure for general size matrices is the Gan_Matrix. For special types of square matrix the structure is the Gan_SquMatrix, and is declared in the header file
      #include <gandalf/linalg/mat_square.h>
The square matrix types are listed in linalg_defs.h (file not to be included explicitly in application programs):
      /* types of square matrix */
      typedef enum { GAN_SYMMETRIC_MATRIX,     /* symmetric */
                     GAN_DIAGONAL_MATRIX,      /* diagonal */
                     GAN_SCALED_IDENT_MATRIX,  /* identity times scalar */
                     GAN_LOWER_TRI_MATRIX,     /* lower triangular */
                     GAN_UPPER_TRI_MATRIX,     /* upper triangular */
                     GAN_ZERO_SQUARE_MATRIX }  /* square matrix filled with zeros */
        Gan_SquMatrixType;
Use of the special matrix types producs savings both in memory and computation time, and should be exploited wherever appropriate. To use any functions specific to the above square matrix types (as opposed to general square matrix functions common to many types), you will need to include the header file for the specific type you need, for instance
      #include <gandalf/linalg/mat_symmetric.h>
for symmetric matrices, and
      #include <gandalf/linalg/mat_triangular.h>
for triangular matrices (covers lower and upper triangular matrices). The full list of header files for the specific square matrix types is
      #include <gandalf/linalg/mat_symmetric.h>  /* for symmetric matrices */
      #include <gandalf/linalg/mat_triangular.h> /* lower/upper triangular matrices */
      #include <gandalf/linalg/mat_diagonal.h>   /* diagonal matrices */
      #include <gandalf/linalg/mat_scaledI.h>    /* scaled identity matrices */
The square matrix routines are organised so that once the matrix has been set at a specific type and size, and filled with values, the functions that operate on it are general functions. The computational overhead is that whenever an operation is performed (such at matrix/matrix multiplication) there is an indirection to take the program into the correct routine for the current square matrix type. This design allows the programmer to easily design algorithms that will work correctly and efficiently for any square matrix type.



Subsections
next up previous contents
Next: Creating and freeing general Up: General size matrices and Previous: Rescaling a general size   Contents
2006-03-17