Google

PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Eigensystems

Ruby/GSL provides methods for GSL_Matrix objects to compute eigenvalues and eigenvectors.

Methods

GSL_Matrix#eigen_symm

This method computes the eigenvalues of the real symmetric matrix. The eigenvectors are stored and returned as a GSL_vector object.

GSL_Matrix#eigen_symmv

This method computes the eigenvalues and eigenvectors of the real symmetric matrix. This method returns an array of two elements. The first is a GSL_vector object which stores all the eigenvalues. The second is a GSL_Matrix object, whose columns contain eigenvectors coressponding to the eigenvalues.

ex.)
  require 'gsl'

  m = GSL_Matrix.new([1.0, 1/2.0, 1/3.0, 1/4.0], [1/2.0, 1/3.0, 1/4.0, 1/5.0],
                     [1/3.0, 1/4.0, 1/5.0, 1/6.0], [1/4.0, 1/5.0, 1/6.0, 1/7.0])
  veval, mevec = m.eigen_symmv
  eval3 = veval[3]     <- an eigenvalue
  evec3 = mevec.col(3) <- an eigenvector which corresponds to the eigenvalue(3)
  p eval3              <- 9.670230402e-05
  p evec3.to_a         <- [-0.02919332316, 0.3287120558, -0.7914111458, 0.51455275]