Eigenvalues and eigenvectors of a real matrix.
Computes the eigenvalues and eigenvectors of a matrix A.
If A is diagonalizable, this provides matrices V and D such that A = V*D*V.inv, where D is the diagonal matrix with entries equal to the eigenvalues and V is formed by the eigenvectors.
If A is symmetric, then V is orthogonal and thus A = V*D*V.t
Methods
- D
- E
- N
- T
- V
Class Public methods
new(a)
Link
Constructs the eigenvalue decomposition for a square matrix A
# File lib/matrix/eigenvalue_decomposition.rb, line 18 def initialize(a) # @d, @e: Arrays for internal storage of eigenvalues. # @v: Array for internal storage of eigenvectors. # @h: Array for internal storage of nonsymmetric Hessenberg form. raise TypeError, "Expected Matrix but got #{a.class}" unless a.is_a?(Matrix) @size = a.row_count @d = Array.new(@size, 0) @e = Array.new(@size, 0) if (@symmetric = a.symmetric?) @v = a.to_a tridiagonalize diagonalize else @v = Array.new(@size) { Array.new(@size, 0) } @h = a.to_a @ort = Array.new(@size, 0) reduce_to_hessenberg hessenberg_to_real_schur end end
Instance Public methods
eigenvalues()
Link
Returns the eigenvalues in an array
eigenvector_matrix_inv()
Link
Returns the inverse of the eigenvector matrix V
Also aliased as: v_inv
eigenvectors()
Link
Returns an array of the eigenvectors
to_ary()
Link
Returns [eigenvector_matrix, #eigenvalue_matrix, #eigenvector_matrix_inv]
Also aliased as: to_a