Skip to content

Commit

Permalink
Revert "Reduce arguments in preparation for DRY script indexer use"
Browse files Browse the repository at this point in the history
This reverts commit 7f29919.
  • Loading branch information
mattfidler committed Sep 23, 2024
1 parent 563bbe8 commit bebad0e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 28 deletions.
4 changes: 2 additions & 2 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ popedSetup <- function(e, full) {
.Call(`_babelmixr2_popedSetup`, e, full)
}

popedSolveIdME <- function(theta, id) {
.Call(`_babelmixr2_popedSolveIdME`, theta, id)
popedSolveIdME <- function(theta, umt, mt, ms, nend, id, totn) {
.Call(`_babelmixr2_popedSolveIdME`, theta, umt, mt, ms, nend, id, totn)
}

popedSolveIdME2 <- function(theta, umt, mt, ms, nend, id, totn) {
Expand Down
7 changes: 4 additions & 3 deletions R/poped.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
#' @export
#' @author Matthew L. Fidler
#' @keywords internal
.popedSolveIdME <- function(theta, id) {
.Call(`_babelmixr2_popedSolveIdME`, theta, id)
.popedSolveIdME <- function(theta, umt, mt, ms, nend, id, totn) {
.Call(`_babelmixr2_popedSolveIdME`, theta, umt, mt, ms, nend, id, totn)
}

#' @rdname dot-popedSolveIdME
Expand Down Expand Up @@ -340,7 +340,8 @@ rxUiGet.popedFfFun <- function(x, ...) {
.(.poped$maxn),
poped.db$babelmixr2$optTime)
.popedRxRunSetup(poped.db)
.ret <- .popedSolveIdME(.p, .id-1)
.ret <- .popedSolveIdME(.p, .u, .xt, model_switch, .(length(.predDf$cond)),
.id-1, .totn)
} else if (.lu > .(.poped$maxn)) {
.p <- p[-1]
.popedRxRunFullSetupMe(poped.db, .xt, model_switch)
Expand Down
10 changes: 0 additions & 10 deletions inst/poped/ex.1.a.PK.1.comp.oral.md.intro.babelmixr2.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@ 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,
Expand Down
11 changes: 8 additions & 3 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,19 @@ BEGIN_RCPP
END_RCPP
}
// popedSolveIdME
Rcpp::DataFrame popedSolveIdME(NumericVector& theta, int id);
RcppExport SEXP _babelmixr2_popedSolveIdME(SEXP thetaSEXP, SEXP idSEXP) {
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) {
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_result_gen = Rcpp::wrap(popedSolveIdME(theta, id));
Rcpp::traits::input_parameter< int >::type totn(totnSEXP);
rcpp_result_gen = Rcpp::wrap(popedSolveIdME(theta, umt, mt, ms, nend, id, totn));
return rcpp_result_gen;
END_RCPP
}
Expand Down
4 changes: 2 additions & 2 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 idSEXP);
SEXP _babelmixr2_popedSolveIdME(SEXP thetaSEXP, SEXP umtSEXP, SEXP mtSEXP, SEXP msSEXP, SEXP nendSEXP, SEXP idSEXP, SEXP totnSEXP);
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);
Expand All @@ -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, 2},
{"_babelmixr2_popedSolveIdME", (DL_FUNC) &_babelmixr2_popedSolveIdME, 7},
{"_babelmixr2_popedSolveIdME2", (DL_FUNC) &_babelmixr2_popedSolveIdME2, 7},
{"_babelmixr2_iniRxodePtrs", (DL_FUNC) &_babelmixr2_iniRxodePtrs, 1},
{"_babelmixr2_convertDataBack", (DL_FUNC) &_babelmixr2_convertDataBack, 13},
Expand Down
17 changes: 9 additions & 8 deletions src/poped.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,14 +491,15 @@ void popedSolveFidMat(arma::mat &matMT, NumericVector &theta, int id, int nrow,
}

//[[Rcpp::export]]
Rcpp::DataFrame popedSolveIdME(NumericVector &theta, int id) {
Rcpp::DataFrame popedSolveIdME(NumericVector &theta,
NumericVector &umt,
NumericVector &mt, IntegerVector &ms,
int nend, int id, int totn) {
if (solveCached(theta, id)) return(as<Rcpp::DataFrame>(_popedE["s"]));
size_t totn = globalTimeIndexer.getTimes().size();
size_t nend = globalTimeIndexer.getNid();
NumericVector t(totn);
arma::vec f(totn);
arma::vec w(totn);
size_t nrow = globalTimeIndexer.getUniqueTimes().size();//umt.size();
int nrow = umt.size();
arma::mat matMT(nrow, nend*2+1);
List we(nend);
for (int i = 0; i < nend; i++) {
Expand All @@ -524,12 +525,13 @@ Rcpp::DataFrame popedSolveIdME(NumericVector &theta, int id) {
// 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<double> 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)nend ||
if (info.id > (int)nId ||
info.id <= 0) {
Rcpp::stop("modelSwitch need to be sequential 1, 2, 3, ..., n");
}
Expand All @@ -540,9 +542,8 @@ Rcpp::DataFrame popedSolveIdME(NumericVector &theta, int id) {
}
}
}
DataFrame ret = DataFrame::create(_["t"]=Rcpp::wrap(globalTimeIndexer.getTimes()),
_["ms"]=
Rcpp::wrap(globalTimeIndexer.getModelSwitch()),
DataFrame ret = DataFrame::create(_["t"]=mt,
_["ms"]=ms,
_["rx_pred_"]=f, // match rxode2/nlmixr2 to simplify code of mtime models
_["w"]=w); // w = sqrt(rx_r_)
_popedE["s"] = ret;
Expand Down

0 comments on commit bebad0e

Please sign in to comment.