The Linear Algebra Package (original) (raw)
Next: Fixed size matrices and Up: Gandalf: The Fast Computer Previous: Error tests and codes Contents The linear algebra package covers matrix and vector manipulations, matrix decompositions and other operations. To be able to use any function or structure in the linear algebra package use the declaration
#include <gandalf/linalg.h>but including individual module header files instead will speed up program compilation. There are two parts to the linear algebra package, one dealing with small fixed size vectors and matrices, between size two and four, and another for general size objects. This separation allows the most efficient implementation of linear algebra operations when the size of the objects is known and small. Being designed to support image- and goemetry-based applications, the size range from two to four allows 2D image and 3D camera/world objects to be manipulated, in homogeneous coordinates where required; thus four is the natural size limit for Gandalf.
A major design feature of the linear algebra package is the application of implicit operations. By this is meant, for example, that adding a matrix to the transpose of another matrix is a one step operation. Rather than transposing the matrix and then adding it, there is a specific Gandalf routine to apply the operation ``add matrix to transpose of another matrix'', implemented by indexing the elements of the second matrix in transposed order. This principle increases greatly the number of routines that Gandalf implements, but also greatly increases the efficiency of the package. It can also help to reduce errors, in the case of implicit matrix inverse. Let us say that we want to compute a matrix/vector product where the matrix is to be inverted:
If
happens to be a diagonal matrix, it makes sense to apply the inverse operation implicitly, inside the product operation. This is because if, for example, we are dealing with vectors & matrix of size 2, we have
and the operations required are
Applying the inverse firstly to
and then computing the product would involve the following operations
This has two drawbacks: the two stages of inverting followed by multiplication reduces the accuracy of the result compared to a single division operation, and the
matrix is overwritten with the inverse of
, which is not normally what is wanted (explicit matrix inverse is to be avoided wherever possible). As we shall see, Gandalf implements a comprehensive set of implicit transpose and inverse operations, which apply when the matrix involved is diagonal (as above) or triangular. For these types of matrix the inverse operation can be conjoined with multiplication, such that effectively only one operation is performed. Implicit inverse does not apply to symmetric or general square matrices, because there is no way of conjoining the inverse with multiplication in the same way.
Subsections
- Fixed size matrices and vectors
- Fixed size vectors
* Creating and accessing fixed size vectors
* Fixed size vector addition
* Fixed size vector subtraction
* Rescaling a fixed size vector
* Fixed size vector products
* Fixed size vector file I/O
* Conversion from general to fixed size vector
* Single precision fixed size vectors
* Other types of fixed size vector
* Other sizes of fixed size vector
* Setting/extracting parts of fixed size vectors - Fixed size matrices
* Definitions of fixed size matrice
* Creating and accessing fixed size matrices
* Fixed size matrix addition
* Fixed size matrix subtraction
* Rescaling a fixed size matrix
* Transposing a fixed size matrix
* Fixed size vector outer products
* Fixed size matrix/vector multiplication
* Fixed size matrix/matrix multiplication
* Fixed size matrix inverse
* Determinant, trace, norms of fixed size matrix
* Fixed size matrix decompositions
* Fixed size matrix file I/O
* Conversion from general to fixed size matrix
* Single precision fixed size matrices
- Fixed size vectors
- General size matrices and vectors
- General size vectors
* Creating and freeing general size vectors
* Adjusting the size of a general size vector
* Filling a general size vector with values
* Accessing the elements of a general size vector
* Copying a general size vector
* General size vector addition
* General size vector subtraction
* Rescaling a general size vector - General size matrices
* Creating and freeing general size matrices
* Adjusting the size of a general size matrix
* Filling a general size matrix with values
* Accessing the elements of a general size matrix
* Copying a general size matrix
* Transposing a general size matrix
* General size matrix addition
* General size matrix subtraction
* Rescaling a general size matrix
* General size matrix/vector multiplication
* General size matrix/matrix multiplication
* Inverting a general size matrix
* Cholesky factorising a general size symmetric matrix
* Symmetric matrix eigendecomposition
* Accumulated symmetric matrix eigendecomposition - Single precision general size matrices & vectors
- General size vectors
Next: Fixed size matrices and Up: Gandalf: The Fast Computer Previous: Error tests and codes Contents
2006-03-17