view +time/+expint/Magnus_mp.m @ 711:397d1b22cc37 feature/quantumTriangles

Changed closure and penalty ao that sparse matrices are created in DiffOpTimeDep
author Ylva Rydin <ylva.rydin@telia.com>
date Thu, 30 Nov 2017 18:01:21 +0100
parents 8434063ed162
children
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')
    Omega = D(t +k/2);
else
    Omega = D;
end

switch matrixexp
    case 'expm'
        v = expm(k*Omega)*v;
    case 'Arnoldi'
        v = time.expint.expm_Arnoldi(-Omega,v,k,tol,1000);
    otherwise
        error('No such matrix exponential evaluation')
        
end
end