het_computebase.m

来自「计算动力学系统的分岔图」· M 代码 · 共 41 行

M
41
字号
%function  [Q0,evl,NSub] =  Het_computeBase(hom, A0, unstable_flag, NSub)
%
% Compute an orthonormal basis Q0 for the invariant subspace
% corresponding to the NSub 
%       most unstable eigenvalues of A0 if unstable_flag = 1
%   and most stable eigenvalues of A0 if unstable_flag = 0.
%
% If resizeable_flag is true, then the size of the space NSub may
% be adjusted. 

function  [Q0,evl,NSub] = Het_computeBase(A0, unstable_flag, NSub)
evl = eig(A0);
if unstable_flag
    
    % Compute all eigenvalues and eigenvectors and check number of unstable
    % ones
   
    % Compute eigenvalues and -vectors, ordered
    % (the ones with largest norm are first)
    
    [VU, DU] = eigs(A0,size(A0,1),'LM');
    % Select first NSub eigenvectors: unstable eigenspace
    VU = VU(:,1:NSub);
    % Compute orthonormal basis for the eigenspace
    [Q0,RU] = qr(VU);
    
else
    
    % Compute all eigenvalues and eigenvectors and check number of stable
    % ones
 
    % Compute eigenvalues and -vectors, ordered
    % (the ones with smallest norm are first)
    
    [VS, DS] = eigs(A0,size(A0,1),'SM');
    % Select first NSub eigenvectors: stable eigenspace
    VS = VS(:,1:NSub);
    % Compute orthonormal basis for the eigenspace
    [Q0,RS] = qr(VS);
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?