Class: GLM::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/glm/util.rb

Class Method Summary collapse

Class Method Details

.aa_to_gsl_matrix(aa) ⇒ Object

Construct a GSL::Matrix out of an Array of Arrays, should have been in GSL::Matrix already



11
12
13
14
15
16
17
18
19
# File 'lib/glm/util.rb', line 11

def self.aa_to_gsl_matrix(aa)
  n_rows = aa.length
  n_cols = aa[0].length
  gmat = GSL::Matrix.alloc n_rows,n_cols
  (0...n_rows).each {|i|
    (0...n_cols).each {|j|
      gmat.set i, j, aa[i][j]}}
  return gmat
end

.formatArrays(x, y) ⇒ Object



4
5
6
7
8
# File 'lib/glm/util.rb', line 4

def self.formatArrays(x, y)
  x = Matrix.rows(x)
  y = Matrix.column_vector(y)
  return [x, y]
end