isBidiagonalMatrix method

bool isBidiagonalMatrix({
  1. double tolerance = 1e-12,
})

Checks if the matrix is a Bidiagonal matrix.

A matrix is bidiagonal if all its elements are zero except for the elements on its main diagonal and the first superdiagonal (the diagonal just above the main diagonal).

Implementation

bool isBidiagonalMatrix({double tolerance = 1e-12}) {
  for (int i = 0; i < rowCount; i++) {
    for (int j = 0; j < columnCount; j++) {
      if (i != j && i != j - 1) {
        if (_data[i][j].abs() > tolerance) {
          return false;
        }
      }
    }
  }
  return true;
}