1、if (lNum > m - 1 | lNum < 0 | hNum & m - 1 | hNum & 0)MessageBox.Show("不存在该列或行&);if (lNum = m - 1 && hNum = m - 1)/如果去掉的行列都为最后一行一列for (int i=0;i&m-1;i+)for (int j=0;j &j+)newMatri, j = matri , j; hNum & m - 1 & hNum&=0)/去掉最后一列,中间一行j&for (int i = 0; i & hNum; i+)for (int i = hNum; m -
2、1;newMatri, j = matri + 1, j;if (hNum = m - 1 & lNum &= 0)/去掉最后一行,中间一列for (int j = 0; j & lNum; j+)newMatri, j = matri, j;for (int j = lNum;newMatri, j = matri, j+1;= 0 &= 0)/去掉中间行列for (int j2 = lNum; j2 &j2+ )newMatri, j2 = matri , j2+1;/ m-1; j2+)newMatri, j2 = matri + 1, j2 + 1;return newMatr; /求
3、行列式public double valueHls(double, matr) double value=0;/用于存储最后计算值double e = -1;/-1的次数if (matr.Length = 1)value = matr0, 0;/ if(matr.Length&1)/if 不套for/ Math.Sqrt(matr.Length) & matr.Length & 1;e = e * (-1);double, B = minus(0,j, matr);value += e * matr0, j * valueHls(B);/ return value;/矩阵求逆public do
4、uble, matrInver(double, matr)int m = (int)Math.Sqrt(matr.Length);double, newMatr = new doublem , m;double AValue=0;AValue = 1 / valueHls(matr); m;i + )e *= -1;newMatri, j = e * AValue*valueHls(minus(j, i, matr);/矩阵相乘public double, matrMult(double a, double, matr)double, newMatr = new doublematr.GetL
5、ength(0), matr.GetLength(1); matr.GetLength(0); matr.GetLength(1);newMatri, j = matri, j*a;/矩阵相乘2public double, matrMult(double, matr1, double, matr2)if (matr1.GetLength(1) = matr2.GetLength(0)double, newMatr = new doublematr1.GetLength(0), matr2.GetLength(1);for(int i=0;matr1.GetLength(0); matr2.Ge
6、tLength(1);for (int k = 0; k & matr2.GetLength(0); k+)newMatri, j += matr1i, k * matr2k, j;else 两个行列式不能相乘&return null;/矩阵相加public double, matrAdd(double, matr1, double, matr2)if (matr1.GetLength(0) = matr2.GetLength(0) & matr1.GetLength(1) = matr2.GetLength(1)double, newMatr = new doublematr1.GetLength(0), matr1.GetLength(1); matr1.GetLength(0); matr1.GetLength(1);newMatri, j = matr1i, j + matr2i, j;else两个行列式不能相加&/矩阵转置public double, matrTrans(double, matr) double, newMatr = new doublematr.GetLength(1), matr.GetLength(0);newMatri, j = matrj, i ;
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1