Class: Kwyjibo::SparseMatrix
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Attributes inherited from Matrix
Instance Method Summary collapse
- #[](i) ⇒ Object
-
#initialize(rows, cols, h = {}) ⇒ SparseMatrix
constructor
A new instance of SparseMatrix.
Methods inherited from Matrix
Constructor Details
#initialize(rows, cols, h = {}) ⇒ SparseMatrix
174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/kwyjibo.rb', line 174 def initialize(rows,cols, h = {}) @data = Hash.new({}) for k in h.keys do if h[k].is_a? SparseVector @data[k] = h[k] else @data[k] = SparseVector.new(h[k]) end end super(rows,cols) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
172 173 174 |
# File 'lib/kwyjibo.rb', line 172 def data @data end |
Instance Method Details
#[](i) ⇒ Object
186 187 188 |
# File 'lib/kwyjibo.rb', line 186 def [](i) @data[i] end |