Sha256: 55ebac7a3d9096f893b8b72c8d400b46dec0b93aed49528b00e5893c72dd447d
Contents?: true
Size: 553 Bytes
Versions: 5
Compression:
Stored size: 553 Bytes
Contents
require "rubygems" require "facets" require "narray" module NMatrixExtensions def pretty_string(opts={}) { :col_header => nil, :row_header => nil }.merge!(opts) ("%-3s" % "#") + opts[:col_header].inject("") { |s, a| s + ("%7s" % a) } + "\n" + self.to_a.map_with_index { |a, i| ("%-3s" % opts[:row_header][i]) + a.inject("") { |s, v| if v.is_a? Float s + ("%7.2f" % v) else s + ("%7d" % v) end } }.join("\n") end end NMatrix.send(:include, NMatrixExtensions)
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
egor-0.0.1 | lib/nmatrix_extensions.rb |
egor-0.0.2 | lib/nmatrix_extensions.rb |
egor-0.0.4 | lib/nmatrix_extensions.rb |
egor-0.0.3 | lib/nmatrix_extensions.rb |
egor-0.0.5 | lib/nmatrix_extensions.rb |