call method

T call(
  1. int row,
  2. int col
)

Use this method to retrieve the element at a given position in the matrix. For example:

final value = myMatrix(2, 1);

In the above example, you're accessing the value at position (3, 2). This method is an alias of itemAt.

A MatrixException is thrown if row and/or col is not within the size range of the matrix.

Implementation

T call(int row, int col) {
  if ((row >= rowCount) || (col >= columnCount)) {
    throw const MatrixException('The given indices are out of the bounds.');
  }

  // Data are stored sequentially so there's the need to work with the indices
  return _data[columnCount * row + col];
}