Module: Eigen::SpMatrixCommon

Included in:
SpMatrixDouble
Defined in:
lib/eigen.rb

Instance Method Summary collapse

Instance Method Details

#reserve(arg) ⇒ Object

Raises:

  • (Eigen::EigenRuntimeError)


197
198
199
200
201
202
203
# File 'lib/eigen.rb', line 197

def reserve( arg )
  if arg.respond_to?(:to_int)
    return __reserve__( arg )
  end
  raise Eigen::EigenRuntimeError unless arg.size == cols()
  __reserve__( arg )
end

#setFromTriplet(arry) ⇒ Object



182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/eigen.rb', line 182

def setFromTriplet(arry)
  arry0 = arry.sort{|a, b|
    ret = a[1] <=> b[1]
    ret == 0 ? a[0] <=> b[0] : ret
  }
  each_col_size = Array.new(cols(), 0)
  arry0.slice_when{|a, b| a[1] != b[1] }.each{|e|
    each_col_size[ e[0][1] ] = e.size
  }
  reserve( each_col_size )
  arry0.each{|e|
    __insert__(e[0], e[1], e[2])
  }
end