Defining Matrices
Once we understand vectors, the next most important abstraction in linear algebra is the concept of a linear mapping from one vector space to another. Since we are concerned only with vectors of finite dimension, such a mapping can always be represented using a matrix of coefficients. If x is a vector from one space, and y is a vector from another, we can represent a linear mapping from x to y as y=Ax, where A is a matrix, and Ax is an inner product. Often, the matrix A has some special structure; for example, it may be banded or symmetric.
The Linear Algebra Module has classes for many different matrix types. Each matrix type has a similar interface, so if you learn one, learning the others is easy. To give you a feel for using a matrix type, here is a simple example using a tridiagonal matrix class:
#include <rw/lapack/trdgmat.h> // 1
#include <iostream>
int main()
{
RWTriDiagMat<float> T(6,6); // 2
T.zero();
T.diagonal(0) = 2; // 3
T.diagonal(-1) = 1;
T.diagonal(1) = 3;
T(1,2) = 4; // 4
RWMathVec<float> x = " [ 2 3 9 8 3 0 ] ";
RWMathVec<float> Tx = product(T,x); // 5
std::cout << T << std::endl;
std::cout << x << std::endl;
std::cout << Tx << std::endl;
return 0;
}