eigensEigenvalues and eigenvectors of a real symmetric matrix.
double A[n*(n+1)/2], EV[n*n], E[n];
void eigens(A, EV, E, n);
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.
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.
var A = [
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);
cephes.eigens(A, EV, E, N);
Session.Output(" EV is matrix of " + dimensionsOfArray(EV));
Session.Output(" E is matrix of " + dimensionsOfArray(E));
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]);
str += v.length;
var e = v;
str += " x ";
str = "";