资源描述:
《矩阵论20111021》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、3.求矩阵的杜利特分解与克劳特分解解:杜利特分解程序如下function[L,U]=LU_Doolittle(A)[r,c]=size(A);L=eye(r,c);U=zeros(r,c);forj=1:cfori=1:jU(i,j)=A(i,j);fork=1:i-1U(i,j)=U(i,j)-L(i,k)*U(k,j);endendfori=j+1:rL(i,j)=A(i,j);fork=1:j-1L(i,j)=L(i,j)-L(i,k)*U(k,j);endL(i,j)=L(i,j)/U(j,j);endend测试数据:A=52-4021-21-4-2500102测试结果:
2、>>[L,U]=LU_Doolittle(A)L=1.00000000.40001.000000-0.8000-2.00001.0000005.00002.00001.0000U=5.00002.0000-4.0000000.2000-0.40001.0000001.00002.0000000-7.0000克劳特分解程序如下:function[L,U]=LU_Crout(A)[r,c]=size(A);L=zeros(r,c);U=eye(r,c);fori=1:rforj=1:iL(i,j)=A(i,j);fork=1:j-1L(i,j)=L(i,j)-L(i,k)*U(k,j
3、);endendforj=i+1:cU(i,j)=A(i,j);fork=1:i-1U(i,j)=U(i,j)-L(i,k)*U(k,j);endU(i,j)=U(i,j)/L(i,i);endend测试数据:A=52-4021-21-4-2500102测试结果:>>[L,U]=LU_Crout(A)L=5.00000002.00000.200000-4.0000-0.40001.0000001.00002.0000-7.0000U=1.00000.4000-0.8000001.0000-2.00005.0000001.00002.00000001.00004.求对称正定矩阵的不
4、带平方根的乔累斯基分解解:不带平方根乔累斯基分解程序如下function[L,D]=LD_Cholesky_noSqrt(A)[r,c]=size(A);L=zeros(r,c);D=zeros(r,c);fori=1:rforj=1:iL(i,j)=A(i,j);fork=1:j-1L(i,j)=L(i,j)-L(i,k)*L(j,k)/L(k,k);endendendfori=1:rD(i,i)=1/L(i,i);end测试数据:A=52-421-2-4-25测试结果:>>[L,D]=LD_Cholesky_noSqrt(A)L=5.0000002.00000.20000-4
5、.0000-0.40001.0000D=0.20000005.00000001.00005.对下列矩阵进行LDU分解(1)(2)其中L为单位下三角矩阵,D为对角矩阵,U为单位上三角矩阵解:LDU分解程序如下:function[L,D,U]=LDU(A)[r,c]=size(A);[L,U]=LU_Doolittle(A);D=zeros(r,c);fori=1:rD(i,i)=U(i,i);U(i,i)=1;if(D(i,i)~=0)forj=i+1:cU(i,j)=U(i,j)/D(i,i);endendend测试数据1:A=1020010020-110011测试结果1:>>[
6、L,D,U]=LDU(A)L=1.000000001.0000002.000001.0000000-0.20001.0000D=1.000000001.00000000-5.000000001.2000U=1.000002.0000001.000000001.0000-0.20000001.0000测试数据2:A=123-12-19-7-34-3194-16-21测试结果2:>>[L,D,U]=LDU(A)L=1.00000002.00001.000000-3.0000-2.00001.000004.00001.8000-0.95001.0000D=1.00000000-5.00
7、00000012.00000000-2.3000U=1.00002.00003.0000-1.000001.0000-0.60001.0000001.00000.50000001.000011.用豪斯霍尔德变换求矩阵的QR分解解:豪斯霍尔德变换程序如下:function[Q,R]=QR_Householder(A)[r,c]=size(A);R=A;Q=eye(r);forj=1:c-1w=R(j:r,j);w(1,1)=w(1,1)-norm(w);w=w/norm(w);H=