Class: DistMatrix

Inherits:
Object
  • Object
show all
Defined in:
ext/lib/CompLearnLib/DistMatrix.rb

Class Method Summary collapse

Class Method Details

.convertToString(distmatrix) ⇒ Object



10
11
12
13
14
15
16
# File 'ext/lib/CompLearnLib/DistMatrix.rb', line 10

def DistMatrix.convertToString(distmatrix)
  result = ''
  distmatrix.each { |row|
    result << row.join(' ') + "\n"
  }
  result
end

.readFromFile(f) ⇒ Object



3
4
5
6
7
8
# File 'ext/lib/CompLearnLib/DistMatrix.rb', line 3

def DistMatrix.readFromFile(f)
  f = File.open(f, 'r') if f.is_a?(String)
  result = f.readlines
  result.delete_if { |line| line =~ /^#/ || line !~ /\S+/ }
  result.collect { |line| line.split(' ').collect { |i| i.to_f } }
end