mirror of
https://github.com/msberends/AMR.git
synced 2025-07-25 17:45:45 +02:00
speed improvements
This commit is contained in:
@ -6,36 +6,36 @@
|
||||
using namespace Rcpp;
|
||||
|
||||
// rsi_calc_S
|
||||
int rsi_calc_S(std::vector<double> x, bool include_I);
|
||||
int rsi_calc_S(DoubleVector x, bool include_I);
|
||||
RcppExport SEXP _AMR_rsi_calc_S(SEXP xSEXP, SEXP include_ISEXP) {
|
||||
BEGIN_RCPP
|
||||
Rcpp::RObject rcpp_result_gen;
|
||||
Rcpp::RNGScope rcpp_rngScope_gen;
|
||||
Rcpp::traits::input_parameter< std::vector<double> >::type x(xSEXP);
|
||||
Rcpp::traits::input_parameter< DoubleVector >::type x(xSEXP);
|
||||
Rcpp::traits::input_parameter< bool >::type include_I(include_ISEXP);
|
||||
rcpp_result_gen = Rcpp::wrap(rsi_calc_S(x, include_I));
|
||||
return rcpp_result_gen;
|
||||
END_RCPP
|
||||
}
|
||||
// rsi_calc_R
|
||||
int rsi_calc_R(std::vector<double> x, bool include_I);
|
||||
int rsi_calc_R(DoubleVector x, bool include_I);
|
||||
RcppExport SEXP _AMR_rsi_calc_R(SEXP xSEXP, SEXP include_ISEXP) {
|
||||
BEGIN_RCPP
|
||||
Rcpp::RObject rcpp_result_gen;
|
||||
Rcpp::RNGScope rcpp_rngScope_gen;
|
||||
Rcpp::traits::input_parameter< std::vector<double> >::type x(xSEXP);
|
||||
Rcpp::traits::input_parameter< DoubleVector >::type x(xSEXP);
|
||||
Rcpp::traits::input_parameter< bool >::type include_I(include_ISEXP);
|
||||
rcpp_result_gen = Rcpp::wrap(rsi_calc_R(x, include_I));
|
||||
return rcpp_result_gen;
|
||||
END_RCPP
|
||||
}
|
||||
// rsi_calc_total
|
||||
int rsi_calc_total(std::vector<double> x);
|
||||
int rsi_calc_total(DoubleVector x);
|
||||
RcppExport SEXP _AMR_rsi_calc_total(SEXP xSEXP) {
|
||||
BEGIN_RCPP
|
||||
Rcpp::RObject rcpp_result_gen;
|
||||
Rcpp::RNGScope rcpp_rngScope_gen;
|
||||
Rcpp::traits::input_parameter< std::vector<double> >::type x(xSEXP);
|
||||
Rcpp::traits::input_parameter< DoubleVector >::type x(xSEXP);
|
||||
rcpp_result_gen = Rcpp::wrap(rsi_calc_total(x));
|
||||
return rcpp_result_gen;
|
||||
END_RCPP
|
||||
|
@ -1,12 +1,11 @@
|
||||
#include <Rcpp.h>
|
||||
#include <vector> // for std::vector
|
||||
#include <functional> // for std::less, etc
|
||||
#include <algorithm> // for count_if
|
||||
|
||||
using namespace Rcpp ;
|
||||
using namespace Rcpp;
|
||||
|
||||
// [[Rcpp::export]]
|
||||
int rsi_calc_S(std::vector<double> x, bool include_I) {
|
||||
int rsi_calc_S(DoubleVector x, bool include_I) {
|
||||
if (include_I == TRUE) {
|
||||
return count_if(x.begin(), x.end(), bind2nd(std::less_equal<double>(), 2));
|
||||
} else {
|
||||
@ -15,7 +14,7 @@ int rsi_calc_S(std::vector<double> x, bool include_I) {
|
||||
}
|
||||
|
||||
// [[Rcpp::export]]
|
||||
int rsi_calc_R(std::vector<double> x, bool include_I) {
|
||||
int rsi_calc_R(DoubleVector x, bool include_I) {
|
||||
if (include_I == TRUE) {
|
||||
return count_if(x.begin(), x.end(), bind2nd(std::greater_equal<double>(), 2));
|
||||
} else {
|
||||
@ -24,6 +23,6 @@ int rsi_calc_R(std::vector<double> x, bool include_I) {
|
||||
}
|
||||
|
||||
// [[Rcpp::export]]
|
||||
int rsi_calc_total(std::vector<double> x) {
|
||||
return count_if(x.begin(), x.end(), bind2nd(std::less_equal<double>(), 3));
|
||||
int rsi_calc_total(DoubleVector x) {
|
||||
return count_if(x.begin(), x.end(), bind2nd(std::less_equal<double>(), 3));
|
||||
}
|
||||
|
Reference in New Issue
Block a user