Class: SparseVector
- Inherits:
-
Object
- Object
- SparseVector
- Defined in:
- lib/matriz_dispersa.rb
Instance Attribute Summary collapse
-
#vector ⇒ Object
readonly
Returns the value of attribute vector.
Instance Method Summary collapse
- #[](i) ⇒ Object
-
#initialize(h = {}) ⇒ SparseVector
constructor
A new instance of SparseVector.
- #to_s ⇒ Object
Constructor Details
#initialize(h = {}) ⇒ SparseVector
Returns a new instance of SparseVector.
8 9 10 11 |
# File 'lib/matriz_dispersa.rb', line 8 def initialize(h = {}) @vector = Hash.new(0) @vector = @vector.merge!(h) end |
Instance Attribute Details
#vector ⇒ Object (readonly)
Returns the value of attribute vector.
6 7 8 |
# File 'lib/matriz_dispersa.rb', line 6 def vector @vector end |
Instance Method Details
#[](i) ⇒ Object
13 14 15 |
# File 'lib/matriz_dispersa.rb', line 13 def [](i) @vector[i] end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/matriz_dispersa.rb', line 17 def to_s @vector.to_s end |