#include <time.h>
#include <stdlib.h>
unsigned long int __timeId=0;
void writeHeader(const char *md5, const char *extra) {
sAppend(&sbOut, "#define _getRxSolve_ _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define simeps _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define simeta _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _solveData _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _assign_ptr _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _rxRmModelLib _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _rxGetModelLib _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _old_c _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _ptrid _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _rxIsCurrentC _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _sumPS _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _prodPS _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _prodType _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _sumType _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _update_par_ptr _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _getParCov _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define linCmtA _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define linCmtC _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define linCmtB _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _RxODE_rxAssignPtr _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _rxQr _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define phi _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define logit _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define expit _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define gammap _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define gammaq _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define lowergamma _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define uppergamma _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define gammapInv _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define gammapDer _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define gammapInva _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define gammaqInv _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define gammaqInva _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define rxnorm _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define rxnormV _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define rxbinom _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define rxcauchy _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define rxchisq _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define rxexp _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define rxf _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define rxgeom _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define rxgamma _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define rxbeta _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define rxpois _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define rxt_ _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define rxunif _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define rxweibull _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define rinorm _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define rinormV _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define ribinom _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define ricauchy _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define richisq _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define riexp _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define rif _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define rigeom _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define rigamma _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define ribeta _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define ripois _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define rit_ _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define riunif _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define riweibull _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _compareFactorVal _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _sum _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _sign _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _prod _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _max _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _min _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _transit4P _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _transit3P _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _assignFuns0 _rx%s%s%ld\n", extra, md5, __timeId++);
sAppend(&sbOut, "#define _assignFuns _rx%s%s%ld\n", extra, md5, __timeId++);
}
void writeBody() {
sAppendN(&sbOut, "_getRxSolve_t _getRxSolve_;\n", 28);
sAppendN(&sbOut, "_simfun simeps;\n", 16);
sAppendN(&sbOut, "_simfun simeta;\n", 16);
sAppendN(&sbOut, "rx_solve *_solveData=NULL;\n", 27);
sAppendN(&sbOut, "RxODE_assign_ptr _assign_ptr=NULL;\n", 35);
sAppendN(&sbOut, "_rxRmModelLibType _rxRmModelLib=NULL;\n", 38);
sAppendN(&sbOut, "_rxGetModelLibType _rxGetModelLib=NULL;\n", 40);
sAppendN(&sbOut, "RxODE_ode_solver_old_c _old_c=NULL;\n", 36);
sAppendN(&sbOut, "RxODE_fn0i _ptrid=NULL;\n", 24);
sAppendN(&sbOut, "_rxIsCurrentC_type _rxIsCurrentC=NULL;\n", 39);
sAppendN(&sbOut, "_rxSumType _sumPS=NULL;\n", 24);
sAppendN(&sbOut, "_rxProdType _prodPS=NULL;\n", 26);
sAppendN(&sbOut, "RxODE_fn0i _prodType=NULL;\n", 27);
sAppendN(&sbOut, "RxODE_fn0i _sumType=NULL;\n", 26);
sAppendN(&sbOut, "_update_par_ptr_p _update_par_ptr=NULL;\n", 40);
sAppendN(&sbOut, "_getParCov_p _getParCov=NULL;\n", 30);
sAppendN(&sbOut, "linCmtA_p linCmtA;\n", 19);
sAppendN(&sbOut, "linCmtA_p linCmtC;\n", 19);
sAppendN(&sbOut, "linCmtB_p linCmtB;\n", 19);
sAppendN(&sbOut, "_rx_asgn _RxODE_rxAssignPtr=NULL;\n", 34);
sAppendN(&sbOut, "_rx_asgn _rxQr=NULL;\n", 21);
sAppendN(&sbOut, "RxODE_fn phi;\n", 14);
sAppendN(&sbOut, "RxODE_fn3 logit;\n", 17);
sAppendN(&sbOut, "RxODE_fn3 expit;\n", 17);
sAppendN(&sbOut, "RxODE_fn2 gammap;\n", 18);
sAppendN(&sbOut, "RxODE_fn2 gammaq;\n", 18);
sAppendN(&sbOut, "RxODE_fn2 lowergamma;\n", 22);
sAppendN(&sbOut, "RxODE_fn2 uppergamma;\n", 22);
sAppendN(&sbOut, "RxODE_fn2 gammapInv;\n", 21);
sAppendN(&sbOut, "RxODE_fn2 gammapDer;\n", 21);
sAppendN(&sbOut, "RxODE_fn2 gammapInva;\n", 22);
sAppendN(&sbOut, "RxODE_fn2 gammaqInv;\n", 21);
sAppendN(&sbOut, "RxODE_fn2 gammaqInva;\n", 22);
sAppendN(&sbOut, "RxODEi_fn2 rxnorm;\n", 19);
sAppendN(&sbOut, "RxODEi_fn2 rxnormV;\n", 20);
sAppendN(&sbOut, "RxODEi_rxbinom rxbinom;\n", 24);
sAppendN(&sbOut, "RxODEi_fn2 rxcauchy;\n", 21);
sAppendN(&sbOut, "RxODEi_fn rxchisq;\n", 19);
sAppendN(&sbOut, "RxODEi_fn rxexp;\n", 17);
sAppendN(&sbOut, "RxODEi_fn2 rxf;\n", 16);
sAppendN(&sbOut, "RxODEi_ifn rxgeom;\n", 19);
sAppendN(&sbOut, "RxODEi_fn2 rxgamma;\n", 20);
sAppendN(&sbOut, "RxODEi_fn2 rxbeta;\n", 19);
sAppendN(&sbOut, "RxODEi_ifn rxpois;\n", 19);
sAppendN(&sbOut, "RxODEi_fn rxt_;\n", 16);
sAppendN(&sbOut, "RxODEi_fn2 rxunif;\n", 19);
sAppendN(&sbOut, "RxODEi_fn2 rxweibull;\n", 22);
sAppendN(&sbOut, "RxODEi2_fn2 rinorm;\n", 20);
sAppendN(&sbOut, "RxODEi2_fn2 rinormV;\n", 21);
sAppendN(&sbOut, "RxODEi2_ribinom ribinom;\n", 25);
sAppendN(&sbOut, "RxODEi2_fn2 ricauchy;\n", 22);
sAppendN(&sbOut, "RxODEi2_fn richisq;\n", 20);
sAppendN(&sbOut, "RxODEi2_fn riexp;\n", 18);
sAppendN(&sbOut, "RxODEi2_fn2 rif;\n", 17);
sAppendN(&sbOut, "RxODEi2_ifn rigeom;\n", 20);
sAppendN(&sbOut, "RxODEi2_fn2 rigamma;\n", 21);
sAppendN(&sbOut, "RxODEi2_fn2 ribeta;\n", 20);
sAppendN(&sbOut, "RxODEi2_ifn ripois;\n", 20);
sAppendN(&sbOut, "RxODEi2_fn rit_;\n", 17);
sAppendN(&sbOut, "RxODEi2_fn2 riunif;\n", 20);
sAppendN(&sbOut, "RxODEi2_fn2 riweibull;\n", 23);
sAppendN(&sbOut, "RxODE_compareFactorVal_fn _compareFactorVal;\n", 45);
sAppendN(&sbOut, "double _prod(double *input, double *p, int type, int n, ...){\n", 62);
sAppendN(&sbOut, "  va_list valist;\n", 18);
sAppendN(&sbOut, "  va_start(valist, n);\n", 23);
sAppendN(&sbOut, "  for (unsigned int i = 0; i < n; i++){\n", 40);
sAppendN(&sbOut, "    input[i] = va_arg(valist, double);\n", 39);
sAppendN(&sbOut, "  }\n", 4);
sAppendN(&sbOut, "  va_end(valist);\n", 18);
sAppendN(&sbOut, "  return _prodPS(input, p, n, type);\n", 37);
sAppendN(&sbOut, "}\n", 2);
sAppendN(&sbOut, "double _sum(double *input, double *pld, int m, int type, int n, ...){\n", 70);
sAppendN(&sbOut, "  va_list valist;\n", 18);
sAppendN(&sbOut, "  va_start(valist, n);\n", 23);
sAppendN(&sbOut, "  for (unsigned int i = 0; i < n; i++){\n", 40);
sAppendN(&sbOut, "    input[i] = va_arg(valist, double);\n", 39);
sAppendN(&sbOut, "  }\n", 4);
sAppendN(&sbOut, "  va_end(valist);\n", 18);
sAppendN(&sbOut, "  double ret = _sumPS(input, n, pld, m, type);\n", 47);
sAppendN(&sbOut, "  if (type == 2 && m < 0){\n", 27);
sAppendN(&sbOut, "    for (int i = -m; i--;){\n", 28);
sAppendN(&sbOut, "      pld[i] = 0.0;\n", 20);
sAppendN(&sbOut, "    }\n", 6);
sAppendN(&sbOut, "  }\n", 4);
sAppendN(&sbOut, "  return ret;\n", 14);
sAppendN(&sbOut, "}\n", 2);
sAppendN(&sbOut, "double _sign(unsigned int n, ...) {\n", 36);
sAppendN(&sbOut, "  va_list valist;\n", 18);
sAppendN(&sbOut, "  va_start(valist, n);\n", 23);
sAppendN(&sbOut, "  double s = 1;\n", 16);
sAppendN(&sbOut, "  for (unsigned int i = 0; i < n; i++) {\n", 41);
sAppendN(&sbOut, "    s = sign(va_arg(valist, double))*s;\n", 40);
sAppendN(&sbOut, "    if (s == 0){\n", 17);
sAppendN(&sbOut, "      break;\n", 13);
sAppendN(&sbOut, "    }\n", 6);
sAppendN(&sbOut, "  }\n", 4);
sAppendN(&sbOut, "  va_end(valist);\n", 18);
sAppendN(&sbOut, "  return s;\n", 12);
sAppendN(&sbOut, "}\n", 2);
sAppendN(&sbOut, "double _max(unsigned int n, ...) {\n", 35);
sAppendN(&sbOut, "  va_list valist;\n", 18);
sAppendN(&sbOut, "  va_start(valist, n);\n", 23);
sAppendN(&sbOut, "  double mx = NA_REAL;\n", 23);
sAppendN(&sbOut, "  double tmp = 0;\n", 18);
sAppendN(&sbOut, "  if (n >= 1){\n", 15);
sAppendN(&sbOut, "    mx = va_arg(valist, double);\n", 33);
sAppendN(&sbOut, "    for (unsigned int i = 1; i < n; i++) {\n", 43);
sAppendN(&sbOut, "      tmp = va_arg(valist, double);\n", 36);
sAppendN(&sbOut, "      if (tmp>mx) mx=tmp;\n", 26);
sAppendN(&sbOut, "    }\n", 6);
sAppendN(&sbOut, "    va_end(valist);\n", 20);
sAppendN(&sbOut, "  }\n", 4);
sAppendN(&sbOut, "  return mx;\n", 13);
sAppendN(&sbOut, "}\n", 2);
sAppendN(&sbOut, "double _min(unsigned int n, ...){\n", 34);
sAppendN(&sbOut, "  va_list valist;\n", 18);
sAppendN(&sbOut, "  va_start(valist, n);\n", 23);
sAppendN(&sbOut, "  double mn = NA_REAL;\n", 23);
sAppendN(&sbOut, "  double tmp = 0;\n", 18);
sAppendN(&sbOut, "  if (n >= 1){\n", 15);
sAppendN(&sbOut, "    mn = va_arg(valist, double);\n", 33);
sAppendN(&sbOut, "    for (unsigned int i = 1; i < n; i++){\n", 42);
sAppendN(&sbOut, "      tmp = va_arg(valist, double);\n", 36);
sAppendN(&sbOut, "      if (tmp<mn) mn=tmp;\n", 26);
sAppendN(&sbOut, "    }\n", 6);
sAppendN(&sbOut, "    va_end(valist);\n", 20);
sAppendN(&sbOut, "  }\n", 4);
sAppendN(&sbOut, "  return mn;\n", 13);
sAppendN(&sbOut, "}\n", 2);
sAppendN(&sbOut, "double _transit4P(double t, unsigned int id, double n, double mtt, double bio){\n", 80);
sAppendN(&sbOut, "  double ktr = (n+1)/mtt;\n", 26);
sAppendN(&sbOut, "  double lktr = log(n+1)-log(mtt);\n", 35);
sAppendN(&sbOut, "  double tc = (t-(_solveData->subjects[id].tlast));\n", 52);
sAppendN(&sbOut, "  return exp(log(bio*(_solveData->subjects[id].podo))+lktr+n*(lktr+log(tc))-ktr*(tc)-lgamma1p(n));\n", 99);
sAppendN(&sbOut, "}\n", 2);
sAppendN(&sbOut, "double _transit3P(double t, unsigned int id, double n, double mtt){\n", 68);
sAppendN(&sbOut, "  double ktr = (n+1)/mtt;\n", 26);
sAppendN(&sbOut, "  double lktr = log(n+1)-log(mtt);\n", 35);
sAppendN(&sbOut, "  double tc = (t-(_solveData->subjects[id].tlast));\n", 52);
sAppendN(&sbOut, "  return exp(log(_solveData->subjects[id].podo)+lktr+n*(lktr+log(tc))-ktr*(tc)-lgamma1p(n));\n", 93);
sAppendN(&sbOut, "}\n", 2);
sAppendN(&sbOut, "void _assignFuns0() {\n", 22);
sAppendN(&sbOut, "  _getRxSolve_ = (_getRxSolve_t) R_GetCCallable(\"RxODE\",\"getRxSolve_\");\n", 72);
sAppendN(&sbOut, "  _assign_ptr=(RxODE_assign_ptr) R_GetCCallable(\"RxODE\",\"RxODE_assign_fn_pointers\");\n", 85);
sAppendN(&sbOut, "  _rxRmModelLib=(_rxRmModelLibType) R_GetCCallable(\"RxODE\",\"rxRmModelLib\");\n", 76);
sAppendN(&sbOut, "  _rxGetModelLib=(_rxGetModelLibType) R_GetCCallable(\"RxODE\",\"rxGetModelLib\");\n", 79);
sAppendN(&sbOut, "  _RxODE_rxAssignPtr=(_rx_asgn)R_GetCCallable(\"RxODE\",\"_RxODE_rxAssignPtr\");\n", 77);
sAppendN(&sbOut, "  _rxQr=(_rx_asgn)R_GetCCallable(\"RxODE\",\"_RxODE_rxQr\");\n", 57);
sAppendN(&sbOut, "  _rxIsCurrentC = (_rxIsCurrentC_type)R_GetCCallable(\"RxODE\",\"rxIsCurrentC\");\n", 78);
sAppendN(&sbOut, "  _sumPS  = (_rxSumType) R_GetCCallable(\"PreciseSums\",\"PreciseSums_sum_r\");\n", 76);
sAppendN(&sbOut, "  _prodPS = (_rxProdType) R_GetCCallable(\"PreciseSums\",\"PreciseSums_prod_r\");\n", 78);
sAppendN(&sbOut, "  _prodType=(RxODE_fn0i)R_GetCCallable(\"PreciseSums\", \"PreciseSums_prod_get\");\n", 79);
sAppendN(&sbOut, "  _sumType=(RxODE_fn0i)R_GetCCallable(\"PreciseSums\", \"PreciseSums_sum_get\");\n", 77);
sAppendN(&sbOut, "  _ptrid=(RxODE_fn0i)R_GetCCallable(\"RxODE\", \"RxODE_current_fn_pointer_id\");\n", 77);
sAppendN(&sbOut, "  linCmtA=(linCmtA_p)R_GetCCallable(\"RxODE\", \"linCmtA\");\n", 57);
sAppendN(&sbOut, "  linCmtB=(linCmtB_p)R_GetCCallable(\"RxODE\", \"linCmtB\");\n", 57);
sAppendN(&sbOut, "  linCmtC=(linCmtA_p)R_GetCCallable(\"RxODE\", \"linCmtC\");\n", 57);
sAppendN(&sbOut, "    \n", 5);
sAppendN(&sbOut, "  rxnorm = (RxODEi_fn2)R_GetCCallable(\"RxODE\", \"rxnorm\");\n", 58);
sAppendN(&sbOut, "  rxnormV = (RxODEi_fn2)R_GetCCallable(\"RxODE\", \"rxnormV\");\n", 60);
sAppendN(&sbOut, "  rxbinom = (RxODEi_rxbinom)R_GetCCallable(\"RxODE\",\"rxbinom\") ;\n", 64);
sAppendN(&sbOut, "  rxcauchy = (RxODEi_fn2)R_GetCCallable(\"RxODE\",\"rxcauchy\") ;\n", 62);
sAppendN(&sbOut, "  rxchisq = (RxODEi_fn)R_GetCCallable(\"RxODE\",\"rxchisq\") ;\n", 59);
sAppendN(&sbOut, "  rxexp = (RxODEi_fn)R_GetCCallable(\"RxODE\",\"rxexp\");\n", 54);
sAppendN(&sbOut, "  rxf = (RxODEi_fn2)R_GetCCallable(\"RxODE\",\"rxf\") ;\n", 52);
sAppendN(&sbOut, "  rxgeom = (RxODEi_ifn)R_GetCCallable(\"RxODE\",\"rxgeom\") ;\n", 58);
sAppendN(&sbOut, "  rxgamma = (RxODEi_fn2)R_GetCCallable(\"RxODE\",\"rxgamma\") ;\n", 60);
sAppendN(&sbOut, "  rxbeta = (RxODEi_fn2)R_GetCCallable(\"RxODE\",\"rxbeta\") ;\n", 58);
sAppendN(&sbOut, "  rxpois = (RxODEi_ifn)R_GetCCallable(\"RxODE\",\"rxpois\") ;\n", 58);
sAppendN(&sbOut, "  rxt_ = (RxODEi_fn)R_GetCCallable(\"RxODE\",\"rxt_\") ;\n", 53);
sAppendN(&sbOut, "  rxunif = (RxODEi_fn2)R_GetCCallable(\"RxODE\",\"rxunif\") ;\n", 58);
sAppendN(&sbOut, "  rxweibull = (RxODEi_fn2)R_GetCCallable(\"RxODE\",\"rxweibull\");\n", 63);
sAppendN(&sbOut, "  rinorm = (RxODEi2_fn2)R_GetCCallable(\"RxODE\", \"rinorm\");\n", 59);
sAppendN(&sbOut, "  rinormV = (RxODEi2_fn2)R_GetCCallable(\"RxODE\", \"rinormV\");\n", 61);
sAppendN(&sbOut, "  ribinom = (RxODEi2_ribinom)R_GetCCallable(\"RxODE\",\"ribinom\") ;\n", 65);
sAppendN(&sbOut, "  ricauchy = (RxODEi2_fn2)R_GetCCallable(\"RxODE\",\"ricauchy\") ;\n", 63);
sAppendN(&sbOut, "  richisq = (RxODEi2_fn)R_GetCCallable(\"RxODE\",\"richisq\") ;\n", 60);
sAppendN(&sbOut, "  riexp = (RxODEi2_fn)R_GetCCallable(\"RxODE\",\"riexp\");\n", 55);
sAppendN(&sbOut, "  rif = (RxODEi2_fn2)R_GetCCallable(\"RxODE\",\"rif\") ;\n", 53);
sAppendN(&sbOut, "  rigeom = (RxODEi2_ifn)R_GetCCallable(\"RxODE\",\"rigeom\") ;\n", 59);
sAppendN(&sbOut, "  rigamma = (RxODEi2_fn2)R_GetCCallable(\"RxODE\",\"rigamma\") ;\n", 61);
sAppendN(&sbOut, "  ribeta = (RxODEi2_fn2)R_GetCCallable(\"RxODE\",\"ribeta\") ;\n", 59);
sAppendN(&sbOut, "  ripois = (RxODEi2_ifn)R_GetCCallable(\"RxODE\",\"ripois\") ;\n", 59);
sAppendN(&sbOut, "  rit_ = (RxODEi2_fn)R_GetCCallable(\"RxODE\",\"rit_\") ;\n", 54);
sAppendN(&sbOut, "  riunif = (RxODEi2_fn2)R_GetCCallable(\"RxODE\",\"riunif\") ;\n", 59);
sAppendN(&sbOut, "  riweibull = (RxODEi2_fn2)R_GetCCallable(\"RxODE\",\"riweibull\");\n", 64);
sAppendN(&sbOut, "    \n", 5);
sAppendN(&sbOut, "  phi = (RxODE_fn)R_GetCCallable(\"RxODE\",\"phi\");\n", 49);
sAppendN(&sbOut, "  gammap = (RxODE_fn2) R_GetCCallable(\"RxODE\",\"gammap\");\n", 57);
sAppendN(&sbOut, "  gammaq = (RxODE_fn2) R_GetCCallable(\"RxODE\",\"gammaq\");\n", 57);
sAppendN(&sbOut, "  gammapInv = (RxODE_fn2) R_GetCCallable(\"RxODE\",\"gammapInv\");\n", 63);
sAppendN(&sbOut, "  gammapInva = (RxODE_fn2) R_GetCCallable(\"RxODE\",\"gammapInva\");\n", 65);
sAppendN(&sbOut, "  gammaqInv = (RxODE_fn2) R_GetCCallable(\"RxODE\",\"gammaqInv\");\n", 63);
sAppendN(&sbOut, "  gammaqInva = (RxODE_fn2) R_GetCCallable(\"RxODE\",\"gammaqInva\");\n", 65);
sAppendN(&sbOut, "  uppergamma = (RxODE_fn2) R_GetCCallable(\"RxODE\",\"uppergamma\");\n", 65);
sAppendN(&sbOut, "  lowergamma = (RxODE_fn2) R_GetCCallable(\"RxODE\",\"lowergamma\");\n", 65);
sAppendN(&sbOut, "  gammapDer  = (RxODE_fn2) R_GetCCallable(\"RxODE\",\"gammapDer\");\n", 64);
sAppendN(&sbOut, "  logit = (RxODE_fn3) R_GetCCallable(\"RxODE\", \"logit\");\n", 56);
sAppendN(&sbOut, "  expit = (RxODE_fn3) R_GetCCallable(\"RxODE\", \"expit\");\n", 56);
sAppendN(&sbOut, "  simeta =(_simfun) R_GetCCallable(\"RxODE\", \"simeta\");\n", 55);
sAppendN(&sbOut, "  simeps =(_simfun) R_GetCCallable(\"RxODE\", \"simeps\");\n", 55);
sAppendN(&sbOut, "  _compareFactorVal=(RxODE_compareFactorVal_fn) R_GetCCallable(\"RxODE\", \"compareFactorVal\");\n", 93);
sAppendN(&sbOut, "  _update_par_ptr = (_update_par_ptr_p) R_GetCCallable(\"RxODE\",\"_update_par_ptr\");\n", 83);
sAppendN(&sbOut, "  _getParCov = (_getParCov_p) R_GetCCallable(\"RxODE\",\"_getParCov\");\n", 68);
sAppendN(&sbOut, "  _solveData = _getRxSolve_();\n", 31);
sAppendN(&sbOut, "}\n", 2);
sAppendN(&sbOut, "void _assignFuns() {\n", 21);
sAppendN(&sbOut, "  if (_assign_ptr == NULL){\n", 28);
sAppendN(&sbOut, "    _assignFuns0();\n", 20);
sAppendN(&sbOut, "  }\n", 4);
sAppendN(&sbOut, "}\n", 2);
}
void writeFooter() {
sAppendN(&sbOut, "#undef _getRxSolve_\n", 20);
sAppendN(&sbOut, "#undef simeps\n", 14);
sAppendN(&sbOut, "#undef simeta\n", 14);
sAppendN(&sbOut, "#undef _solveData\n", 18);
sAppendN(&sbOut, "#undef _assign_ptr\n", 19);
sAppendN(&sbOut, "#undef _rxRmModelLib\n", 21);
sAppendN(&sbOut, "#undef _rxGetModelLib\n", 22);
sAppendN(&sbOut, "#undef _old_c\n", 14);
sAppendN(&sbOut, "#undef _ptrid\n", 14);
sAppendN(&sbOut, "#undef _rxIsCurrentC\n", 21);
sAppendN(&sbOut, "#undef _sumPS\n", 14);
sAppendN(&sbOut, "#undef _prodPS\n", 15);
sAppendN(&sbOut, "#undef _prodType\n", 17);
sAppendN(&sbOut, "#undef _sumType\n", 16);
sAppendN(&sbOut, "#undef _update_par_ptr\n", 23);
sAppendN(&sbOut, "#undef _getParCov\n", 18);
sAppendN(&sbOut, "#undef linCmtA\n", 15);
sAppendN(&sbOut, "#undef linCmtC\n", 15);
sAppendN(&sbOut, "#undef linCmtB\n", 15);
sAppendN(&sbOut, "#undef _RxODE_rxAssignPtr\n", 26);
sAppendN(&sbOut, "#undef _rxQr\n", 13);
sAppendN(&sbOut, "#undef phi\n", 11);
sAppendN(&sbOut, "#undef logit\n", 13);
sAppendN(&sbOut, "#undef expit\n", 13);
sAppendN(&sbOut, "#undef gammap\n", 14);
sAppendN(&sbOut, "#undef gammaq\n", 14);
sAppendN(&sbOut, "#undef lowergamma\n", 18);
sAppendN(&sbOut, "#undef uppergamma\n", 18);
sAppendN(&sbOut, "#undef gammapInv\n", 17);
sAppendN(&sbOut, "#undef gammapDer\n", 17);
sAppendN(&sbOut, "#undef gammapInva\n", 18);
sAppendN(&sbOut, "#undef gammaqInv\n", 17);
sAppendN(&sbOut, "#undef gammaqInva\n", 18);
sAppendN(&sbOut, "#undef rxnorm\n", 14);
sAppendN(&sbOut, "#undef rxnormV\n", 15);
sAppendN(&sbOut, "#undef rxbinom\n", 15);
sAppendN(&sbOut, "#undef rxcauchy\n", 16);
sAppendN(&sbOut, "#undef rxchisq\n", 15);
sAppendN(&sbOut, "#undef rxexp\n", 13);
sAppendN(&sbOut, "#undef rxf\n", 11);
sAppendN(&sbOut, "#undef rxgeom\n", 14);
sAppendN(&sbOut, "#undef rxgamma\n", 15);
sAppendN(&sbOut, "#undef rxbeta\n", 14);
sAppendN(&sbOut, "#undef rxpois\n", 14);
sAppendN(&sbOut, "#undef rxt_\n", 12);
sAppendN(&sbOut, "#undef rxunif\n", 14);
sAppendN(&sbOut, "#undef rxweibull\n", 17);
sAppendN(&sbOut, "#undef rinorm\n", 14);
sAppendN(&sbOut, "#undef rinormV\n", 15);
sAppendN(&sbOut, "#undef ribinom\n", 15);
sAppendN(&sbOut, "#undef ricauchy\n", 16);
sAppendN(&sbOut, "#undef richisq\n", 15);
sAppendN(&sbOut, "#undef riexp\n", 13);
sAppendN(&sbOut, "#undef rif\n", 11);
sAppendN(&sbOut, "#undef rigeom\n", 14);
sAppendN(&sbOut, "#undef rigamma\n", 15);
sAppendN(&sbOut, "#undef ribeta\n", 14);
sAppendN(&sbOut, "#undef ripois\n", 14);
sAppendN(&sbOut, "#undef rit_\n", 12);
sAppendN(&sbOut, "#undef riunif\n", 14);
sAppendN(&sbOut, "#undef riweibull\n", 17);
sAppendN(&sbOut, "#undef _compareFactorVal\n", 25);
sAppendN(&sbOut, "#undef _sum\n", 12);
sAppendN(&sbOut, "#undef _sign\n", 13);
sAppendN(&sbOut, "#undef _prod\n", 13);
sAppendN(&sbOut, "#undef _max\n", 12);
sAppendN(&sbOut, "#undef _min\n", 12);
sAppendN(&sbOut, "#undef _transit4P\n", 18);
sAppendN(&sbOut, "#undef _transit3P\n", 18);
sAppendN(&sbOut, "#undef _assignFuns0\n", 20);
sAppendN(&sbOut, "#undef _assignFuns\n", 19);
}
