《C常用矩阵子函数.pdf》由会员分享,可在线阅读,更多相关《C常用矩阵子函数.pdf(4页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、doublescalar(double MAR1C1,double k)int i,j,R1,C1;double k,MA2;for(i=0;iR1;i+)doubleAdd(double MA1R1C1,double MA2R2C2)inti,j;double MA33;for(i=0;iR1;i+)double Sub(double MA1R1C1,double MA2R2C2)inti,j;double MA33;for(j=0;jC1;j+)MAij=MA1ij+MA2ij;return MA33;return MA2;for(j=0;jC1;j+)MA2ij=k*MAij;for(i
2、=0;iR1;i+)double Mul(double MA1R1C1,double MA2R2C2)inti,j,k;double MA33;for(i=0;iR1;i+)double Tra(double MA1R1C1)inti,j;double MAR1C1;for(i=0;iR1;i+)for(j=0;jC1;j+)return MA33;for(k=0;kC1;k+)MAij+=MA1ik*MA2kj;for(j=0;jC1;j+)MAij=MA1ij-MA2ij;return MA33;for(j=0;jC1;j+)MAji=MA1ij;return MAR1C1;double
3、Inv(aMM)double aM2*M;double bN2*N;floatt,x;inti,j,k,T=M;for(i=0;iT;i+)for(j=0;j(2*T);j+)if(jT)aij=bij;else if(j=T+i)elsefor(i=0;iT;i+)for(k=0;kT;k+)if(k!=i)t=aki/aii;aij=0.0;aij=1.0;for(i=0;iT;i+)return bij;for(j=0;j(2*T);j+)x=aij*t;akj=akj-x;for(i=0;iT;i+)t=aii;for(j=0;j(2*T);j+)aij=aij/t;y=y*aii;if(y=0)printf(Errorn);elsefor(i=0;iT;i+)for(j=0;jT;j+)bij=aij+T;