Arnoldi method to find eigenvalues
30 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm trying to implement the Arnoldi method with the inverse power method to find eigenvalues of large pencil matrix.
I have followed the practical implementation in Saad's book and I started with a small matrix to check if the code work well. As I understand H is a square matrix and has size of the number of the iterations but the resulted H is of size 3x2 and V is 4x3. I'm not sure if this is correct and I do'nt know how I can find the eigenvalues of H and the corresponding eigenvectors. Here is my attempt, and I really appreciate any help..
A=[1 0 0 0;0 17 0 0;0 0 -10 0 ;0 0 0 5]
n=length(A)
B=eye(n)
a=0 %interval [a,b]
b=10
m=2; %iterations
x=ones(n,1); %constant vector
shift=0.5;
V = zeros(n,m); %orthonormal basis of Krylov space
V(:,1) = x/norm(x);
H = zeros(n,m); %upper Hessenberg matrix
C=A-shift*B;
[L, U] = lu(C, 'vector');
for j=1:m
w=U\(L\(B*V(:,j)));
for i=1:j %Gram-schmidt
H(i,j) = V(:,i)'*w;
w = w - V(:,i)*H(i,j);
end
H(j+1,j) = norm(w,2);
V(:,j+1) = w/H(j+1,j);
end
0 Kommentare
Antworten (1)
Pavl M.
am 11 Okt. 2024
Hi, happy to help:
Use next code:
clc
clear all
close all
%non-square matrix:
%A=[1 0 0 0;0 17 0 0;0 0 -10 0 ;0 0 0 5;0 0 0 0]
A=[1 0 0 0;0 17 0 0;0 0 -10 0 ;0 0 0 5]
%DMD code:
%version 1:
n1=size(A,1);
n2=size(A,2);
B=eye(n1,n2);
a=0 %interval [a,b]
b=10
m=n2; %iterations
x=ones(n2,1); %constant vector
shift=0.5;
V = zeros(n2,m); %orthonormal basis of Krylov space
V(:,1) = x/norm(x);
H = zeros(min(m+1,m),n1); %upper Hessenberg matrix
W = zeros(n1,m);
Z = zeros(n1,m);
C=A-shift*B;
[L, U] = lu(C, 'vector');
for j=1:m
w=U\(L\(B*V(:,j)))
z = A*V(:,j)
W(:,j) = w;
Z(:,j) = z;
for i=1:j %Gram-schmidt
H(i,j) = V(:,i)'*w;
w = w - V(:,i)*H(i,j);
end
if j < n1
H(j+1,j) = norm(w,2);
if H(j+1,j) == 0, return, end
V(:,j+1) = w/H(j+1,j);
end
end
H
V
W
Z
%find dynamical modes:
%vector of mode amplitudes and ? estimation:
v1 = H*A
v2 = A*diag(Z)
v23 = diag(z)*A
v11 = W*A
v22 = Z*A
display('Accuracy measure 1:')
acc = mean(mean(abs(V-Z)))
0 Kommentare
Siehe auch
Kategorien
Mehr zu Programming Utilities finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!