From 201ffe51622b88b2c118bc6df2cf8787c49d0c2f Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Tue, 22 Oct 2024 14:05:11 +0200 Subject: [PATCH] Added placeholder `UpdateRPlee11_cpp() (#11) --- R/RcppExports.R | 4 ++++ R/UpdateRPlee11.R | 5 +++++ src/RcppExports.cpp | 16 ++++++++++++++++ src/UpdateRPlee11_cpp.cpp | 18 ++++++++++++++++++ src/init.c | 2 ++ 5 files changed, 45 insertions(+) create mode 100644 src/UpdateRPlee11_cpp.cpp diff --git a/R/RcppExports.R b/R/RcppExports.R index 864264a..efb2372 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -5,6 +5,10 @@ UpdateGamma_cpp <- function(sobj, hyperpar, ini, S, method, MRF_G, MRF_2b) { .Call(`_BayesSurvive_UpdateGamma_cpp`, sobj, hyperpar, ini, S, method, MRF_G, MRF_2b) } +UpdateRPlee11_cpp <- function(sobj, hyperpar, ini, S, method, MRF_G) { + .Call(`_BayesSurvive_UpdateRPlee11_cpp`, sobj, hyperpar, ini, S, method, MRF_G) +} + func_MCMC_graph_cpp <- function(sobj, hyperpar, ini, S, method, MRF_2b) { .Call(`_BayesSurvive_func_MCMC_graph_cpp`, sobj, hyperpar, ini, S, method, MRF_2b) } diff --git a/R/UpdateRPlee11.R b/R/UpdateRPlee11.R index dcb0aae..8a29f25 100755 --- a/R/UpdateRPlee11.R +++ b/R/UpdateRPlee11.R @@ -7,12 +7,17 @@ #' #' @inheritParams BayesSurvive #' @inheritParams func_MCMC +#' @inheritParams func_MCMC_graph #' #' @return A list object with component 'beta.ini' for the updated coefficients #' and component 'acceptlee' for the MCMC acceptance rate #' #' @export UpdateRPlee11 <- function(sobj, hyperpar, ini, S, method, MRF_G, cpp = FALSE) { + if (cpp) { + warning("Cpp not implemented. Rerouting to R implementation.") + return(UpdateRPlee11(sobj, hyperpar, ini, S, method, MRF_G)) + } p <- sobj$p tau <- hyperpar$tau cb <- hyperpar$cb diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index b8513b1..f7659d4 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -28,6 +28,22 @@ BEGIN_RCPP return rcpp_result_gen; END_RCPP } +// UpdateRPlee11_cpp +Rcpp::List UpdateRPlee11_cpp(const Rcpp::List sobj, const Rcpp::List hyperpar, const Rcpp::List ini, const uint S, const std::string method, const bool MRF_G); +RcppExport SEXP _BayesSurvive_UpdateRPlee11_cpp(SEXP sobjSEXP, SEXP hyperparSEXP, SEXP iniSEXP, SEXP SSEXP, SEXP methodSEXP, SEXP MRF_GSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::RNGScope rcpp_rngScope_gen; + Rcpp::traits::input_parameter< const Rcpp::List >::type sobj(sobjSEXP); + Rcpp::traits::input_parameter< const Rcpp::List >::type hyperpar(hyperparSEXP); + Rcpp::traits::input_parameter< const Rcpp::List >::type ini(iniSEXP); + Rcpp::traits::input_parameter< const uint >::type S(SSEXP); + Rcpp::traits::input_parameter< const std::string >::type method(methodSEXP); + Rcpp::traits::input_parameter< const bool >::type MRF_G(MRF_GSEXP); + rcpp_result_gen = Rcpp::wrap(UpdateRPlee11_cpp(sobj, hyperpar, ini, S, method, MRF_G)); + return rcpp_result_gen; +END_RCPP +} // func_MCMC_graph_cpp Rcpp::List func_MCMC_graph_cpp(const Rcpp::List sobj, const Rcpp::List hyperpar, const Rcpp::List ini, const uint S, const std::string method, const bool MRF_2b); RcppExport SEXP _BayesSurvive_func_MCMC_graph_cpp(SEXP sobjSEXP, SEXP hyperparSEXP, SEXP iniSEXP, SEXP SSEXP, SEXP methodSEXP, SEXP MRF_2bSEXP) { diff --git a/src/UpdateRPlee11_cpp.cpp b/src/UpdateRPlee11_cpp.cpp new file mode 100644 index 0000000..dccb943 --- /dev/null +++ b/src/UpdateRPlee11_cpp.cpp @@ -0,0 +1,18 @@ +#include +#include "misc.h" +// [[Rcpp::depends(RcppArmadillo)]] +// [[Rcpp::export]] +Rcpp::List UpdateRPlee11_cpp( + const Rcpp::List sobj, + const Rcpp::List hyperpar, + const Rcpp::List ini, + const uint S, + const std::string method, + const bool MRF_G +){ + Rcpp::List out = Rcpp::List::create( + Rcpp::Named("beta.ini") = NA_REAL, // TEMP + Rcpp::Named("acceptlee") = NA_REAL // TEMP + ); + return out; +} diff --git a/src/init.c b/src/init.c index 678030f..0d9e72c 100644 --- a/src/init.c +++ b/src/init.c @@ -17,6 +17,7 @@ extern SEXP _BayesSurvive_updateRP_genomic_cpp(SEXP, SEXP, SEXP, SEXP, SEXP, SEX extern SEXP _BayesSurvive_func_MCMC_graph_cpp(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP _BayesSurvive_UpdateGamma_cpp(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP _BayesSurvive_list_to_matrix(SEXP); +extern SEXP _BayesSurvive_UpdateRPlee11_cpp(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); static const R_CallMethodDef CallEntries[] = { {"_BayesSurvive_calJpost_helper_cpp", (DL_FUNC) &_BayesSurvive_calJpost_helper_cpp, 9}, @@ -28,6 +29,7 @@ static const R_CallMethodDef CallEntries[] = { {"_BayesSurvive_func_MCMC_graph_cpp", (DL_FUNC) &_BayesSurvive_func_MCMC_graph_cpp, 6}, {"_BayesSurvive_UpdateGamma_cpp", (DL_FUNC) &_BayesSurvive_UpdateGamma_cpp, 7}, {"_BayesSurvive_list_to_matrix", (DL_FUNC) &_BayesSurvive_list_to_matrix, 1}, + {"_BayesSurvive_UpdateRPlee11_cpp", (DL_FUNC) &_BayesSurvive_UpdateRPlee11_cpp, 6}, {NULL, NULL, 0} };