matrixEquals static method

bool matrixEquals(
  1. Matrix a,
  2. Matrix b
)

Custom comparison method for matrices

Implementation

static bool matrixEquals(Matrix a, Matrix b) {
  // Check if dimensions are the same
  if (a.rows != b.rows || a.cols != b.cols) {
    return false;
  }

  // Compare each cell
  for (int y = 0; y < a.rows; y++) {
    for (int x = 0; x < a.cols; x++) {
      if (a._data[y][x] != b._data[y][x]) {
        return false;
      }
    }
  }

  // If we've made it this far, the matrices are equal
  return true;
}