computeEigenDecomposition
Computes the eigenvectors and eigenvalues of a symmetric matrix.
Returns a diagonal matrix and unitary matrix such that: matrix = unitary matrix * diagonal matrix * transpose(unitary matrix)
The values along the diagonal of the diagonal matrix are the eigenvalues. The columns of the unitary matrix are the corresponding eigenvectors.
const a = //... symetric matrix
const result = {
unitary : new Matrix3(),
diagonal : new Matrix3()
};
Matrix3.computeEigenDecomposition(a, result);
const unitaryTranspose = Matrix3.transpose(result.unitary, new Matrix3());
const b = Matrix3.multiply(result.unitary, result.diagonal, new Matrix3());
Matrix3.multiply(b, unitaryTranspose, b); // b is now equal to a
const lambda = Matrix3.getColumn(result.diagonal, 0, new Cartesian3()).x; // first eigenvalue
const v = Matrix3.getColumn(result.unitary, 0, new Cartesian3()); // first eigenvector
const c = Cartesian3.multiplyByScalar(v, lambda, new Cartesian3()); // equal to Matrix3.multiplyByVector(a, v)
Content copied to clipboard
Return
An object with unitary and diagonal properties which are the unitary and diagonal matrices, respectively.
Parameters
matrix
The matrix to decompose into diagonal and unitary matrix. Expected to be symmetric.
result
An object with unitary and diagonal properties which are matrices onto which to store the result.