矩阵运算的程序实现以C描述Word格式文档下载.docx
- 文档编号:16944173
- 上传时间:2022-11-27
- 格式:DOCX
- 页数:7
- 大小:14.91KB
矩阵运算的程序实现以C描述Word格式文档下载.docx
《矩阵运算的程序实现以C描述Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《矩阵运算的程序实现以C描述Word格式文档下载.docx(7页珍藏版)》请在冰豆网上搜索。
if(lNum&
gt;
m-1||lNum&
lt;
0||hNum&
m-1||hNum&
0)
MessageBox.Show(&
quot;
不存在该列或行&
);
}
if(lNum==m-1&
amp;
&
hNum==m-1)//如果去掉的行列都为最后一行一列
for(inti=0;
i&
m-1;
i++)
for(intj=0;
j&
j++)
newMatr[i,j]=matr[i,j];
}
hNum&
m-1&
hNum&
=0)//去掉最后一列,中间一行
j&
for(inti=0;
i&
hNum;
i++)
for(inti=hNum;
m-1;
newMatr[i,j]=matr[i+1,j];
if(hNum==m-1&
lNum&
=0)//去掉最后一行,中间一列
for(intj=0;
j&
lNum;
j++)
newMatr[i,j]=matr[i,j];
for(intj=lNum;
newMatr[i,j]=matr[i,j+1];
=0&
=0)//去掉中间行列
for(intj2=lNum;
j2&
j2++)
newMatr[i,j2]=matr[i,j2+1];
//////////
m-1;
j2++)
newMatr[i,j2]=matr[i+1,j2+1];
returnnewMatr;
//求行列式
publicdoublevalueHls(double[,]matr)
doublevalue=0;
//用于存储最后计算值
doublee=-1;
//-1的次数
if(matr.Length==1)
value=matr[0,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*matr[0,j]*valueHls(B);
//}
returnvalue;
//矩阵求逆
publicdouble[,]matrInver(double[,]matr)
intm=(int)Math.Sqrt(matr.Length);
double[,]newMatr=newdouble[m,m];
doubleAValue=0;
AValue=1/valueHls(matr);
m;
i++)
e*=-1;
newMatr[i,j]=e*AValue*valueHls(minus(j,i,matr));
//矩阵相乘
publicdouble[,]matrMult(doublea,double[,]matr)
double[,]newMatr=newdouble[matr.GetLength(0),matr.GetLength
(1)];
matr.GetLength(0);
matr.GetLength
(1);
newMatr[i,j]=matr[i,j]*a;
//矩阵相乘2
publicdouble[,]matrMult(double[,]matr1,double[,]matr2)
if(matr1.GetLength
(1)==matr2.GetLength(0))
double[,]newMatr=newdouble[matr1.GetLength(0),matr2.GetLength
(1)];
for(inti=0;
matr1.GetLength(0);
matr2.GetLength
(1);
for(intk=0;
k&
matr2.GetLength(0);
k++)
newMatr[i,j]+=matr1[i,k]*matr2[k,j];
else{
两个行列式不能相乘&
returnnull;
//矩阵相加
publicdouble[,]matrAdd(double[,]matr1,double[,]matr2)
if(matr1.GetLength(0)==matr2.GetLength(0)&
matr1.GetLength
(1)==matr2.GetLength
(1))
double[,]newMatr=new
double[matr1.GetLength(0),matr1.GetLength
(1)];
matr1.GetLength(0);
matr1.GetLength
(1);
newMatr[i,j]=matr1[i,j]+matr2[i,j];
else
两个行列式不能相加&
//矩阵转置
publicdouble[,]matrTrans(double[,]matr)
double[,]newMatr=newdouble[matr.GetLength
(1),matr.GetLength(0)];
newMatr[i,j]=matr[j,i];
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 矩阵 运算 程序 实现 描述
![提示](https://static.bdocx.com/images/bang_tan.gif)