Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # NamedMatrix.rb
- # @project: Pharmaduke
- # @author: Nicholas P. Tatonetti
- # @created: 11/24/2009
- #
- require 'rnum'
- include RNum
- # Include the Enumerable mixin
- class Matrix
- include Enumerable
- def rowmax
- # Define a column vector
- v = RNum::zeros(self.row_size,1)
- 0.upto(self.row_size-1) do |i|
- v[i,0] = self[i,0..(self.column_size-1)].max
- end
- return v
- end
- end
- class NamedMatrix < Matrix
- attr_accessor :colnames, :rownames
- def initialize(rownames, colnames, matrix = nil)
- if matrix == nil
- super(RNum::zeros(rownames.length, colnames.length))
- else
- super(matrix)
- end
- @colnames = colnames
- @rownames = rownames
- end
- end
Add Comment
Please, Sign In to add comment