|
1 | 1 | #include "data.table.h" |
2 | 2 |
|
| 3 | +const char *const rfunNames[] = { |
| 4 | + "MEAN", "SUM", "MAX", "MIN", "PROD", "MEDIAN", "VAR", "SD"}; //constant definition of froll functions |
3 | 5 | /* |
4 | 6 | OpenMP is used here to parallelize the loops in most of the |
5 | 7 | implementations of rolling functions. |
|
21 | 23 | */ |
22 | 24 | void frollfun(rollfun_t rfun, unsigned int algo, const double *x, uint64_t nx, ans_t *ans, int k, int align, double fill, bool narm, int hasnf, bool verbose, bool par) { |
23 | 25 | double tic = 0; |
24 | | - char rfunStr[7]; |
25 | | - |
26 | | - const char *rfunNames[] = { |
27 | | - "MEAN", "SUM", "MAX", "MIN", "PROD", "MEDIAN", "VAR", "SD"}; |
28 | | - |
29 | | - if (verbose){ |
| 26 | + if (verbose) |
30 | 27 | tic = omp_get_wtime(); |
31 | | - snprintf(rfunStr, sizeof(rfunStr), "%s", rfunNames[rfun]); |
32 | | - } |
33 | | - |
34 | 28 | if (nx < k) { // if window width bigger than input just return vector of fill values |
35 | 29 | if (verbose) |
36 | 30 | snprintf(end(ans->message[0]), 500, _("%s: window width longer than input vector, returning all NA vector\n"), __func__); |
@@ -112,7 +106,7 @@ void frollfun(rollfun_t rfun, unsigned int algo, const double *x, uint64_t nx, a |
112 | 106 | } |
113 | 107 | } |
114 | 108 | if (verbose) { |
115 | | - snprintf(end(ans->message[0]), 500, _("%s: processing fun %s algo %s took %.3fs\n"), __func__, rfunStr, (algo == 0) ? "fast" : "exact", omp_get_wtime()-tic); |
| 109 | + snprintf(end(ans->message[0]), 500, _("%s: processing fun %s algo %s took %.3fs\n"), __func__, rfunNames[rfun], (algo == 0) ? "fast" : "exact", omp_get_wtime()-tic); |
116 | 110 | } |
117 | 111 | } |
118 | 112 |
|
|
0 commit comments