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
61 62 63 |
# File 'lib/statsample/matrix.rb', line 61 def []=(i, j, x) @rows[i][j] = x end |
#eigenpairs ⇒ Object
Optimize eigenpairs of extendmatrix module using gsl
36 37 38 |
# File 'lib/statsample/matrix.rb', line 36 def eigenpairs to_gsl.eigenpairs end |
#eigenpairs_ruby ⇒ Object
31 |
# File 'lib/statsample/matrix.rb', line 31 alias_method :eigenpairs_ruby, :eigenpairs |
#eigenvalues ⇒ Object
41 42 43 |
# File 'lib/statsample/matrix.rb', line 41 def eigenvalues eigenpairs.collect {|v| v[0]} end |
#eigenvectors ⇒ Object
45 46 47 |
# File 'lib/statsample/matrix.rb', line 45 def eigenvectors eigenpairs.collect {|v| v[1]} end |
#eigenvectors_matrix ⇒ Object
49 50 51 |
# File 'lib/statsample/matrix.rb', line 49 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 |
# 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.rename(self.name) if self.respond_to? :name ds end |
#to_gsl ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/statsample/matrix.rb', line 53 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 |