mirror of
https://github.com/msberends/AMR.git
synced 2025-07-25 17:45:45 +02:00
Welcome C++!
This commit is contained in:
54
src/RcppExports.cpp
Normal file
54
src/RcppExports.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
// Generated by using Rcpp::compileAttributes() -> do not edit by hand
|
||||
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
|
||||
|
||||
#include <Rcpp.h>
|
||||
|
||||
using namespace Rcpp;
|
||||
|
||||
// rsi_calc_S
|
||||
int rsi_calc_S(std::vector<double> 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< 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);
|
||||
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< 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);
|
||||
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_result_gen = Rcpp::wrap(rsi_calc_total(x));
|
||||
return rcpp_result_gen;
|
||||
END_RCPP
|
||||
}
|
||||
|
||||
static const R_CallMethodDef CallEntries[] = {
|
||||
{"_AMR_rsi_calc_S", (DL_FUNC) &_AMR_rsi_calc_S, 2},
|
||||
{"_AMR_rsi_calc_R", (DL_FUNC) &_AMR_rsi_calc_R, 2},
|
||||
{"_AMR_rsi_calc_total", (DL_FUNC) &_AMR_rsi_calc_total, 1},
|
||||
{NULL, NULL, 0}
|
||||
};
|
||||
|
||||
RcppExport void R_init_AMR(DllInfo *dll) {
|
||||
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
|
||||
R_useDynamicSymbols(dll, FALSE);
|
||||
}
|
29
src/rsi_calc.cpp
Normal file
29
src/rsi_calc.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#include <Rcpp.h>
|
||||
#include <vector> // for std::vector
|
||||
#include <functional> // for std::less, etc
|
||||
#include <algorithm> // for count_if
|
||||
|
||||
using namespace Rcpp ;
|
||||
|
||||
// [[Rcpp::export]]
|
||||
int rsi_calc_S(std::vector<double> x, bool include_I) {
|
||||
if (include_I == TRUE) {
|
||||
return count_if(x.begin(), x.end(), bind2nd(std::less_equal<double>(), 2));
|
||||
} else {
|
||||
return count_if(x.begin(), x.end(), bind2nd(std::less<double>(), 2));
|
||||
}
|
||||
}
|
||||
|
||||
// [[Rcpp::export]]
|
||||
int rsi_calc_R(std::vector<double> x, bool include_I) {
|
||||
if (include_I == TRUE) {
|
||||
return count_if(x.begin(), x.end(), bind2nd(std::greater_equal<double>(), 2));
|
||||
} else {
|
||||
return count_if(x.begin(), x.end(), bind2nd(std::greater<double>(), 2));
|
||||
}
|
||||
}
|
||||
|
||||
// [[Rcpp::export]]
|
||||
int rsi_calc_total(std::vector<double> x) {
|
||||
return count_if(x.begin(), x.end(), bind2nd(std::less_equal<double>(), 3));
|
||||
}
|
Reference in New Issue
Block a user