add_op(OP_SORT, SORT)
add_op(OP_REV, REV)
add_op(OP_TREND, TREND)
+ add_op(OP_TRENDNAN, TRENDNAN)
add_op(OP_RAD2DEG, RAD2DEG)
add_op(OP_DEG2RAD, DEG2RAD)
add_op(OP_AVG, AVG)
match_op(OP_SORT, SORT)
match_op(OP_REV, REV)
match_op(OP_TREND, TREND)
+ match_op(OP_TRENDNAN, TRENDNAN)
match_op(OP_RAD2DEG, RAD2DEG)
match_op(OP_DEG2RAD, DEG2RAD)
match_op(OP_AVG, AVG)
}
break;
case OP_TREND:
+ case OP_TRENDNAN:
stackunderflow(1);
if ((rpi < 2) || (rpnp[rpi - 2].op != OP_VARIABLE)) {
rrd_set_error("malformed trend arguments");
time_t step = (time_t) rpnp[rpi - 2].step;
if (output_idx > (int) ceil((float) dur / (float) step)) {
+ int ignorenan = (rpnp[rpi].op == OP_TREND);
double accum = 0.0;
int i = 0;
+ int count = 0;
do {
- accum +=
+ double val =
rpnp[rpi - 2].data[rpnp[rpi - 2].ds_cnt * i--];
+ if (ignorenan || !isnan(val)) {
+ accum += val;
+ ++count;
+ }
+
dur -= step;
} while (dur > 0);
- rpnstack->s[--stptr] = (accum / -i);
+ rpnstack->s[--stptr] =
+ (count == 0) ? DNAN : (accum / count);
} else
rpnstack->s[--stptr] = DNAN;
}