%
% sys_deri.m
%
% DDE-BIFTOOL MATLAB vector field function for: mg
%
% This file was generated by the program VFGEN (Version:2.1.0)
% Generated on  3-Jun-2007 at 12:24
%
%
% The lags are: {tau}
%
% If X(t) is the state vector at time t, then
%    Zlags_ = [ X(t) X(t-tau) ]
%
% The state vector:
% x          = Zlags_(1,1);
%
% (In the comments below, "wrt" means "with respect to".)
%
function jac_ = sys_deri(Zlags_,par_,nx_,np_,v_)
    % Parameters
    a          = par_(1);
    b          = par_(2);
    tau        = par_(3);

    if length(nx_) == 1 & length(np_) == 0 & isempty(v_)
        jac_ = zeros(1,1);
        if nx_ == 0
            % Derivatives wrt the state variables
            jac_(1,1) = -b;
        elseif nx_ == 1
            % Derivatives wrt state variables with delay tau
            jac_(1,1) = a*(1+Zlags_(1,2)^10)^(-1)-10*Zlags_(1,2)^10*a*(1+Zlags_(1,2)^10)^(-2);
        end
    elseif length(nx_) == 0 & length(np_) == 1 & isempty(v_)
        jac_ = zeros(1,1);
        if np_ == 1
            % Derivative wrt a
            jacp_(1) = Zlags_(1,2)*(1+Zlags_(1,2)^10)^(-1);
        elseif np_ == 2
            % Derivative wrt b
            jacp_(1) = -Zlags_(1,1);
        elseif np_ == 3
            % Derivative wrt tau
        end
    elseif length(nx_) == 1 & length(np_) == 1 & isempty(v_)
        % mixed state variable and parameter derivatives
        jac_ = zeros(1,1);
        if nx_ == 0
            % Derivatives wrt the state variables
            if np_ == 1
                % Derivative wrt a
            elseif np_ == 2
                % Derivative wrt b
                jac_(1,1) = -1;
            elseif np_ == 3
                % Derivative wrt tau
            end    % if np_ == ...
        elseif nx_ == 1
            % Derivatives wrt state variables with delay tau
            if np_ == 1
                % Derivative wrt a
                jac_(1,1) = -10*Zlags_(1,2)^10*(1+Zlags_(1,2)^10)^(-2)+(1+Zlags_(1,2)^10)^(-1);
            elseif np_ == 2
                % Derivative wrt b
            elseif np_ == 3
                % Derivative wrt tau
            end    % if np_ == ...
        end    % if nx_ == ...
    elseif length(nx_) == 2 & length(np_) == 0 & ~isempty(v_)
        jac_ = zeros(1,1);
        if nx_(1) == 0
            % Derivatives wrt the state variables
            if nx_(2) == 0
                % Derivatives wrt the state variables
            elseif nx_(2) == 1
                % Derivatives wrt state variables with delay tau
            end % if nx_(2) == ...
        elseif nx_(1) == 1
            % Derivatives wrt state variables with delay tau
            if nx_(2) == 0
                % Derivatives wrt the state variables
            elseif nx_(2) == 1
                % Derivatives wrt state variables with delay tau
                jac_(1,1) = (200*Zlags_(1,2)^19*a*(1+Zlags_(1,2)^10)^(-3)-110*Zlags_(1,2)^9*a*(1+Zlags_(1,2)^10)^(-2))*v_(1);
            end % if nx_(2) == ...
        end  % if nx_(1) == ...
    else
        error('sys_deri: Requested derivative has not been implemented.')
    end
    return
