Matrix Class

The default matrix class is a row-major-order Matrix and Inherits from Vector<RealVector>
Everything worthwhile doing in this library can be represented as a Matrix or a collection of Matrices. Matrices represent systems of linear equations most of the time. Although the basic matrix class can be used to represent graphs, I do not recommend it for this purpose as it's values are floating point and not suited to discrete data structures.

In general, operations that return every element ( i, j ) of the initial matrix are in-place operations. If the matrix operation can return a matrix of different dimensions then you should assume that a new matrix has been created and returned. In-place operations do not generate a new matrix, they only act upon the elements of the initial matrix. if there is not an obvious return value for an operation, then a reference to the original matrix is returned. For example Inverse is in place, however GetSubmatrix returns a new matrix. I haven't yet implemented a simple method to copy a matrix, but the GetSubmatrix method can be called in such a way to do this easily. In place methods return a reference to the modified matrix and not a new matrix. This is to facilitate chaining of expressions, which allows for you to create some lethal one-liners using this library.

Example of Inversion using In-Place Methods
Matrix A = Matrix.Random( 5, 5, 36, 0, 1000 );
Matrix Inv;
Inv = A.Augment( Matrix.Identity( 5, 5 ) ).
             ForwardElimination( Double.Epsilon ).
             Normalize().
             SolveByBackSubstitution().
             DeAugment( i, j );

Assert( (A*Inv).Equals( Matrix.Identity( 5, 5 ), 0.00001 ) );

Matrix Operations that return a reference to the Original Matrix's Instance

  1. Do - performs a subroutine for each element of the matrix given either the value of the element or the coordinates of the element
  2. Set - sets each element of the matrix to a value given by a user defined function
  3. ForwardElimination - Perform Gaussian Elimination taking the matrix to Row Echelon Form
  4. Normalize - divides each element on a row by the value of the pivot
  5. SolveByBackSubstitution - if used after ForwardElimination and Normalize it takes the matrix to Row Canonical Form
  6. Augment - Appends a matrix to the horizontal end of this matrix

Matrix Operations that return something else

  1. GetSubmatrix
  2. Determinant
  3. Multiplication Operator
  4. DeAugment (returns the portion of the matrix that was removed)

Properties

  1. this.M - the number of rows
  2. this.N - the number of columns

Operators

  1. * - Multiplication - Matrix multiplication

Static Methods

  1. Create
  2. Random
  3. GetFromUserInput

Method Dependency Graph

MatrixMethodDependencies.png

Method Dependency Matrix

MatrixDependencyMatrix.png

Last edited Oct 13, 2010 at 7:39 PM by CoryDambach, version 16

Comments

No comments yet.