classdef Magnus4 < time.Timestepper
    properties
        D
        S
        F
        k
        t
        v
        m
        n
        matrixexp
        tol
    end


    methods
        function obj = Magnus4(D, k, t0, v0,matrixexp,tol)
            default_arg('matrixexp','expm')
            default_arg('tol',1e-6)
            obj.D = D;
            obj.k = k;
            obj.t = t0;
            obj.v = v0;
            obj.m = length(v0);
            obj.n = 0;
            obj.matrixexp = matrixexp;
            obj.tol = tol;
        end

        function [v,t] = getV(obj)
            v = obj.v;
            t = obj.t;
        end

        function obj = step(obj)
            obj.v = time.expint.Magnus_4(obj.v,obj.D, obj.t, obj.k, obj.matrixexp, obj.tol);
            obj.t = obj.t + obj.k;
            obj.n = obj.n + 1;
        end
    end


    methods (Static)
        function k = getTimeStep(lambda)
            k = rk4.get_rk4_time_step(lambda);
        end
    end

end