mdiam
8/5/2008 11:46:00 AM
Redirect to fortan just because you need some float usage
is a bad idea : it's a true argument to make switching
to piton...
But yes, if you have to manipulate matrix with billion
of elements, then you should do some fortan (... ruby binding) !
Some month ago I also had such a need.
As mentioned above, I had to reopen the Matrix class and
add several methods:
class Matrix
def dump(firstLine = "")
str = ""
if firstLine != ""
str << firstLine << "\n"
end
for i in 0...self.row_size
space = ""
for j in 0...self.column_size
str << space << self[i,j].to_s
space = " "
end
str << "\n"
end
return str
end
# La classe Matrix est immutable, or je veux pouvoir écrire :
# m[i,j] = v
#
def []=(i, j, v)
@rows[i][j] = v
end
# Il n'y a même pas de constructeur pour une matrice
rectangulaire : bouhhh
# Le prefixe "self." permet de déclarer une méthode de classe
def self.create(nbRows, nbCols, value)
return Matrix.rows(Array.new(nbRows, Array.new(nbCols,
value)))
end
end