Mercurial > repos > public > sbplib
comparison +time/+expint/expm_Arnoldi.m @ 697:8434063ed162 feature/optim
1 objective optimization finished
author | Ylva Rydin <ylva.rydin@telia.com> |
---|---|
date | Fri, 06 Oct 2017 13:51:21 +0200 |
parents | bc39bb984d88 |
children |
comparison
equal
deleted
inserted
replaced
696:7c16b5af8d98 | 697:8434063ed162 |
---|---|
1 function y = expm_Arnoldi(A,v,t,toler,m) | 1 function y = expm_Arnoldi(A,v,t,toler,m) |
2 % | 2 |
3 global iter | |
4 | |
3 % y = expm_Arnoldi(A,v,t,toler,m) | 5 % y = expm_Arnoldi(A,v,t,toler,m) |
4 % | 6 % |
5 % computes $y = \exp(-t A) v$ | 7 % computes $y = \exp(-t A) v$ |
6 % input: A (n x n)-matrix, v n-vector, t>0 time interval, | 8 % input: A (n x n)-matrix, v n-vector, t>0 time interval, |
7 % toler>0 tolerance, m maximal Krylov dimension | 9 % toler>0 tolerance, m maximal Krylov dimension |
24 beta = norm(v); | 26 beta = norm(v); |
25 V(:,1) = v/beta; | 27 V(:,1) = v/beta; |
26 resnorm = inf; | 28 resnorm = inf; |
27 | 29 |
28 j=0; | 30 j=0; |
31 iter = 0; | |
32 | |
29 | 33 |
30 while resnorm > toler | 34 while resnorm > toler |
35 iter = iter +1; | |
31 j = j+1; | 36 j = j+1; |
32 w = A*V(:,j); | 37 w = A*V(:,j); |
33 for i=1:j | 38 for i=1:j |
34 H(i,j) = w'*V(:,i); | 39 H(i,j) = w'*V(:,i); |
35 w = w - H(i,j)*V(:,i); | 40 w = w - H(i,j)*V(:,i); |