#ifndef _LSODE_H
#define _LSODE_H

#include "f_eval.h"


typedef struct _lsode
{
    int N,METHFLAG,ITOL,FUNOUT,ISTATE,IOPT,LRW,LIW,*IWORK;
    double RTOL,ATOL,*RWORK;
    double *Y,T;
    F_EVAL F;
} LSODE;


/*
** LSODE is an Adams method.
** n = number of equations.
** time = initial time.
** y = pointer to your array of n state variables.
** f = function of yours that computes ydot
** stiff_flag: 0 = no, 1 = yes.  No dynamic decision like SDRIV2.
** eps = allowable relative error.
** zero = "problem zero"; I think it's allowable absolute error.
**
** WARNING: although you can have multiple invokations of the integrator
** running using this interface, each time you switch which LSODE "object"
** you're integrating, there is some restart overhead.  So, it's quite a bit
** more efficient to do a bunch of LSODE integrations in series than in
** parallel.
*/ 
LSODE *LsodeAlloc(int n, double t, double *y, F_EVAL f, int stiff_flag,
    double eps, double zero);

/* Do the actual integration.  Return the actual TOUT */
double LsodeIntegrate(LSODE *l, double TOUT);

void LsodeFree(LSODE *l);

#endif  /* _LSODE_H */
