The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....



Using TMatrix


The classes TMatrix, TIntMatrix  and TMat3D provide containers for a two- and three-dimensional matrix of integer and floating point numbers (of type double) and the corresponding methods to manipulate this matrix. The methods of TMatrix provide only the most fundamental routines for handling such matrices. More elaborate mathematical methods are contained in the unit MATH2. In addition some other units (e.g. the Kohonen network) are based on matrices.

The indices of a matrix of the class TMatrix are counted starting at 1 up to NrOfRows, or NrOfColumns respectively. In order to use TMatrix the user has first to create one or several matrices (instances of class TMatrix ) by calling the method Create. If a matrix is not needed anymore, it should be removed from the memory by calling the methods Destroy  or (preferably) Free. The individual elements of a matrix are represented by the property Elem. Most of the matrix operations are available via methods. The following code snippet shows a very simple sample application: a square matrix (Mat1) of 27 elements is created and filled with a constant value for the diagonal elements of 1.0, with all other elements being set to zero values. At the end of the program the matrix is destroyed.

const
  MatCols = 40;             { size of the matrix }
  MatRows = 27;

var
  Mat1    : TMatrix;

begin
Mat1 := TMatrix.Create (nil);
Mat1.Resize (MatCols, MatRows);
    { here comes your code to
      process the matrix Mat1 }
Mat1.Free;
end;

Hint: In the case of type ambiguities concerning TMatrix please see the SDL TechNotes.


Last Update: 2023-Feb-06