diff --git a/R/RcppExports.R b/R/RcppExports.R index 94b758a..b92d8d2 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -20,10 +20,6 @@ RHO_BOOT_Cpp <- function(x, B) { .Call('_INAr_RHO_BOOT_Cpp', PACKAGE = 'INAr', x, B) } -RHO_BOOT_Cpp_Parallel <- function(x, B, num_threads = 2L) { - .Call('_INAr_RHO_BOOT_Cpp_Parallel', PACKAGE = 'INAr', x, B, num_threads) -} - #' Sun-McCabe score statistic to test for dependence in an integer autoregressive process #' @param x NumericVector #' @param method unsigned int diff --git a/src/INARboot.cpp b/src/INARboot.cpp index 1aeb576..6acb056 100644 --- a/src/INARboot.cpp +++ b/src/INARboot.cpp @@ -80,75 +80,6 @@ NumericVector RHO_BOOT_Cpp(NumericVector x, int B){ } - -// -// ---------------------------------------------------------------------------- -// ---------------------------------------------------------------------------- -// ---------------------------------------------------------------------------- -// - -// testing the possibility to use a parallel version of the bootstrap -// WARNING: compilation error on Mac OS X -// -// // [[Rcpp::plugins(openmp)]] -// #include -// -// // [[Rcpp::export]] -// NumericVector RHO_BOOT_Cpp_Parallel(NumericVector x, int B, int num_threads = 2) { -// int n = x.length(); -// NumericVector s_temp(B); -// -// // Set the number of threads (optional, default is usually the number of cores) -// if(num_threads > 1 & num_threads <= omp_get_max_threads()){ -// omp_set_num_threads(num_threads); -// }else{ -// num_threads = 1; -// } -// -// #pragma omp parallel num_threads(num_threads) -// { -// // Each thread needs its own RNG -// RNGScope scope; -// -// #pragma omp for -// for(int i = 0; i < B; i++) { -// // simplified version for testing, to update using the correct do while loop -// NumericVector xb = RcppArmadillo::sample(x, n, true); -// s_temp[i] = RHO_Cpp(xb)[0]; -// } -// } -// -// return s_temp; -// } - - -// #include -// -// // Placeholder for the RHO_Cpp function, which you need to provide -// NumericVector RHO_Cpp(NumericVector x); -// -// // [[Rcpp::export]] -// NumericVector RHO_BOOT_Cpp_Parallel(NumericVector x, int B, int threads = 0) { -// int n = x.length(); -// NumericVector s_temp(B); -// -// // Set the number of threads (optional, default is usually the number of cores) -// if(threads > 0 & threads <= omp_get_max_threads()){ -// omp_set_num_threads(threads); -// }else{ -// omp_set_num_threads(1); -// } -// -// #pragma omp parallel for -// for(int i = 0; i < B; i++) { -// NumericVector xb = RcppArmadillo::sample(x, n, true); -// s_temp[i] = RHO_Cpp(xb)[0]; -// } -// -// return s_temp; -// } - - // // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- diff --git a/src/INARbootpar.cpp b/src/INARbootpar.cpp new file mode 100644 index 0000000..0a147b8 --- /dev/null +++ b/src/INARbootpar.cpp @@ -0,0 +1,61 @@ + +// testing the possibility to use a parallel version of the bootstrap +// WARNING: compilation error on Mac OS X +// +// // [[Rcpp::plugins(openmp)]] +// #include +// +// // [[Rcpp::export]] +// NumericVector RHO_BOOT_Cpp_Parallel(NumericVector x, int B, int num_threads = 2) { +// int n = x.length(); +// NumericVector s_temp(B); +// +// // Set the number of threads (optional, default is usually the number of cores) +// if(num_threads > 1 & num_threads <= omp_get_max_threads()){ +// omp_set_num_threads(num_threads); +// }else{ +// num_threads = 1; +// } +// +// #pragma omp parallel num_threads(num_threads) +// { +// // Each thread needs its own RNG +// RNGScope scope; +// +// #pragma omp for +// for(int i = 0; i < B; i++) { +// // simplified version for testing, to update using the correct do while loop +// NumericVector xb = RcppArmadillo::sample(x, n, true); +// s_temp[i] = RHO_Cpp(xb)[0]; +// } +// } +// +// return s_temp; +// } + + +// #include +// +// // Placeholder for the RHO_Cpp function, which you need to provide +// NumericVector RHO_Cpp(NumericVector x); +// +// // [[Rcpp::export]] +// NumericVector RHO_BOOT_Cpp_Parallel(NumericVector x, int B, int threads = 0) { +// int n = x.length(); +// NumericVector s_temp(B); +// +// // Set the number of threads (optional, default is usually the number of cores) +// if(threads > 0 & threads <= omp_get_max_threads()){ +// omp_set_num_threads(threads); +// }else{ +// omp_set_num_threads(1); +// } +// +// #pragma omp parallel for +// for(int i = 0; i < B; i++) { +// NumericVector xb = RcppArmadillo::sample(x, n, true); +// s_temp[i] = RHO_Cpp(xb)[0]; +// } +// +// return s_temp; +// } diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index 3931438..4eba111 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -34,19 +34,6 @@ BEGIN_RCPP return rcpp_result_gen; END_RCPP } -// RHO_BOOT_Cpp_Parallel -NumericVector RHO_BOOT_Cpp_Parallel(NumericVector x, int B, int num_threads); -RcppExport SEXP _INAr_RHO_BOOT_Cpp_Parallel(SEXP xSEXP, SEXP BSEXP, SEXP num_threadsSEXP) { -BEGIN_RCPP - Rcpp::RObject rcpp_result_gen; - Rcpp::RNGScope rcpp_rngScope_gen; - Rcpp::traits::input_parameter< NumericVector >::type x(xSEXP); - Rcpp::traits::input_parameter< int >::type B(BSEXP); - Rcpp::traits::input_parameter< int >::type num_threads(num_threadsSEXP); - rcpp_result_gen = Rcpp::wrap(RHO_BOOT_Cpp_Parallel(x, B, num_threads)); - return rcpp_result_gen; -END_RCPP -} // SMC_Cpp NumericVector SMC_Cpp(NumericVector x, unsigned int method); RcppExport SEXP _INAr_SMC_Cpp(SEXP xSEXP, SEXP methodSEXP) { @@ -212,7 +199,6 @@ END_RCPP static const R_CallMethodDef CallEntries[] = { {"_INAr_RHO_Cpp", (DL_FUNC) &_INAr_RHO_Cpp, 1}, {"_INAr_RHO_BOOT_Cpp", (DL_FUNC) &_INAr_RHO_BOOT_Cpp, 2}, - {"_INAr_RHO_BOOT_Cpp_Parallel", (DL_FUNC) &_INAr_RHO_BOOT_Cpp_Parallel, 3}, {"_INAr_SMC_Cpp", (DL_FUNC) &_INAr_SMC_Cpp, 2}, {"_INAr_SMC_semiparBOOT_Cpp", (DL_FUNC) &_INAr_SMC_semiparBOOT_Cpp, 3}, {"_INAr_SMC_parBOOT_Cpp", (DL_FUNC) &_INAr_SMC_parBOOT_Cpp, 3},