Class: Matrix
Instance Method Summary collapse
- #[]=(i, j, x) ⇒ Object
-
#eigenpairs ⇒ Object
Optimize eigenpairs of extendmatrix module using gsl.
- #eigenpairs_ruby ⇒ Object
- #eigenvalues ⇒ Object
- #eigenvectors ⇒ Object
- #eigenvectors_matrix ⇒ Object
- #to_dataframe ⇒ Object (also: #to_dataset)
- #to_gsl ⇒ Object
- #to_matrix ⇒ Object
Instance Method Details
#[]=(i, j, x) ⇒ Object
62 63 64 |
# File 'lib/statsample/matrix.rb', line 62 def []=(i, j, x) @rows[i][j] = x end |
#eigenpairs ⇒ Object
Optimize eigenpairs of extendmatrix module using gsl
37 38 39 |
# File 'lib/statsample/matrix.rb', line 37 def eigenpairs to_gsl.eigenpairs end |
#eigenpairs_ruby ⇒ Object
32 |
# File 'lib/statsample/matrix.rb', line 32 alias_method :eigenpairs_ruby, :eigenpairs |
#eigenvalues ⇒ Object
42 43 44 |
# File 'lib/statsample/matrix.rb', line 42 def eigenvalues eigenpairs.collect {|v| v[0]} end |
#eigenvectors ⇒ Object
46 47 48 |
# File 'lib/statsample/matrix.rb', line 46 def eigenvectors eigenpairs.collect {|v| v[1]} end |
#eigenvectors_matrix ⇒ Object
50 51 52 |
# File 'lib/statsample/matrix.rb', line 50 def eigenvectors_matrix Matrix.columns(eigenvectors) end |
#to_dataframe ⇒ Object Also known as: to_dataset
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/statsample/matrix.rb', line 14 def to_dataframe f = (self.respond_to? :fields_y) ? fields_y : column_size.times.map {|i| "VAR_#{i+1}".to_sym } f = [f] unless f.is_a?(Array) ds = Daru::DataFrame.new({}, order: f) f.each do |ff| ds[ff].rename ff end row_size.times {|i| ds.add_row(self.row(i).to_a) } ds.update ds.rename(self.name) if self.respond_to? :name ds end |
#to_gsl ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/statsample/matrix.rb', line 54 def to_gsl out=[] self.row_size.times{|i| out[i]=self.row(i).to_a } GSL::Matrix[*out] end |
#to_matrix ⇒ Object
10 11 12 |
# File 'lib/statsample/matrix.rb', line 10 def to_matrix self end |