Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // compute SMA using standard summation
- simple_moving_average(data, w, averages);
- unsigned n_SMAs = 1000; // # of SMA indicators to evaluate
- unsigned len = 2000; // # of stock prices per indicator
- unsigned w = 6; // window size
- // generate stock prices: [0..10]
- af::array data = af::randu(n_SMAs, len) * 10;
- // compute inclusive prefix sums along colums of the matrix
- af::array s = af::accum(data, 1);
- // compute the average
- af::array avg = (s.cols(w, af::end) - s.cols(0, af::end - w)) / w;
- af::eval(avg);
- std::cout << avg.dims() << "n" << avg << "n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement