/// <summary> /// 求逆 /// </summary> /// <param name="Mat"></param> /// <returns></returns> public Matrix Inverses(Matrix Mat) { int n = Mat.RowCount; Matrix LU = new Matrix(n, n), Inverse = new Matrix(n, n); Vector b = new Vector(n), Indx = new Vector(n); if (Mat.ColCount != Mat.RowCount) { throw new ArgumentException("维数不符合要求!"); } // LU decomposition LU = Mat; MatrixUtilNew.LU_Decomp(LU, Indx); // Solve Ax=b for unit vectors b_1..b_n for (int j = 0; j < n; j++) { b[j] = 1.0; // Set b to j-th unit vector MatrixUtilNew.LU_BackSub(LU, Indx, b); // Solve Ax=b Inverse.SetCol(j, b); // Copy result } ; return(Inverse); }
/// <summary> /// Transposition /// </summary> /// <returns></returns> public Matrix Transpose() { return(MatrixUtilNew.Transpose(this)); }