function [R,lam2,x2]=decorder(A,lambda,V) % 利用相似变换对矩阵A进行降阶,从而可用幂法求次大特征值和特征向量 % NUMERICAL METHODS: Matlab Programs % (c) 2007 by Xie Liling % Complementary Software to accompany the textbook: % Information and Computing Science: A Laboratory Course [n,n]=size(A); % 选主元 [m,p]=max(abs(V)); % 构造排列阵Ip Ip=eye(n); Ip(1,1)=0; Ip(1,p)=1; Ip(p,1)=1; Ip(p,p)=0; Y=Ip*V; L=eye(n); for i=2:n L(i,1)=-Y(i)/Y(1); end S=L*Ip; R=S*A*inv(S); % R为分块矩阵 % 对R右下块阵(降阶)求按模最大特征值和特征向量 A2=R(2:n,2:n); V0=ones(n-1,1); [lam2,Y2,k2]= powerm(A2,V0,1e-12,100); alpha=-R(1,2:n)*Y2/(lambda(end)-lam2(end)); z2=[alpha;Y2]; x2=inv(S)*z2; % 对特征向量规范化 c=max(abs(x2)); x2=x2/c;