Exemplo n.º 1
0
        public MatrixR LUInverse(MatrixR m)
        {
            int     n = m.GetRows();
            MatrixR u = m.Identity();

            LUDecompose(m);
            VectorR uv = new VectorR(n);

            for (int i = 0; i < n; i++)
            {
                uv = u.GetRowVector(i);
                LUSubstitute(m, uv);
                u.ReplaceRow(uv, i);
            }
            MatrixR inv = u.GetTranspose();

            return(inv);
        }
Exemplo n.º 2
0
        public static MatrixR Adjoint(MatrixR m)
        {
            if (!m.IsSquared())
            {
                throw new ArgumentOutOfRangeException(
                          "Dimension", m.GetRows(), "The matrix must be squared!");
            }
            MatrixR ma = new MatrixR(m.GetRows(), m.GetCols());

            for (int i = 0; i < m.GetRows(); i++)
            {
                for (int j = 0; j < m.GetCols(); j++)
                {
                    ma[i, j] = Math.Pow(-1, i + j) * (Determinant(Minor(m, i, j)));
                }
            }
            return(ma.GetTranspose());
        }