1、矩阵求逆及相关运算(Inverse matrix and related operations)使用系统;使用 system.collections.generic;使用系统文本;命名空间 bytetest/ / /算法的大致思想是通过行列式初等变换来求。/matrixcomputer 公共类/ / /求逆矩阵/ / / / 公共静态双,逆矩阵(双, dMatrix)/ /获取矩阵的行数智力水平= dMatrix 长度(1) ;/ / / /求矩阵的行列式的值/ /双 dmatrixvalue = matrixvalue(dMatrix) ;/如果(dmatrixvalue = = 0)/ /
2、返回 null;/ 双, dreversematrix =新的双 2 *级水平;/ /初始化矩阵水平(2 级)对于(int = i 0;i I; s-)Temp = dReverseMatrixs, j;For (int t = J; T = 0; i-)For (int j = I + 1; J The corresponding matrix determinant value x/ / / Name= “MatrixList“ / / / Public, static, double, MatrixValue (double, MatrixList)Int Level = MatrixL
3、ist.GetLength (1);Double, dMatrix = new, doubleLevel, Level;For (int i = 0; I i, cut dMatrixm, j! =0) exchangeIf (dMatrixi, j = 0)If (I = = Level - 1)Return 0;Int m = I + 1;Gets a dMatrixm / / j, not for 0 rows(for; dMatrixm, j = 0; m+)If (M = = Level - 1)Return 0;To determine whether the maximum li
4、ne / matrix, if so, it returns 0/ / the I line and the M line changeDouble temp;For (int n = J; n I; s - -)TMP = dmatrix S J;/ / j 行后面的所有行For (int t = J; T / / / / / / /Public static double , matrixmultiplication (double , firstmatrix, double , secondmatrix)Double , resultmatrix = new double firstma
5、trix.getlength (0), secondmatrix.getlength (1);/ / 判断相乘矩阵是否合法, 即第一个矩阵的列要等于第二个矩阵的行If (firstmatrix.getlength (1). Secondmatrix.getlength (0) =Return null;/ / 求结果矩阵For (int rowindex = 0; rowindex firstmatrix.getlength (0); rowindex + +)For (int COLINDEX = 0; COLINDEX secondmatrix.getlength (1); COLINDEX + +)/ / 初始化结果矩阵的元素Resultmatrix rowindex, COLINDEX = 0;For (int i = 0; I firstmatrix.getlength (1); I + +)/ / 求结果矩阵的元素值Resultmatrix rowindex, COLINDEX + = firstmatrix rowindex, I * secondmatrix I, COLINDEX;Return resultmatrix;