Class: SparseMatrix::SparseVector

Inherits:
Object
  • Object
show all
Defined in:
lib/sparse_matrix.rb

Overview

clase para guardar vector de tuplas

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(i = 0, j = 0, v = 0) ⇒ SparseVector

Returns a new instance of SparseVector.



54
55
56
57
58
# File 'lib/sparse_matrix.rb', line 54

def initialize(i=0,j=0,v=0)
    @i = i
    @j = j
    @value = v
end

Instance Attribute Details

#iObject

Returns the value of attribute i.



59
60
61
# File 'lib/sparse_matrix.rb', line 59

def i
  @i
end

#jObject

Returns the value of attribute j.



59
60
61
# File 'lib/sparse_matrix.rb', line 59

def j
  @j
end

#valueObject

Returns the value of attribute value.



59
60
61
# File 'lib/sparse_matrix.rb', line 59

def value
  @value
end

Instance Method Details

#to_sObject



61
62
63
# File 'lib/sparse_matrix.rb', line 61

def to_s
    "#{@i},#{@j},#{@value}"
end