function varargout = mpend_Idx2_GGL(t,y,flag,idx)

if nargin<4 | isempty(idx)
idx = 1;
end

switch flag
case '' % Return dy/dt = f(t,y).
varargout{1} = f(t,y,idx);
case 'init' % Return default [tspan,y0,options].
[varargout{1:3}] = init(idx);
case 'jacobian' % Return Jacobian matrix df/dy.
varargout{1} = jacobian(t,y,idx);
case 'mass' % Return mass matrix M(t) or M.
varargout{1} = mass(t,y,idx);
otherwise
error(['Unknown flag ''' flag '''.']);
end

% --------------------------------------------------------------------------

function [tspan,y0,options] = init(idx)

global g_nind;

tspan = [];
y0 = [];

options = odeset('Vectorized','off');
options = odeset(options,'Jacobian','on');
options = odeset(options,'JConstant','off');
options = odeset(options,'JPattern','off');
options = odeset(options,'Mass', 'on');
options = odeset(options,'MassConstant', 'on');
options = odeset(options,'Stats', 'on');

g_nind = [4,2,0]';

options.Complex = 'off';

% --------------------------------------------------------------------------

function dy = f(t,y,idx)
dy = zeros(size(y));

% --------------------------------------------------------------------------

function J = jacobian(t,y,idx)
J = zeros(6,6);

% --------------------------------------------------------------------------

function M = mass(t,y,p1,p2)
M = [1 0 0 0 0 0;
0 1 0 0 0 0;
0 0 1 0 0 0;
0 0 0 1 0 0;
0 0 0 0 0 0;
0 0 0 0 0 0];