Exemple #1
0
        public void Adjoint(Matrix mA)
        {
            Matrix temp = new Matrix(this);         //  Create a working copy.

            double[] vs = new double[9];            //  3x3 matrices for each adjoint minor.

            for (int i = 0; i < 4; i++)             //  row
            {
                for (int j = 0; j < 4; j++)         //  column
                {
                    int n = 0;                      //  sub-matrix insert counter
                    for (int k = 0; k < 4; k++)     //  row
                    {
                        for (int l = 0; l < 4; l++) //  column
                        {
                            if (k != i && l != j)
                            {
                                vs[n++] = temp.mat[k, l];
                            }
                        }
                    }
                    double det = temp.Det(3, vs);
                    if (((i + j) & 1) == 0)
                    {
                        this.mat[j, i] = det;
                    }
                    else
                    {
                        this.mat[j, i] = -det;
                    }
                }
            }
        }