isVandermondeMatrix method

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

Checks if the matrix is a Vandermonde matrix.

A Vandermonde matrix has the terms of a geometric progression in each row, often used in polynomial interpolation problems.

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 isVandermondeMatrix({num tolerance = 1e-10}) {
  for (int i = 0; i < rowCount - 1; i++) {
    dynamic ratio = _data[i + 1][0] / _data[i][0];
    for (int j = 1; j < columnCount; j++) {
      dynamic currentRatio = _data[i + 1][j] / _data[i][j];
      if ((currentRatio - ratio).abs() > Complex(tolerance)) {
        return false;
      }
    }
  }
  return true;
}