Wednesday 25 July 2012

numeric Library

<numeric>


In the following, plus, minus, and times are optional functions taking 2 arguments x and y that return x+y, x-y, and x*y respectively, e.g. int plus(int x, int y) {return x+y;} x=accumulate(b, e, x, plus); // x + sum over [b,e)
x=inner_product(b, e, b2, x, plus, times); // x + sum [b,e)*[b2,e2)
adjacent_difference(b, e, minus); // for i in (b,e) *i -= i[-1]
partial_sum(b, e, plus); // for i in [b,e) *i += sum [b,i)

No comments:

Post a Comment