In Files

  • matrix.rb

Parent

Object

Public Instance Methods

[](i, j) click to toggle source

Returns element (i,j) of the matrix. That is: row i, column j.

 
               # File matrix.rb, line 325
def [](i, j)
  @rows.fetch(i){return nil}[j]
end
            
Also aliased as: element, component
matrix[range, range] = matrix/element click to toggle source
matrix[range, integer] = vector/column_matrix/element
matrix[integer, range] = vector/row_matrix/element
matrix[integer, integer] = element

Set element or elements of matrix.

 
               # File matrix.rb, line 339
def []=(i, j, v)
  raise FrozenError, "can't modify frozen Matrix" if frozen?
  rows = check_range(i, :row) or row = check_int(i, :row)
  columns = check_range(j, :column) or column = check_int(j, :column)
  if rows && columns
    set_row_and_col_range(rows, columns, v)
  elsif rows
    set_row_range(rows, column, v)
  elsif columns
    set_col_range(row, columns, v)
  else
    set_value(row, column, v)
  end
end
            
Also aliased as: set_element, set_component
component(i, j) click to toggle source
Alias for: []
element(i, j) click to toggle source
Alias for: []
set_component(i, j, v) click to toggle source
Alias for: []=
set_element(i, j, v) click to toggle source
Alias for: []=