Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split out ini and sorting before ode solving #457

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion inst/include/RxODE.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ typedef struct {
double *simIni;
int isIni;
int _update_par_ptr_in;
int badIni;
int ini;
} rx_solving_options_ind;

typedef struct {
Expand Down
17 changes: 13 additions & 4 deletions src/par_solve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,13 @@ extern "C" int iniSubjectE(int solveid, int inLhs, rx_solving_options_ind *ind,
return iniSubject(solveid, inLhs, ind, op, rx, u_inis);
}

static inline void iniAllSubjectsForODE(rx_solve *rx) {
for (int solveid = 0; solveid < rx->nsim*rx->nsub; solveid++){
rx_solving_options_ind *ind = &(rx->subjects[solveid]);
ind->ini = iniSubject(solveid, 0, ind, rx->op, rx, update_inis);
}
}

static void chkIntFn(void *dummy) {
R_CheckUserInterrupt();
}
Expand Down Expand Up @@ -1194,7 +1201,7 @@ extern "C" void ind_indLin0(rx_solve *rx, rx_solving_options *op, int solveid,
inits = op->inits;
int idid = 0;
ind = &(rx->subjects[neq[1]]);
if (!iniSubject(neq[1], 0, ind, op, rx, u_inis)) return;
if (!ind->ini) return;
nx = ind->n_all_times;
BadDose = ind->BadDose;
InfusionRate = ind->InfusionRate;
Expand Down Expand Up @@ -1326,7 +1333,7 @@ extern "C" void ind_liblsoda0(rx_solve *rx, rx_solving_options *op, struct lsoda
ctx->state = 1;
ctx->error=NULL;
ind = &(rx->subjects[neq[1]]);
if (!iniSubject(neq[1], 0, ind, op, rx, u_inis)) {
if (!ind->ini) {
free(ctx);
ctx = NULL;
return;
Expand Down Expand Up @@ -1675,7 +1682,7 @@ extern "C" void ind_lsoda0(rx_solve *rx, rx_solving_options *op, int solveid, in
double xp = ind->all_times[0];
double xout;

if (!iniSubject(neq[1], 0, ind, op, rx, u_inis)) return;
if (!ind->ini) return;
unsigned int j;
for(i=0; i < ind->n_all_times; i++) {
ind->idx=i;
Expand Down Expand Up @@ -1813,7 +1820,7 @@ extern "C" void ind_dop0(rx_solve *rx, rx_solving_options *op, int solveid, int
int nx;
neq[1] = solveid;
ind = &(rx->subjects[neq[1]]);
if (!iniSubject(neq[1], 0, ind, op, rx, u_inis)) return;
if (!ind->ini) return;
nx = ind->n_all_times;
inits = op->inits;
evid = ind->evid;
Expand Down Expand Up @@ -1960,6 +1967,7 @@ extern "C" void ind_solve(rx_solve *rx, unsigned int cid,
rxt.cur = 0;
assignFuns();
rx_solving_options *op = &op_global;
iniAllSubjectsForODE(rx);
if (op->neq != 0){
switch (op->stiff){
case 3:
Expand Down Expand Up @@ -1990,6 +1998,7 @@ extern "C" void par_solve(rx_solve *rx){
rxt.d = 0;
rxt.cur = 0;
assignFuns();
iniAllSubjectsForODE(rx);
rx_solving_options *op = &op_global;
if (op->neq != 0){
switch(op->stiff){
Expand Down