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....



EigenDecomposition


Unit:SDL_openarrays
Class: none
Declaration: function EigenDecomposition (Data: TDouble2DArray; SortEV: boolean; var EigenVectors: TDouble2DArray; var EigenValues: TDoubleArray): integer;

The function EigenDecomposition calculates the eigenvectors and eigenvalues of the symmetric matrix Data. The results of the eigenanalysis (i.e. the eigenvalues and the eigenvectors) are returned in the variable parameters EigenVectors and EigenValues. If the parameter SortEV is set to TRUE the eigenvectors and eigenvalues are sorted in decreasing order of the eigenvalues.

CalcEigVec increments the global variable ProcStat and calls the feedback routine MathFeedBackProc in order to allow feedback to the user during time consuming calculations. The EigenDecomposition function can be terminated by setting the global variable AbortMathProc to TRUE.

The function returns the following error codes:

 0 ... everything is OK
-1 ... the matrix Data is not square
-2 ... the Jacobi rotation did not converge
-3 ... routine aborted by user

Hint: EigenDecomposition uses Jacobi rotation to calculate the eigenvectors. Thus it must not be applied to asymmetric matrices.

Example: The eigenvectors are stored rowwise in the array EigenVectors. The following code snippet shows how to calculate the eigenvectors and copy the first and second eigenvector into the one-dimensional arrays Evec1 and Evec2 (assuming that the symmetric matrix CovarMat contains the covariance matrix):
...
var
  CovarMat       : TDouble2DArray;
  EigVec         : TDouble2DArray;
  EigVal         : TDoubleArray;
  Evec1          : TDoubleArray;
  Evec2          : TDoubleArray;
...
errnum := EigenDecomposition (CovarMat, true, Eigvec, EigVal);
CopyArrayRow (EigVec, 0, 0, 0, Evec1);  // first eigenvector (row index 0)
CopyArrayRow (EigVec, 1, 0, 0, Evec2);  // second eigenvector (row index 1)
...



Last Update: 2023-Dec-10