-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7577767
commit 2cfa7f8
Showing
61 changed files
with
26,612 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#pragma once | ||
#define STRICT_R_HEADERS | ||
#ifndef __rxode2parse_H__ | ||
#define __rxode2parse_H__ | ||
#define rxLlikSaveSize 9 | ||
|
||
#define getAdvan(idx) ind->solve + (op->neq + op->nlin)*(idx) + op->neq | ||
#define getSolve(idx) ind->solve + (op->neq + op->nlin)*(idx) | ||
#define isDose(evid) ((evid) == 3 || (evid) >= 100) | ||
#define isObs(evid) ((evid) == 0 || (evid) == 2 || ((evid) >= 9 && (evid) <= 99)) | ||
|
||
#define getEvid(ind, idx) (idx >= 0 ? ind->evid[idx] : ind->extraDoseEvid[-1-idx]) | ||
#define getEvidP1(ind, idx) (idx >= 0 ? ind->evid[idx+1] : ind->extraDoseEvid[-idx]) | ||
#define getEvidM1(ind, idx) (idx >= 0 ? ind->evid[idx-1] : ind->extraDoseEvid[-2-idx]) | ||
|
||
#define getDose(ind, idx) (idx >= 0 ? ind->dose[idx] : ind->extraDoseDose[-1-idx]) | ||
#define getDoseP1(ind, idx) (idx >= 0 ? ind->dose[idx+1] : ind->extraDoseDose[-idx]) | ||
#define getDoseM1(ind, idx) (idx >= 0 ? ind->dose[idx-1] : ind->extraDoseDose[-2-idx]) | ||
|
||
#define setDoseP1(ind, idx, val) if (idx >= 0){ind->dose[idx+1] = val;} else {ind->extraDoseDose[-idx] = val;} | ||
|
||
#define getIi(ind, idx) (idx >= 0 ? ind->ii[idx] : 0.0) | ||
#define getIiP1(ind, idx) (idx >= 0 ? ind->ii[idx+1] : 0.0) | ||
#define getIiM1(ind, idx) (ind >= 0 ? ind->ii[idx-1] : 0.0) | ||
|
||
#define getDoseM1(ind, idx) (idx >= 0 ? ind->dose[idx-1] : ind->extraDoseDose[-2-idx]) | ||
|
||
#define getAllTimes(ind, idx) (idx >= 0 ? ind->all_times[idx] : ind->extraDoseTime[-1-idx]) | ||
#define getAllTimesP1(ind, idx) (idx >= 0 ? ind->all_times[idx+1] : ind->extraDoseTime[-idx]) | ||
#define getAllTimesM1(ind, idx) (idx >= 0 ? ind->all_times[idx-1] : ind->extraDoseTime[-2-idx]) | ||
|
||
#define setAllTimesP1(ind, idx, val) if (idx>= 0) {ind->all_times[idx+1] = val;} else {ind->extraDoseTime[-idx] = val;} | ||
#include <R.h> | ||
#include <stdbool.h> | ||
|
||
#include <float.h> | ||
#include <stdio.h> | ||
#include <stdarg.h> | ||
|
||
#include "rxode2parse_control.h" | ||
#include <stdint.h> // for uint64_t rather than unsigned long long | ||
|
||
#ifdef _isrxode2parse_ | ||
#define max2( a , b ) ( (a) > (b) ? (a) : (b) ) | ||
#define isSameTime(xout, xp) (fabs((xout)-(xp)) <= DBL_EPSILON*max2(fabs(xout),fabs(xp))) | ||
// use ~dop853 definition of same time | ||
#define isSameTimeDop(xout, xp) (0.1 * fabs((xout)-(xp)) <= fabs(xout) * 2.3E-16) | ||
#define _linCmtParse _rxode2parse_linCmtParse | ||
#define _rxode2_linCmtGen _rxode2parse_linCmtGen | ||
#define rc_buf_read _rxode2parse_rc_buf_read | ||
#define sIniTo _rxode2parse_sIniTo | ||
#define sFree _rxode2parse_sFree | ||
#define sFreeIni _rxode2parse_sFreeIni | ||
#define sAppendN _rxode2parse_sAppendN | ||
#define sAppend _rxode2parse_sAppend | ||
#define sPrint _rxode2parse_sPrint | ||
#define lineIni _rxode2parse_lineIni | ||
#define lineFree _rxode2parse_lineFree | ||
#define addLine _rxode2parse_addLine | ||
#define curLineProp _rxode2parse_curLineProp | ||
#define curLineType _rxode2parse_curLineType | ||
#define doDot _rxode2parse_doDot | ||
#define doDot2 _rxode2parse_doDot2 | ||
#define _setSilentErr _rxode2parse__setSilentErr | ||
#define _isRstudio2 _rxode2parse_isRstudio2 | ||
#define setSilentErr _rxode2parse_setSilentErr | ||
#define setRstudioPrint _rxode2parse_setRstudioPrint | ||
#define getSilentErr _rxode2parse_getSilentErr | ||
#define getRstudioPrint _rxode2parse_getRstudioPrint | ||
#define RSprintf _rxode2parse_RSprintf | ||
#define parseFree _rxode2parse_parseFree | ||
#define parseFreeLast _rxode2parse_parseFreeLast | ||
#define reset _rxode2parse_reset | ||
#endif | ||
#include "rxode2parseStruct.h" | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#ifndef __rxode2parseConvertMethod_h__ | ||
#define __rxode2parseConvertMethod_h__ | ||
IntegerVector convertMethod(RObject method){ | ||
IntegerVector oldEvid; | ||
if (rxIsChar(method)){ | ||
CharacterVector tmp = asCv(method, "method"); | ||
oldEvid = IntegerVector(tmp.size()); | ||
for (int jj = tmp.size(); jj--;){ | ||
std::string cur = (as<std::string>(tmp[jj])).substr(0,1); | ||
// (1 = replace, 2 = add, 3 = multiply) | ||
if (cur == "A" || cur == "a" || cur == "2"){ | ||
oldEvid[jj] = 1; | ||
} else if (cur == "m" || cur == "M" || cur == "3"){ | ||
oldEvid[jj] = 6; | ||
} else if (cur == "r" || cur == "R" || cur == "1"){ | ||
oldEvid[jj] = 5; | ||
} else { | ||
stop(_("unknown method: '%s'"), (as<std::string>(tmp[jj])).c_str()); | ||
} | ||
} | ||
} else if (Rf_inherits(method, "factor")){ | ||
IntegerVector tmp = asIv(method, "method"); | ||
oldEvid = IntegerVector(tmp.size()); | ||
CharacterVector lvl = tmp.attr("levels"); | ||
IntegerVector trans(lvl.size()); | ||
for (int jj = lvl.size(); jj--;){ | ||
std::string cur = (as<std::string>(lvl[jj])).substr(0,1); | ||
if (cur == "A" || cur == "a" || cur == "2"){ | ||
trans[jj] = 1; | ||
} else if (cur == "m" || cur == "M" || cur == "3"){ | ||
trans[jj] = 6; | ||
} else if (cur == "r" || cur == "R" || cur == "1"){ | ||
trans[jj] = 5; | ||
} else { | ||
stop(_("unknown method: '%s'"), (as<std::string>(lvl[jj])).c_str()); | ||
} | ||
} | ||
for (int jj = tmp.size(); jj--;){ | ||
oldEvid[jj] = trans[tmp[jj]-1]; | ||
} | ||
} else if (rxIsNumInt(method)){ | ||
IntegerVector tmp = as<IntegerVector>(method); | ||
oldEvid = IntegerVector(tmp.size()); | ||
for (int jj = tmp.size(); jj--;){ | ||
// (1 = replace, 2 = add, 3 = multiply) | ||
if (tmp[jj] == 1.){ | ||
oldEvid[jj] = 5; | ||
} else if (tmp[jj] == 2.){ | ||
oldEvid[jj] = 1; | ||
} else if (tmp[jj] == 3.){ | ||
oldEvid[jj] = 6; | ||
} | ||
} | ||
} | ||
return oldEvid; | ||
} | ||
#endif |
Oops, something went wrong.