det method

double det()

Implementation

double det() {
  assert(this.isSquare, 'Determinant of nonsquare matrix is undefined');

  if (this.nrows == 1 && this.ncols == 1) return this[0][0];

  double result = 0;
  for (int j = 0; j < ncols; j++) {
    result += (j % 2 == 0 ? 1 : -1) * this[0][j] * this.slice(0, j).det();
  }

  return result;
}