/usr/lib/R/site-library/dplyr/include/dplyr/Result/CumSum.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 | #ifndef dplyr_Result_CumSum_H
#define dplyr_Result_CumSum_H
#include <dplyr/Result/Mutater.h>
namespace dplyr {
// REALSXP version
template <int RTYPE>
class CumSum : public Mutater<RTYPE, CumSum<RTYPE> > {
public:
CumSum(SEXP data_) : data(data_) {}
void process_slice(Vector<RTYPE>& out, const SlicingIndex& index, const SlicingIndex& out_index) {
double value = 0.0;
int n = index.size();
for (int i = 0; i < n; i++) {
value += data[index[i]];
out[out_index[i]] = value;
}
}
Vector<RTYPE> data;
};
// INTSXP version
template <>
class CumSum<INTSXP> : public Mutater<INTSXP, CumSum<INTSXP> > {
public:
CumSum(SEXP data_) : data(data_) {}
void process_slice(IntegerVector& out, const SlicingIndex& index, const SlicingIndex& out_index) {
int value = 0;
int n = index.size();
for (int i = 0; i < n; i++) {
int current = data[index[i]];
if (IntegerVector::is_na(current)) {
for (int j = i; j < n; j++) {
out[ out_index[j] ] = NA_INTEGER;
}
return;
}
value += current;
out[out_index[i]] = value;
}
}
IntegerVector data;
};
}
#endif
|