New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce space usage of Discrete Integrals #1877
Conversation
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. |
Oh ok, but the sum accumulator does not store each summand, it only maintains the running sum as its internal state, see here: |
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. |
Reduce space usage of discrete integrals, no need to allocate extra space.