2018-07-13 17:23:46 +02:00
|
|
|
#include <Rcpp.h>
|
|
|
|
#include <functional> // for std::less, etc
|
|
|
|
#include <algorithm> // for count_if
|
|
|
|
|
2018-07-15 22:56:41 +02:00
|
|
|
using namespace Rcpp;
|
2018-07-13 17:23:46 +02:00
|
|
|
|
|
|
|
// [[Rcpp::export]]
|
2018-07-15 22:56:41 +02:00
|
|
|
int rsi_calc_S(DoubleVector x, bool include_I) {
|
2018-07-13 17:23:46 +02:00
|
|
|
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]]
|
2018-07-15 22:56:41 +02:00
|
|
|
int rsi_calc_R(DoubleVector x, bool include_I) {
|
2018-07-13 17:23:46 +02:00
|
|
|
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]]
|
2018-07-15 22:56:41 +02:00
|
|
|
int rsi_calc_total(DoubleVector x) {
|
|
|
|
return count_if(x.begin(), x.end(), bind2nd(std::less_equal<double>(), 3));
|
2018-07-13 17:23:46 +02:00
|
|
|
}
|