预订演示

请注意 : 本帮助页面不适用于最新版本的Enterprise Architect. 最新的帮助文档在这里.

前页 后页

eigens

Eigenvalues and eigenvectors of a real symmetric matrix.

SYNOPSIS:

int n;
double A[n*(n+1)/2], EV[n*n], E[n];
void eigens(A, EV, E, n);

DESCRIPTION:

The algorithm is due to J. vonNeumann.
                   -     -
A[] is a symmetric matrix stored in lower triangular form. That is, A[row, column] = A[(row*row+row)/2 + column] or the equivalent with row and column interchanged. The indices row and column run from 0 through n-1.

EV[] is the output matrix of eigenvectors stored columnwise. That is, the elements of each eigenvector appear in sequential memory order. The jth element of the ith eigenvector is EV[n*i+j] = EV[i][j].

E[] is the output matrix of eigenvalues. The ith element of E corresponds to the ith eigenvector (the ith row of EV).

On output, the matrix A will have been diagonalized and its original contents are destroyed.

ACCURACY:

The error is controlled by an internal parameter called RANGE which is set to 1e-10.  After diagonalization, the off-diagonal elements of A will have been reduced by this factor.

ERROR MESSAGES:

None.

JavaScript:

function test_eigens()
{
var A = [
[0.1,0.2,0.3,0.4],
[0.5,0.6,0.7,0.8],
[0.9,0.8,0.7,0.6],
[0.5,0.4,0.3,0.2]
];
var EV = new Array();
var E = new Array();
var N = 4;
Session.Output("calling cephes.eigens( A, EV, E, N) where:");
Session.Output(" A is NxN input matrix and N = " + N);
printMatrix("A",A,N,N);
cephes.eigens(A, EV, E, N);
Session.Output(" EV is matrix of " + dimensionsOfArray(EV));
printMatrix("Y",EV,N,N);
Session.Output(" ");
Session.Output(" E is matrix of " + dimensionsOfArray(E));
printMatrix("Y",E,N,N);
Session.Output(" ");
}


function printMatrix(name, M, rows, cols)
{
for(var r = 0; r < rows; r++)
{
for(var c = 0; c < cols; c++)
{
Session.Output(name + "[" + r + "][" + c + "] = " +M[r][c]);
}
}
}

var str="";

function dimensionsOfArrayX(v)
{
str += v.length;
if(v.length)
{
var e = v[0];
if(Array.isArray(e))
{
str += " x ";
dimensionsOfArrayX(e);
}
}
}
function dimensionsOfArray(v)
{
str = "";
dimensionsOfArrayX(v);
return str;
}