rStats.js v1.3.0
    Preparing search index...

    Function eigen

    • Eigenvalues and eigenvectors of a square matrix. Equivalent to R's eigen().

      Symmetric matrices use tridiagonalization and the implicit QL method; other matrices use Hessenberg reduction and the Francis double-shift QR method, after balancing the matrix as LAPACK's dgebal does. R uses LAPACK, so eigenvalues agree up to rounding, but eigenvector signs may differ from R (both are correct); for repeated eigenvalues the basis may differ. Complex eigenvalues and eigenvectors are returned as separate real and imaginary parts (valuesIm, vectorsIm). Each complex eigenvector is scaled to unit length with its largest component real and positive. Throws on NaN or infinite values.

      Parameters

      Returns EigenResult

      The eigenvalues and eigenvectors. See EigenResult.

      const e = eigen([[2, 1], [1, 2]]);
      e.values; // [3, 1]
      e.vectors; // [[0.7071, 0.7071], [0.7071, -0.7071]] (signs may differ from R)

      eigen([[0, -1], [1, 0]]); // { values: [0, 0], valuesIm: [1, -1] }