Class: Kwyjibo::DenseMatrix
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Attributes inherited from Matrix
Instance Method Summary collapse
- #[](i) ⇒ Object
- #[]=(i, value) ⇒ Object
-
#initialize(rows, cols) ⇒ DenseMatrix
constructor
A new instance of DenseMatrix.
- #tras ⇒ Object
- #x(value) ⇒ Object
Methods inherited from Matrix
Constructor Details
#initialize(rows, cols) ⇒ DenseMatrix
Returns a new instance of DenseMatrix.
126 127 128 129 |
# File 'lib/kwyjibo.rb', line 126 def initialize(rows,cols) @data = Array.new(rows) {Array.new(cols)} super end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
124 125 126 |
# File 'lib/kwyjibo.rb', line 124 def data @data end |
Instance Method Details
#[](i) ⇒ Object
131 132 133 |
# File 'lib/kwyjibo.rb', line 131 def [](i) @data[i] end |
#[]=(i, value) ⇒ Object
135 136 137 |
# File 'lib/kwyjibo.rb', line 135 def []=(i,value) @data[i] = value end |
#tras ⇒ Object
139 140 141 142 143 144 145 146 147 |
# File 'lib/kwyjibo.rb', line 139 def tras() c = DenseMatrix.new(@cols, @rows) c.rows.times do |i| c.cols.times do |j| c[i][j] = self[j][i] end end c end |
#x(value) ⇒ Object
149 150 151 152 153 154 155 |
# File 'lib/kwyjibo.rb', line 149 def x(value) self.rows.times do |i| self.cols.times do |j| self[i][j] *= 2 end end end |