#ifndef R_NO_REMAP
#define R_NO_REMAP
#endif
#define max( a , b )  ( (a) > (b) ? (a) : (b) )
#define min( a , b )  ( (a) < (b) ? (a) : (b) )

#define ETA 2.2204460492503131e-16
#define SQRTETA 1.4901161193847656e-08
#define CCMAX  0.3
#define MAXCOR 3
#define MSBP 20
#define MXNCF 10
#define RATIO 5.0

extern double   sm1[13];
/* newly added static variables */

struct lsoda_common_t {
	int      id; /* rxode2 subject id; set per solve in ind_liblsoda0. Placed before
	                `memory` so lsoda_reset's memset (which starts after `memory`)
	                leaves it untouched between subjects sharing a pooled ctx. */
	/* Discrete-adjoint recording hooks (method="liblsodaadj").  NULL = off (the
	   normal solve).  adjInit is called once at the state==1 initialisation (yh
	   loaded: yh[1]=y0, yh[2]=h0*f(y0)); adjPush is called after every ACCEPTED
	   step (kflag==0).  Placed before `memory` so lsoda_reset preserves them; set
	   unconditionally per-subject in ind_liblsoda0 so a pooled ctx never leaks a
	   stale hook onto a following non-adjoint subject. */
	void (*adjInit)(struct lsoda_context_t *ctx);
	void (*adjPush)(struct lsoda_context_t *ctx);
	double **yh, **wm, *ewt, *savf, *acor;
	int     *ipvt;
	void * memory;

	/* static variables for lsoda() */

	double   h, hu, rc, tn;
	double   tsw, pdnorm;

	/* no static variable for prja(), solsy() */
	/* static variables for stoda() */

	double   crate, el[14];
#ifdef CFODE_STATIC
	double (*elco)[14], (*tesco)[4];
#else
	double elco[13][14], tesco[13][4];
#endif
	double hold, rmax;
	double   pdest, pdlast;

	/* static variables for various vectors and the Jacobian. */

	int      ialth, ipup, nslp;
	int      icount, irflag;
	int      imxer;
	int      illin, nhnil, nslast,
					jcur, meth, mused, nq, nst,
					ncf, nfe, nje, nqu, miter;
};
#define _rxC(x) (ctx->common->x)
