getDeterminent method

double getDeterminent()

Implementation

double getDeterminent() {
  assert(shape.item1 == shape.item2);

  if (shape.item1 == 2) {
    var a = values[0][0];
    var b = values[0][1];
    var c = values[1][0];
    var d = values[1][1];

    return a * d - b * c;
  }

  var subshape = Tuple2(shape.item1 - 1, shape.item2 - 1);

  return sum([
    for (var i in range(end: shape.item1))
      (i % 2 == 0 ? 1 : -1) *
          (Array.fromValue(values[0][i], shape: subshape) * _subMatrix(0, i))
              .getDeterminent()
  ]);
}