Class: MatrixIndex

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

Overview

An index of a binary matrix Copyright GPL 3 – Joseph J. Simpson – 2014 11-22-2014

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(size) ⇒ MatrixIndex

Returns a new instance of MatrixIndex.



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

def initialize(size)
  @mi = Array.new(size) { |i| Array.new(1, i + 1) }
end

Instance Attribute Details

#miObject

Returns the value of attribute mi.



6
7
8
# File 'lib/matrix_index.rb', line 6

def mi
  @mi
end

Instance Method Details

#compress_index(index_1, index_2) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/matrix_index.rb', line 11

def compress_index(index_1, index_2)
  temp_mi = mi.dup
  i1 = temp_mi.index([index_1])
  i2 = temp_mi.index([index_2])
  temp_mi[i1].push(temp_mi[i2])
  temp_mi.delete_at(i2)
  mi = temp_mi
  mi
end