Class: Matrix

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

Instance Method Summary collapse

Constructor Details

#initializeMatrix

Returns a new instance of Matrix.



2
3
4
5
# File 'lib/generic/matrix.rb', line 2

def initialize()
  @mat = []
  @n = 0
end

Instance Method Details

#get(at) ⇒ Object



22
23
24
25
26
# File 'lib/generic/matrix.rb', line 22

def get(at)
  i = at[0]
  j = at[1]
  @mat[i][j]
end

#m_sizeObject



11
12
13
# File 'lib/generic/matrix.rb', line 11

def m_size
  @mat.size
end

#n_sizeObject



7
8
9
# File 'lib/generic/matrix.rb', line 7

def n_size
  @n
end

#set(at, value) ⇒ Object



15
16
17
18
19
20
# File 'lib/generic/matrix.rb', line 15

def set(at, value)
  expand(at)
  i = at[0]
  j = at[1]
  @mat[i][j] = value
end

#to_sObject



28
29
30
31
32
33
# File 'lib/generic/matrix.rb', line 28

def to_s
  p @mat
#    print "["
#    print @mat.join(",\n")
#    print "]\n"
end