Class: Matrix
Instance Method Summary collapse
Instance Method Details
#inspect(format = '%.4f') ⇒ Object
8 9 10 11 |
# File 'lib/lib/helper/lib/matrix.rb', line 8 def inspect format = '%.4f' return "Matrix[]" if empty? (["\nMatrix[ "] + [" "]*(row_size-1)).zip(to_s.lines).map{|v| v.join}.join() + " ]" end |
#to_s(format = '%.4f') ⇒ Object
3 4 5 6 7 |
# File 'lib/lib/helper/lib/matrix.rb', line 3 def to_s format='%.4f' return "" if empty? f = column_vectors.map(&->x{"%#{x.longest_string(format)}s"}).join(" ") map{|v| format % v}.row_vectors.map{|v| f % v.to_a}.join("\n") end |