Reduce space usage of Discrete Integrals
Reduce space usage of discrete integrals, no need to allocate extra space.
coverage: 72.426% (+0.1%) from 72.31% when pulling 19987be07f0f66e70a6e819e289c9aa4dcc1fc8d on yjian012:master into dee33df049a031fed50bb3690615c2116015eb84 on lballabio:master.
I get why you remove the array fv, but what is the benefit of removing the accumulators to compute a sum?
I don't know the internal implementation of accumulators, but from what I read, it provides a bunch of statistics tools, like sum, moments, median, etc. To be able to calculate all these functions, it must store all the data, which requires dynamic memory allocation. But we only need one number, the sum. So, unless there's some secret acceleration on summation that it can do, I think it should be more efficient without it.
Oh ok, but the sum accumulator does not store each summand, it only maintains the running sum as its internal state, see here:
https://github.com/boostorg/accumulators/blob/9d9e5dae2202660f57e2dc91efb620aa001525b3/include/boost/accumulators/statistics/sum.hpp#L43
OK, I see. So when it's only tagged "sum", it only computes the sum... Thank you for letting me know. I still prefer a simple summation, since the area under the curve in each interval is not statistics variable, we'll never need any other feature of this class. But I don't really mind. I reverted it back to accumulator.
For what it's worth, I think that the simple sum is better because it is easier to understand, and also because it doesn't pull in all of the dependencies of boost accumulators, of which there are a lot. I understand that this is a cpp file and not an hpp file but it's good to reduce dependencies wherever we can.
Agreed. Maybe using std::accumulate would be preferable.