There are two base template classes for algebraic calculations: VectorData and MatrixData. As classes names show, these classes organize information in unidimentional (VectorData) and bi-dimentional matrices (MatrixData). These templates can be used anywhere in the library, but essentially they form the base classes from which others derive. RealVec and RealMat are classes derived from these templates.
The class RealVec represents a vector of real numbers, and contains several operators and methods for vectorial calculations. These include:
RealMat represents a bi-dimentional matrix of real numbers, that also contains several operators and methods for matricial calculations. These include:
These classes are strongly interrelated. For instance the indexation operator of a RealMat returns a RealVec containing the desired ith line. This allows the user to use RealVec operations in the lines of RealMat objects, as exemplified in the code below.
#include "types.h" RealVec aRealVec; // Creates a vector of dimension 0 (empty vector) aRealVec << 0.2 << -1.2 << 2.2 << 0.8; // Adds 4 new elements to the vector aRealVec.size(); // The vector dimension is now 4 aRealVec[2] = +3.4; // Modifies the third element of the vector RealMat mat( 5, 4 ); // Creates a matrix with 5 rows and 4 columns mat[3].assign( aRealVec ); // Assign aRealVec to the matrix 4th row mat[3].exp(); // Calculates the exponential values for all elements of the 4th row // mat[3].exp() is equivalent to the following calculation (which is performed element-by-element) for( int i=0; i < mat.cols(); i++ ) { mat[3][i] = exp( mat[3][i] ); }