isSymmetricMatrix method

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

Checks if the matrix is a symmetric matrix.

Example:

Matrix E = Matrix([
  [1, 2, 3],
  [2, 3, 4],
  [3, 4, 5]
]);
print(E.isSymmetricMatrix()); // Output: true

Implementation

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