Sha256: 646024504d646aa13c00e1f68fc95b5abd2197a1158d56fc8c550214cbdc6505
Contents?: true
Size: 555 Bytes
Versions: 1
Compression:
Stored size: 555 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubst-0.0.1 | lib/nmatrix_extensions.rb |