Rectangular matrices

Header file matrix.h

General matrix class

Name
Matrix
Inheritance
array of vectors: Array<Vector>

Constituents

(As for Array<Vector>, plus numbers of rows and columns.)

Methods

(Extending Array<Vector>)
Creation
Input and output
The << and >> operators can be used.

Data format:

rows columns
For each row:
   For each column:
      value
The class also provides Read_elements and Write_elements methods to read and write the elements only, without the number of rows and columns.) e.g.
Matrix x; cin >> x; cout << x << endl; x.Write_elements(cout);
Assignment
=

e.g. Matrix x,y; cin >> x; y = x;

Tests
Decompose into symmetric and antisymmetric parts
void symm_antisymm(Matrix& symm, Matrix& antisymm) const returns the symmetric part in symm and the antisymmetric part in antisymm
Extract a sub-matrix
   Matrix submatrix(
      const int row0, // first row of submatrix
      const int row1  // last row of submatrix
      const int col0, // first column of submatrix
      const int col1  // last column of submatrix
   ) const

e.g. Matrix y = x.submatrix(0,4,1,3);

Matrices of zeroes
Identity matrix
Trace
friend double trace(const Matrix& a)
Norm (sum of squares of elements)
friend double norm(const Matrix& a)
Diagonal matrix from vector
friend Matrix diag(const Vector& v)
Inner product
The following methods all return a.b, where a and b are matrixs with the same number of elements.

e.g.

   Matrix x,y; cin >> x >> y;
   Matrix a = inner_product(x,y), b = dot(x,y), c = x * y; // a = b = c
Norm
(Sum of squares of elements.) friend double norm(const Matrix& a)

e.g. Matrix a; cin >> a; double anorm = norm(a);

Arithmetic operations
These methods allow conventional-looking equations to be written with matrix quantities.

General matrix class (fixed dimension)

Name
Matrix_fixed_dimension
Inheritance
matrix
A Matrix_fixed_dimension is exactly the same as a Matrix, except that the Read and Write methods are redefined to omit the number of elements. (This means that the number of elements must be set before a Matrix_fixed_dimension is read.)

This class is the base for matrixs of a specific dimension.

6D matrix class

Name
Matrix6d
Inheritance
Matrix_fixed_dimension

5D matrix class

Name
Matrix5d
Inheritance
Matrix_fixed_dimension

4D matrix class

Name
Matrix4d
Inheritance
Matrix_fixed_dimension

3D matrix class

Name
Matrix3d
Inheritance
Matrix_fixed_dimension

2D matrix class

Name
Matrix2d
Inheritance
Matrix_fixed_dimension

Methods

Cross product
Calculates the real value a^b.
   friend vector operator^(const Matrix2d& a, const Matrix2d& b)
Rotation

General real matrix class

This is a prototype class for research into structures of arbitrary type.
Name
real_matrix
Inheritance
Arithmetic_matrix<Vector>