diff --git a/R/RcppExports.R b/R/RcppExports.R index 97659764..7edbefd2 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -149,8 +149,8 @@ popedSetup <- function(e, full) { .Call(`_babelmixr2_popedSetup`, e, full) } -popedSolveIdME <- function(theta, umt, mt, ms, nend, id, totn) { - .Call(`_babelmixr2_popedSolveIdME`, theta, umt, mt, ms, nend, id, totn) +popedSolveIdME <- function(theta, id) { + .Call(`_babelmixr2_popedSolveIdME`, theta, id) } popedSolveIdME2 <- function(theta, umt, mt, ms, nend, id, totn) { diff --git a/R/poped.R b/R/poped.R index 861124fa..5bcef56f 100644 --- a/R/poped.R +++ b/R/poped.R @@ -42,8 +42,8 @@ #' @export #' @author Matthew L. Fidler #' @keywords internal -.popedSolveIdME <- function(theta, umt, mt, ms, nend, id, totn) { - .Call(`_babelmixr2_popedSolveIdME`, theta, umt, mt, ms, nend, id, totn) +.popedSolveIdME <- function(theta, id) { + .Call(`_babelmixr2_popedSolveIdME`, theta, id) } #' @rdname dot-popedSolveIdME @@ -340,8 +340,7 @@ rxUiGet.popedFfFun <- function(x, ...) { .(.poped$maxn), poped.db$babelmixr2$optTime) .popedRxRunSetup(poped.db) - .ret <- .popedSolveIdME(.p, .u, .xt, model_switch, .(length(.predDf$cond)), - .id-1, .totn) + .ret <- .popedSolveIdME(.p, .id-1) } else if (.lu > .(.poped$maxn)) { .p <- p[-1] .popedRxRunFullSetupMe(poped.db, .xt, model_switch) diff --git a/inst/poped/ex.1.a.PK.1.comp.oral.md.intro.babelmixr2.R b/inst/poped/ex.1.a.PK.1.comp.oral.md.intro.babelmixr2.R index ea8a5a87..6823e886 100644 --- a/inst/poped/ex.1.a.PK.1.comp.oral.md.intro.babelmixr2.R +++ b/inst/poped/ex.1.a.PK.1.comp.oral.md.intro.babelmixr2.R @@ -46,6 +46,16 @@ e <- et(list(c(0, 10), #xt e$time <- c(1,2,8,240,245) +f <- f() + +babel.db <- nlmixr2(f, e, "poped", + popedControl(groupsize=20, + bUseGrouped_xt=TRUE, + a=list(c(DOSE=20,TAU=24), + c(DOSE=40, TAU=24)), + maxa=c(DOSE=200,TAU=24), + mina=c(DOSE=0,TAU=24), + script=TRUE)) babel.db <- nlmixr2(f, e, "poped", popedControl(groupsize=20, diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index abe37bda..99a87787 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -106,19 +106,14 @@ BEGIN_RCPP END_RCPP } // popedSolveIdME -Rcpp::DataFrame popedSolveIdME(NumericVector& theta, NumericVector& umt, NumericVector& mt, IntegerVector& ms, int nend, int id, int totn); -RcppExport SEXP _babelmixr2_popedSolveIdME(SEXP thetaSEXP, SEXP umtSEXP, SEXP mtSEXP, SEXP msSEXP, SEXP nendSEXP, SEXP idSEXP, SEXP totnSEXP) { +Rcpp::DataFrame popedSolveIdME(NumericVector& theta, int id); +RcppExport SEXP _babelmixr2_popedSolveIdME(SEXP thetaSEXP, SEXP idSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::RNGScope rcpp_rngScope_gen; Rcpp::traits::input_parameter< NumericVector& >::type theta(thetaSEXP); - Rcpp::traits::input_parameter< NumericVector& >::type umt(umtSEXP); - Rcpp::traits::input_parameter< NumericVector& >::type mt(mtSEXP); - Rcpp::traits::input_parameter< IntegerVector& >::type ms(msSEXP); - Rcpp::traits::input_parameter< int >::type nend(nendSEXP); Rcpp::traits::input_parameter< int >::type id(idSEXP); - Rcpp::traits::input_parameter< int >::type totn(totnSEXP); - rcpp_result_gen = Rcpp::wrap(popedSolveIdME(theta, umt, mt, ms, nend, id, totn)); + rcpp_result_gen = Rcpp::wrap(popedSolveIdME(theta, id)); return rcpp_result_gen; END_RCPP } diff --git a/src/init.c b/src/init.c index f26569b5..fd8d2244 100644 --- a/src/init.c +++ b/src/init.c @@ -14,7 +14,7 @@ SEXP _babelmixr2_iniRxodePtrs(SEXP in); SEXP _babelmixr2_popedFree(void); SEXP _babelmixr2_popedSetup(SEXP eSEXP, SEXP fullSEXP); -SEXP _babelmixr2_popedSolveIdME(SEXP thetaSEXP, SEXP umtSEXP, SEXP mtSEXP, SEXP msSEXP, SEXP nendSEXP, SEXP idSEXP, SEXP totnSEXP); +SEXP _babelmixr2_popedSolveIdME(SEXP thetaSEXP, SEXP idSEXP); SEXP _babelmixr2_popedSolveIdME2(SEXP thetaSEXP, SEXP umtSEXP, SEXP mtSEXP, SEXP msSEXP, SEXP nendSEXP, SEXP idSEXP, SEXP totnSEXP); SEXP _babelmixr2_popedGetMultipleEndpointModelingTimes(SEXP, SEXP, SEXP); SEXP _babelmixr2_popedMultipleEndpointResetTimeIndex(void); @@ -30,7 +30,7 @@ static const R_CallMethodDef CallEntries[] = { (DL_FUNC) &_babelmixr2_popedGetMultipleEndpointModelingTimes, 3}, {"_babelmixr2_popedFree", (DL_FUNC) &_babelmixr2_popedFree, 0}, {"_babelmixr2_popedSetup", (DL_FUNC) &_babelmixr2_popedSetup, 2}, - {"_babelmixr2_popedSolveIdME", (DL_FUNC) &_babelmixr2_popedSolveIdME, 7}, + {"_babelmixr2_popedSolveIdME", (DL_FUNC) &_babelmixr2_popedSolveIdME, 2}, {"_babelmixr2_popedSolveIdME2", (DL_FUNC) &_babelmixr2_popedSolveIdME2, 7}, {"_babelmixr2_iniRxodePtrs", (DL_FUNC) &_babelmixr2_iniRxodePtrs, 1}, {"_babelmixr2_convertDataBack", (DL_FUNC) &_babelmixr2_convertDataBack, 13}, diff --git a/src/poped.cpp b/src/poped.cpp index b3116229..82d94651 100644 --- a/src/poped.cpp +++ b/src/poped.cpp @@ -491,15 +491,14 @@ void popedSolveFidMat(arma::mat &matMT, NumericVector &theta, int id, int nrow, } //[[Rcpp::export]] -Rcpp::DataFrame popedSolveIdME(NumericVector &theta, - NumericVector &umt, - NumericVector &mt, IntegerVector &ms, - int nend, int id, int totn) { +Rcpp::DataFrame popedSolveIdME(NumericVector &theta, int id) { if (solveCached(theta, id)) return(as(_popedE["s"])); + size_t totn = globalTimeIndexer.getTimes().size(); + size_t nend = globalTimeIndexer.getNid(); NumericVector t(totn); arma::vec f(totn); arma::vec w(totn); - int nrow = umt.size(); + size_t nrow = globalTimeIndexer.getUniqueTimes().size();//umt.size(); arma::mat matMT(nrow, nend*2+1); List we(nend); for (int i = 0; i < nend; i++) { @@ -525,13 +524,12 @@ Rcpp::DataFrame popedSolveIdME(NumericVector &theta, // This is not how rxode2/nlmixr2 handles the information, but this // routine should put it in whatever order is supplied to // model_switch and time - size_t nId = globalTimeIndexer.getNid(); std::vector ut = globalTimeIndexer.getUniqueTimes(); for (int i = 0; i < (int)ut.size(); ++i) { double curT = matMT(i, 0); const auto& infos= globalTimeIndexer.getTimeInfo(curT); for (const auto& info : infos) { - if (info.id > (int)nId || + if (info.id > (int)nend || info.id <= 0) { Rcpp::stop("modelSwitch need to be sequential 1, 2, 3, ..., n"); } @@ -542,8 +540,9 @@ Rcpp::DataFrame popedSolveIdME(NumericVector &theta, } } } - DataFrame ret = DataFrame::create(_["t"]=mt, - _["ms"]=ms, + DataFrame ret = DataFrame::create(_["t"]=Rcpp::wrap(globalTimeIndexer.getTimes()), + _["ms"]= + Rcpp::wrap(globalTimeIndexer.getModelSwitch()), _["rx_pred_"]=f, // match rxode2/nlmixr2 to simplify code of mtime models _["w"]=w); // w = sqrt(rx_r_) _popedE["s"] = ret;