class Matrix

Public Instance Methods

eigenpairs() click to toggle source

Optimize eigenpairs of extendmatrix module using gsl

# File lib/statsample/matrix.rb, line 33
def eigenpairs
  to_gsl.eigenpairs
end
eigenvalues() click to toggle source
# File lib/statsample/matrix.rb, line 38
def eigenvalues
  eigenpairs.collect {|v| v[0]}
end
eigenvectors() click to toggle source
# File lib/statsample/matrix.rb, line 41
def eigenvectors
  eigenpairs.collect {|v| v[1]}
end
eigenvectors_matrix() click to toggle source
# File lib/statsample/matrix.rb, line 44
def eigenvectors_matrix
  Matrix.columns(eigenvectors)
end
to_dataset() click to toggle source
# File lib/statsample/matrix.rb, line 13
def to_dataset
  f = (self.respond_to? :fields_y) ? fields_y : column_size.times.map {|i| _("VAR_%d") % (i+1) }
  ds=Statsample::Dataset.new(f)
  f.each do |ff|
    ds[ff].type=:scale
    ds[ff].name=ff
  end
  row_size.times {|i|
    ds.add_case_array(self.row(i).to_a)
  }
  ds.update_valid_data
  ds.name=self.name if self.respond_to? :name
  ds
end
to_gsl() click to toggle source
# File lib/statsample/matrix.rb, line 52
def to_gsl
  out=[]
  self.row_size.times{|i|
    out[i]=self.row(i).to_a
  }
  GSL::Matrix[*out]
end
to_matrix() click to toggle source
# File lib/statsample/matrix.rb, line 10
def to_matrix
  self
end