} // MatrizInversa() /// <summary> /// calcula a matriz Transposta da matriz que chamou o metodo. /// </summary> /// <returns>retorna a matriz Transposta da matriz que chamou o método.</returns> private Matriz Adjunta() { int lin, col; Matriz Cofatores = new Matriz(this.qtLin, this.qtCol); for (lin = 0; lin < this.qtLin; lin++) { for (col = 0; col < this.qtCol; col++) { Cofatores.matriz[lin, col] = Matriz.determinante(this.ReduzMatriz(lin, col)); if (((lin + col) % 2) == 1) { Cofatores.matriz[lin, col] = -Cofatores.matriz[lin, col]; } } // for col } return(Cofatores); } // Adjunta()
}// operator / /// <summary> /// calcula a matriz inversa da matriz parametro. /// </summary> /// <param name="A">matriz a ter a inversa calculada.</param> /// <returns></returns> public static Matriz MatrizInversa(Matriz A) { if ((A.qtCol == 1) && (A.qtLin == 1)) { Matriz M = new Matriz(1, 1); M.matriz[0, 0] = 1 / A.matriz[0, 0]; return(M); } // if else { Matriz Adjt = A.Adjunta(); Matriz M = new Matriz(A.qtLin, A.qtCol); int lin, col; double D = Matriz.determinante(A); for (lin = 0; lin < A.qtLin; lin++) { for (col = 0; col < A.qtCol; col++) { M.matriz[lin, col] = Adjt.matriz[lin, col] / D; } } return(M.Transposta()); } } // MatrizInversa()