/usr/lib/R/site-library/dplyr/include/dplyr/Result/MinMax.h is in r-cran-dplyr 0.7.4-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #ifndef dplyr_Result_MinMax_H
#define dplyr_Result_MinMax_H
#include <dplyr/Result/is_smaller.h>
#include <dplyr/Result/Processor.h>
namespace dplyr {
template <int RTYPE, bool MINIMUM, bool NA_RM>
class MinMax : public Processor<REALSXP, MinMax<RTYPE, MINIMUM, NA_RM> > {
public:
typedef Processor<REALSXP, MinMax<RTYPE, MINIMUM, NA_RM> > Base;
typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE;
private:
static const double Inf;
public:
MinMax(SEXP x, bool is_summary_ = false) :
Base(x),
data_ptr(Rcpp::internal::r_vector_start<RTYPE>(x)),
is_summary(is_summary_)
{}
~MinMax() {}
double process_chunk(const SlicingIndex& indices) {
if (is_summary) return data_ptr[ indices.group() ];
const int n = indices.size();
double res = Inf;
for (int i = 0; i < n; ++i) {
STORAGE current = data_ptr[indices[i]];
if (Rcpp::Vector<RTYPE>::is_na(current)) {
if (NA_RM)
continue;
else
return NA_REAL;
}
else {
double current_res = current;
if (is_better(current_res, res))
res = current_res;
}
}
return res;
}
inline static bool is_better(const double current, const double res) {
if (MINIMUM)
return internal::is_smaller<REALSXP>(current, res);
else
return internal::is_smaller<REALSXP>(res, current);
}
private:
STORAGE* data_ptr;
bool is_summary;
};
template <int RTYPE, bool MINIMUM, bool NA_RM>
const double MinMax<RTYPE, MINIMUM, NA_RM>::Inf = (MINIMUM ? R_PosInf : R_NegInf);
}
#endif
|