首頁>Club>
7
回覆列表
  • 1 # 趣趣hsjdnkf

    最基本的特徵值問題分為三類:

    1、標準的線性特徵值問題:

    Ax=λx,A∈Cn∗nAx=λx,A∈Cn∗n

    2、普遍的線性特徵值問題:

    Ax=λBx,A、B∈Cn∗nAx=λBx,A、B∈Cn∗n

    3、普遍的艾米特正定線性特徵值問題:

    Ax=λBx,A、B∈Cn∗nAx=λBx,A、B∈Cn∗n

    A∗=A,B∗=B>0∈Cn∗nA∗=A,B∗=B>0∈Cn∗n

    Arnoldi方法求特徵值是特別常用的一個方法,matlab的內建函式eigs就是用了這個方法,一起來看看。

    % demo routine for the usage of MATLAB eigs function.

    % Example: Compute eigenvalues of a matrix A close to sigma,

    % using shift and invert spectral transformation.

    rng(0);%設定隨機種子

    A = RandomWalkProb(15);%產生隨機矩陣

    n = length(A);%矩陣長度

    sigma = 0.01; %最終是為了找出離sigma最近的特徵值

    [L, U, P] = lu(A - sigma * eye(n));%LU分解, L*U = P*A,此因A不一定能LU分解

    Afun = @(x) U \ (L \ (P*x));%Afun其實就是1/(A-sigmaI)

    opts.isreal = true;%1 if A or A-sigma*B represented by Afun is real, 0 otherwise.

    opts.issym = false;%1 if A or A-sigma*B represented by Afun is symmetric, 0 otherwise.

    opts.disp = 2;%Diagnostic information display level.

    num = 3;

    [V, E] = eigs(Afun, n, num, sigma, opts);%呼叫了eigs函式,對求距離sigma最近的num個矩陣

    %結果最後V是特徵向量組成的矩陣,E的對角線是特徵值

    % END

    其中的RandomWalkProb.m:

    function A = RandomWalkProb(k)

    % Function A = RandomWalkProb(k) generate a stochastic matrix A

    % of size n = (k+1)*(k+2)/2.

    %

    % References:

    % Y. Saad, Numerical Methods for Large Eigenvalue Problems, Revised ed.

    % SIAM, Philadelphia, 2011. pp 36--37.

    %

    II = []; JJ = []; VV = [];

    idx = @(i,j) i*(2*k-i+3)/2+j+1;

    for i = 0:k

    for j = 0:k-i

    % (i,j) --> (i-1, j)

    if i>0

    II = [II, idx(i,j)];

    JJ = [JJ, idx(i-1,j)];

    VV = [VV, (i+j)/2/k * (1+(j==0))];

    end

    % (i,j) --> (i, j-1)

    if j>0

    II = [II, idx(i,j)];

    JJ = [JJ, idx(i,j-1)];

    VV = [VV, (i+j)/2/k * (1+(i==0))];

    end

    % (i,j) --> (i+1, j)

    if j+i<k

    II = [II, idx(i,j)];

    JJ = [JJ, idx(i+1,j)];

    VV = [VV, 0.5 - (i+j)/2/k];

    end

    % (i,j) --> (i, j+1)

    if j+i<k

    II = [II, idx(i,j)];

    JJ = [JJ, idx(i,j+1)];

    VV = [VV, 0.5 - (i+j)/2/k];

    end

    end

    end

    A = sparse(II,JJ,VV);

    return;

  • 中秋節和大豐收的關聯?
  • 索尼A6000和奧林巴斯ep5哪個好?