view +time/+expint/Magnus_mp.m~ @ 696:7c16b5af8d98 feature/quantumTriangles

Add Jonatans symbolic lifehax
author Ylva Rydin <ylva.rydin@telia.com>
date Thu, 05 Oct 2017 18:04:23 +0200
parents bc39bb984d88
children 8434063ed162
line wrap: on
line source

% Takes one time step of size k using the magnus midpoinr
% starting from v_0 and where the function F(v,t) gives the
% time derivatives.
function v = Magnus_mp(v,D, t , k,matrixexp,tol)

if isa(D,'function_handle')
 switch matrixexp
     case 'expm'
        v = expm(k*D(t +k/2))*v;
     case 'Arnol'
    v = time.expint.expm_Arnoldi(-D(t +k/2),v,k,toler,100);
else
   %v = krylov(k*D,v);
   % v = expm(k*D)*v;
end

end