Guest User

Untitled

a guest
Jul 18th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #
  2. # NamedMatrix.rb
  3. # @project: Pharmaduke
  4. # @author: Nicholas P. Tatonetti
  5. # @created: 11/24/2009
  6. #
  7.  
  8. require 'rnum'
  9. include RNum
  10.  
  11. # Include the Enumerable mixin
  12. class Matrix
  13. include Enumerable
  14.  
  15. def rowmax
  16. # Define a column vector
  17. v = RNum::zeros(self.row_size,1)
  18. 0.upto(self.row_size-1) do |i|
  19. v[i,0] = self[i,0..(self.column_size-1)].max
  20. end
  21. return v
  22. end
  23. end
  24.  
  25. class NamedMatrix < Matrix
  26. attr_accessor :colnames, :rownames
  27.  
  28. def initialize(rownames, colnames, matrix = nil)
  29. if matrix == nil
  30. super(RNum::zeros(rownames.length, colnames.length))
  31. else
  32. super(matrix)
  33. end
  34. @colnames = colnames
  35. @rownames = rownames
  36. end
  37. end
Add Comment
Please, Sign In to add comment