Mercurial > repos > public > sbplib
comparison +time/+expint/Magnus_mp.m @ 513:bc39bb984d88 feature/quantumTriangles
Added arnoldi krylov subspace approximation
author | Ylva Rydin <ylva.rydin@telia.com> |
---|---|
date | Mon, 26 Jun 2017 20:15:54 +0200 |
parents | 4ef2d2a493f1 |
children | 8434063ed162 |
comparison
equal
deleted
inserted
replaced
512:4ef2d2a493f1 | 513:bc39bb984d88 |
---|---|
1 % Takes one time step of size k using the magnus midpoinr | 1 % Takes one time step of size k using the magnus midpoinr |
2 % starting from v_0 and where the function F(v,t) gives the | 2 % starting from v_0 and where the function F(v,t) gives the |
3 % time derivatives. | 3 % time derivatives. |
4 function v = Magnus_mp(v,D, t , k) | 4 function v = Magnus_mp(v,D, t , k,matrixexp,tol) |
5 | 5 |
6 if isa(D,'function_handle') | 6 if isa(D,'function_handle') |
7 % v = krylov(k*D(t +k/2*t),v); | 7 Omega = D(t +k/2); |
8 % v = expm(k*D(t +k/2))*v; | |
9 toler = 10^(-5); | |
10 expm_Arnoldi(-D,v,k,toler,100) | |
11 else | 8 else |
12 %v = krylov(k*D,v); | 9 Omega = D; |
13 % v = expm(k*D)*v; | |
14 end | 10 end |
15 | 11 |
12 switch matrixexp | |
13 case 'expm' | |
14 v = expm(k*Omega)*v; | |
15 case 'Arnoldi' | |
16 v = time.expint.expm_Arnoldi(-Omega,v,k,tol,100); | |
17 otherwise | |
18 error('No such matrix exponential evaluation') | |
19 | |
16 end | 20 end |
21 end |