Class: Matrix

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

Direct Known Subclasses

MMatrix

Instance Method Summary collapse

Instance Method Details

#replace_column(j, other) ⇒ Object

Replaces a column in this matrix by copying the entries from another vector.

Parameters:

  • j (Integer)

    the index of the column to replace

  • other (Vector, Array)

    the vector or array whose contents will be copied to the specified column.



58
59
60
61
62
# File 'lib/cicada/mutable_matrix.rb', line 58

def replace_column(j, other)
  row_size.times do |i|
    self[i, j]= other[i]
  end
end

#replace_row(i, other) ⇒ Object

Replaces a row in this matrix by copying the entries from another vector.

Parameters:

  • i (Integer)

    the index of the row to replace

  • other (Vector, Array)

    the vector or array whose contents will be copied to the specified row.



45
46
47
48
49
# File 'lib/cicada/mutable_matrix.rb', line 45

def replace_row(i, other)
  column_size.times do |j|
    self[i, j]= other[j]
  end
end