Class: Matrc::MatrizDensa

Inherits:
Matriz
  • Object
show all
Defined in:
lib/matrc/matriz_densa.rb

Instance Attribute Summary

Attributes inherited from Matriz

#col, #row

Instance Method Summary collapse

Methods inherited from Matriz

#*, #+, #-, #==, #each, #max, #min, #to_s

Constructor Details

#initialize(row, col) ⇒ MatrizDensa

Returns a new instance of MatrizDensa.



7
8
9
10
# File 'lib/matrc/matriz_densa.rb', line 7

def initialize(row,col)
  super(row,col)
  @mtdensa = Array.new(row){Array.new(col, zero)}
end

Instance Method Details

#[](row, col = nil) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/matrc/matriz_densa.rb', line 12

def [](row,col=nil)
    if (col.nil?)
      @mtdensa[row]
    else
   @mtdensa[row][col]
	end
end

#[]=(row, col = nil, val) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/matrc/matriz_densa.rb', line 20

def []=(row,col=nil,val)
  if (col.nil?)
      @mtdensa[row]=val
    else
   @mtdensa[row][col]=val
	end
end