
11.6. EXAMPLE: MOVING AVERAGE 243
The goal is to address the question, “What has the recent trend been?” at
time i, i = w, ..., n.
11.6.1 Rth Code
Rth includes the function rthma() to compute moving average in parallel,
using an algorithm adapted from the Thrust examples package. Here is the
C++ code, contents of the file rthma.cpp:
// Rth i n t e r f a c e to Thrust moving−average example ,
// s imple moving a verage . cu in
// g ithub . com/ t h r u s t / t h r u s t /blob/master/examples /
// C++ code adapted from example in Thrust docs
#include <t h r u s t / d e v i c e ve c t o r . h>
#include <t h r u s t /scan . h>
#include <t h r u s t /transfo