diff --git a/NAMESPACE b/NAMESPACE index 5cf50cf3d..2a66d8860 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -419,6 +419,7 @@ export(rxShiny) export(rxSimThetaOmega) export(rxSolve) export(rxSolveFree) +export(rxSolveSetup) export(rxSplitPlusQ) export(rxStack) export(rxState) diff --git a/R/RcppExports.R b/R/RcppExports.R index 59c0374ac..833a9ec94 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -311,6 +311,16 @@ rxSolveFree <- function() { .Call(`_rxode2_rxSolveFree`) } +#' See if the memory is installed for a solve +#' +#' @return boolean saying if the memnory is currently free for rxode2 +#' @keywords internal +#' @export +#' @author Matthew L. Fidler +rxSolveSetup <- function() { + .Call(`_rxode2_rxSolveSetup`) +} + rxSolve_ <- function(obj, rxControl, specParams, extraArgs, params, events, inits, setupOnly) { .Call(`_rxode2_rxSolve_`, obj, rxControl, specParams, extraArgs, params, events, inits, setupOnly) } diff --git a/inst/include/rxode2_RcppExports.h b/inst/include/rxode2_RcppExports.h index 5b79439d4..24ad0029f 100644 --- a/inst/include/rxode2_RcppExports.h +++ b/inst/include/rxode2_RcppExports.h @@ -445,6 +445,27 @@ namespace rxode2 { return Rcpp::as(rcpp_result_gen); } + inline LogicalVector rxSolveSetup() { + typedef SEXP(*Ptr_rxSolveSetup)(); + static Ptr_rxSolveSetup p_rxSolveSetup = NULL; + if (p_rxSolveSetup == NULL) { + validateSignature("LogicalVector(*rxSolveSetup)()"); + p_rxSolveSetup = (Ptr_rxSolveSetup)R_GetCCallable("rxode2", "_rxode2_rxSolveSetup"); + } + RObject rcpp_result_gen; + { + RNGScope RCPP_rngScope_gen; + rcpp_result_gen = p_rxSolveSetup(); + } + if (rcpp_result_gen.inherits("interrupted-error")) + throw Rcpp::internal::InterruptedException(); + if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) + throw Rcpp::LongjumpException(rcpp_result_gen); + if (rcpp_result_gen.inherits("try-error")) + throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); + return Rcpp::as(rcpp_result_gen); + } + inline SEXP rxSolve_(const RObject& obj, const List& rxControl, const Nullable& specParams, const Nullable& extraArgs, const RObject& params, const RObject& events, const RObject& inits, const int setupOnly) { typedef SEXP(*Ptr_rxSolve_)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_rxSolve_ p_rxSolve_ = NULL; diff --git a/man/rxSolveSetup.Rd b/man/rxSolveSetup.Rd new file mode 100644 index 000000000..c96e457ac --- /dev/null +++ b/man/rxSolveSetup.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/RcppExports.R +\name{rxSolveSetup} +\alias{rxSolveSetup} +\title{See if the memory is installed for a solve} +\usage{ +rxSolveSetup() +} +\value{ +boolean saying if the memnory is currently free for rxode2 +} +\description{ +See if the memory is installed for a solve +} +\author{ +Matthew L. Fidler +} +\keyword{internal} diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index 796b4ba1d..5d7406763 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -773,6 +773,39 @@ RcppExport SEXP _rxode2_rxSolveFree() { UNPROTECT(1); return rcpp_result_gen; } +// rxSolveSetup +LogicalVector rxSolveSetup(); +static SEXP _rxode2_rxSolveSetup_try() { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + rcpp_result_gen = Rcpp::wrap(rxSolveSetup()); + return rcpp_result_gen; +END_RCPP_RETURN_ERROR +} +RcppExport SEXP _rxode2_rxSolveSetup() { + SEXP rcpp_result_gen; + { + Rcpp::RNGScope rcpp_rngScope_gen; + rcpp_result_gen = PROTECT(_rxode2_rxSolveSetup_try()); + } + Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); + if (rcpp_isInterrupt_gen) { + UNPROTECT(1); + Rf_onintr(); + } + bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); + if (rcpp_isLongjump_gen) { + Rcpp::internal::resumeJump(rcpp_result_gen); + } + Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); + if (rcpp_isError_gen) { + SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); + UNPROTECT(1); + Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); + } + UNPROTECT(1); + return rcpp_result_gen; +} // rxSolve_ SEXP rxSolve_(const RObject& obj, const List& rxControl, const Nullable& specParams, const Nullable& extraArgs, const RObject& params, const RObject& events, const RObject& inits, const int setupOnly); static SEXP _rxode2_rxSolve__try(SEXP objSEXP, SEXP rxControlSEXP, SEXP specParamsSEXP, SEXP extraArgsSEXP, SEXP paramsSEXP, SEXP eventsSEXP, SEXP initsSEXP, SEXP setupOnlySEXP) { @@ -1966,6 +1999,7 @@ static int _rxode2_RcppExport_validate(const char* sig) { signatures.insert("void(*atolRtolFactor_)(double)"); signatures.insert("List(*rxSimThetaOmega)(const Nullable&,const RObject&,const Nullable&,const NumericVector&,const NumericVector&,const bool&,std::string,const int,int,const Nullable&,const NumericVector&,const NumericVector&,const Nullable&,const bool&,int,const RObject,const NumericVector&,const NumericVector&,const Nullable&,const bool&,std::string,const int,int,int,double,double,bool,const LogicalVector&)"); signatures.insert("LogicalVector(*rxSolveFree)()"); + signatures.insert("LogicalVector(*rxSolveSetup)()"); signatures.insert("SEXP(*rxSolve_)(const RObject&,const List&,const Nullable&,const Nullable&,const RObject&,const RObject&,const RObject&,const int)"); signatures.insert("CharacterVector(*rxSolveDollarNames)(RObject)"); signatures.insert("RObject(*rxSolveGet)(RObject,RObject,LogicalVector)"); @@ -2025,6 +2059,7 @@ RcppExport SEXP _rxode2_RcppExport_registerCCallable() { R_RegisterCCallable("rxode2", "_rxode2_atolRtolFactor_", (DL_FUNC)_rxode2_atolRtolFactor__try); R_RegisterCCallable("rxode2", "_rxode2_rxSimThetaOmega", (DL_FUNC)_rxode2_rxSimThetaOmega_try); R_RegisterCCallable("rxode2", "_rxode2_rxSolveFree", (DL_FUNC)_rxode2_rxSolveFree_try); + R_RegisterCCallable("rxode2", "_rxode2_rxSolveSetup", (DL_FUNC)_rxode2_rxSolveSetup_try); R_RegisterCCallable("rxode2", "_rxode2_rxSolve_", (DL_FUNC)_rxode2_rxSolve__try); R_RegisterCCallable("rxode2", "_rxode2_rxSolveDollarNames", (DL_FUNC)_rxode2_rxSolveDollarNames_try); R_RegisterCCallable("rxode2", "_rxode2_rxSolveGet", (DL_FUNC)_rxode2_rxSolveGet_try); diff --git a/src/rxData.cpp b/src/rxData.cpp index 265dca3d7..e253b628a 100644 --- a/src/rxData.cpp +++ b/src/rxData.cpp @@ -1362,6 +1362,8 @@ struct rx_globals { // time per thread double *timeThread = NULL; + + bool alloc=false; }; @@ -1554,6 +1556,7 @@ extern "C" void gFree(){ _globals.gcov=NULL; if (_rxGetErrs != NULL) free(_rxGetErrs); _rxGetErrs=NULL; + _globals.alloc = false; } extern "C" double *rxGetErrs(){ @@ -4049,6 +4052,7 @@ static inline void rxSolve_normalizeParms(const RObject &obj, const List &rxCont } } } + _globals.alloc = true; break; default: rxSolveFree(); @@ -4056,6 +4060,17 @@ static inline void rxSolve_normalizeParms(const RObject &obj, const List &rxCont } } +//' See if the memory is installed for a solve +//' +//' @return boolean saying if the memnory is currently free for rxode2 +//' @keywords internal +//' @export +//' @author Matthew L. Fidler +//[[Rcpp::export]] +LogicalVector rxSolveSetup() { + return _globals.alloc; +} + // This creates the final dataset from the currently solved object. // Most of this is a direct C call, but some items are done in C++ List rxSolve_df(const RObject &obj,