determinant method

double determinant()

Implementation

double determinant() {
  final te = storage;

  double n11 = te[0], n12 = te[4], n13 = te[8], n14 = te[12];
  double n21 = te[1], n22 = te[5], n23 = te[9], n24 = te[13];
  double n31 = te[2], n32 = te[6], n33 = te[10], n34 = te[14];
  double n41 = te[3], n42 = te[7], n43 = te[11], n44 = te[15];

  double v1 = n41 *
      (n14 * n23 * n32 -
          n13 * n24 * n32 -
          n14 * n22 * n33 +
          n12 * n24 * n33 +
          n13 * n22 * n34 -
          n12 * n23 * n34);

  double v2 = n42 *
      (n11 * n23 * n34 -
          n11 * n24 * n33 +
          n14 * n21 * n33 -
          n13 * n21 * n34 +
          n13 * n24 * n31 -
          n14 * n23 * n31);

  double v3 = n43 *
      (n11 * n24 * n32 -
          n11 * n22 * n34 -
          n14 * n21 * n32 +
          n12 * n21 * n34 +
          n14 * n22 * n31 -
          n12 * n24 * n31);

  double v4 = n44 *
      (-n13 * n22 * n31 -
          n11 * n23 * n32 +
          n11 * n22 * n33 +
          n13 * n21 * n32 -
          n12 * n21 * n33 +
          n12 * n23 * n31);

  final result = (v1 + v2 + v3 + v4);
  return result;
}