public static double Determinant0(double[,] matrix)
        {
            switch (matrix?.GetLength(0))
            {
            case null: return(0);

            case 1:
            {
                return(matrix[0, 0]);
            }

            case 2:
            {
                return(MatrixDeterminant2x2Tests.Determinant(
                           matrix[0, 0], matrix[0, 1],
                           matrix[1, 0], matrix[1, 1]));
            }

            case 3:
            {
                return(MatrixDeterminant3x3Tests.Determinant(
                           matrix[0, 0], matrix[0, 1], matrix[0, 2],
                           matrix[1, 0], matrix[1, 1], matrix[1, 2],
                           matrix[2, 0], matrix[2, 1], matrix[2, 2]));
            }

            case 4:
            {
                return(MatrixDeterminant4x4Tests.Determinant(
                           matrix[0, 0], matrix[0, 1], matrix[0, 2], matrix[0, 3],
                           matrix[1, 0], matrix[1, 1], matrix[1, 2], matrix[1, 3],
                           matrix[2, 0], matrix[2, 1], matrix[2, 2], matrix[2, 3],
                           matrix[3, 0], matrix[3, 1], matrix[3, 2], matrix[3, 3]));
            }

            case 5:
            {
                return(MatrixDeterminant5x5Tests.Determinant(
                           matrix[0, 0], matrix[0, 1], matrix[0, 2], matrix[0, 3], matrix[0, 4],
                           matrix[1, 0], matrix[1, 1], matrix[1, 2], matrix[1, 3], matrix[1, 4],
                           matrix[2, 0], matrix[2, 1], matrix[2, 2], matrix[2, 3], matrix[2, 4],
                           matrix[3, 0], matrix[3, 1], matrix[3, 2], matrix[3, 3], matrix[3, 4],
                           matrix[4, 0], matrix[4, 1], matrix[4, 2], matrix[4, 3], matrix[4, 4]));
            }

            case 6:
            {
                return(MatrixDeterminant6x6Tests.Determinant(
                           matrix[0, 0], matrix[0, 1], matrix[0, 2], matrix[0, 3], matrix[0, 4], matrix[0, 5],
                           matrix[1, 0], matrix[1, 1], matrix[1, 2], matrix[1, 3], matrix[1, 4], matrix[1, 5],
                           matrix[2, 0], matrix[2, 1], matrix[2, 2], matrix[2, 3], matrix[2, 4], matrix[2, 5],
                           matrix[3, 0], matrix[3, 1], matrix[3, 2], matrix[3, 3], matrix[3, 4], matrix[3, 5],
                           matrix[4, 0], matrix[4, 1], matrix[4, 2], matrix[4, 3], matrix[4, 4], matrix[4, 5],
                           matrix[5, 0], matrix[5, 1], matrix[5, 2], matrix[5, 3], matrix[5, 4], matrix[5, 5]));
            }

            default:
                return(Determinant(matrix));
            }
        }
 public static double InverseDeterminant0(
     double a, double b, double c, double d, double e,
     double f, double g, double h, double i, double j,
     double k, double l, double m, double n, double o,
     double p, double q, double r, double s, double t,
     double u, double v, double w, double x, double y)
 {
     return(1d / ((a * MatrixDeterminant4x4Tests.Determinant(g, h, i, j, l, m, n, o, q, r, s, t, v, w, x, y))
                  - (b * MatrixDeterminant4x4Tests.Determinant(f, h, i, j, k, m, n, o, p, r, s, t, u, w, x, y))
                  + (c * MatrixDeterminant4x4Tests.Determinant(f, g, i, j, k, l, n, o, p, q, s, t, u, v, x, y))
                  - (d * MatrixDeterminant4x4Tests.Determinant(f, g, h, j, k, l, m, o, p, q, r, t, u, v, w, y))
                  + (e * MatrixDeterminant4x4Tests.Determinant(f, g, h, i, k, l, m, n, p, q, r, s, u, v, w, x))));
 }
Пример #3
0
 public static double Determinant0(
     double m1x1, double m1x2, double m1x3, double m1x4, double m1x5,
     double m2x1, double m2x2, double m2x3, double m2x4, double m2x5,
     double m3x1, double m3x2, double m3x3, double m3x4, double m3x5,
     double m4x1, double m4x2, double m4x3, double m4x4, double m4x5,
     double m5x1, double m5x2, double m5x3, double m5x4, double m5x5)
 {
     return((m1x1 * MatrixDeterminant4x4Tests.Determinant(m2x2, m2x3, m2x4, m2x5, m3x2, m3x3, m3x4, m3x5, m4x2, m4x3, m4x4, m4x5, m5x2, m5x3, m5x4, m5x5))
            - (m1x2 * MatrixDeterminant4x4Tests.Determinant(m2x1, m2x3, m2x4, m2x5, m3x1, m3x3, m3x4, m3x5, m4x1, m4x3, m4x4, m4x5, m5x1, m5x3, m5x4, m5x5))
            + (m1x3 * MatrixDeterminant4x4Tests.Determinant(m2x1, m2x2, m2x4, m2x5, m3x1, m3x2, m3x4, m3x5, m4x1, m4x2, m4x4, m4x5, m5x1, m5x2, m5x4, m5x5))
            - (m1x4 * MatrixDeterminant4x4Tests.Determinant(m2x1, m2x2, m2x3, m2x5, m3x1, m3x2, m3x3, m3x5, m4x1, m4x2, m4x3, m4x5, m5x1, m5x2, m5x3, m5x5))
            + (m1x5 * MatrixDeterminant4x4Tests.Determinant(m2x1, m2x2, m2x3, m2x4, m3x1, m3x2, m3x3, m3x4, m4x1, m4x2, m4x3, m4x4, m5x1, m5x2, m5x3, m5x4)));
 }