Module: KMeansClusterer::Utils

Defined in:
lib/kmeans-clusterer.rb

Class Method Summary collapse

Class Method Details

.ensure_matrix(x, typecode = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/kmeans-clusterer.rb', line 7

def self.ensure_matrix x, typecode = nil
  if x.is_a?(NMatrix)
    x
  elsif defined?(GSL::Matrix) && x.is_a?(GSL::Matrix)
    x.to_nm
  else
    NMatrix.cast(x, typecode)
  end
end