isHankelMatrix method

bool isHankelMatrix({
  1. num tolerance = 1e-10,
})

Checks if the matrix is a Hankel matrix.

A Hankel matrix is a matrix in which each ascending diagonal from left to right is constant.

tolerance is the numerical tolerance used to compare the elements. Default value for tolerance is 1e-10.

Returns true if the matrix is tridiagonal, false otherwise.

Implementation

bool isHankelMatrix({num tolerance = 1e-10}) {
  for (int i = 0; i < rowCount - 1; i++) {
    for (int j = 0; j < columnCount - 1; j++) {
      if ((_data[i + 1][j] - _data[i][j + 1]).abs() > tolerance) {
        return false;
      }
    }
  }
  return true;
}