Weighted poisson integration#872
Conversation
69c9e20 to
3c67197
Compare
3c67197 to
d63167b
Compare
8273c3f to
817a80e
Compare
165ec32 to
252a3d0
Compare
| gradients->incr(ix)) { | ||
| size_t count = gradients->samples->value(ix); | ||
| if (count > 0) { | ||
| insert_into_sorted_list<size_t>(sorted_counts, count); |
There was a problem hiding this comment.
I'm not familiar with the algorithm details, but random insertion in a vector should be quite slow. Why not just push_back and then std::sort?
| std::vector<int> zero_vector(nd, 0); | ||
| gradients_to_average_relative_positions.push_back(zero_vector); | ||
| } else { | ||
| for (int i = 0; i < pow(2, directions_to_average_along.size()); i++) { |
There was a problem hiding this comment.
Each time when comparing i with the end of loop, it has to recalculate pow, which might be slow. Is it possible to cache the index of the end of loop? Also, you should consider using cvm::integer_power.
|
When restarting |
| surrounding_points_relative_positions.clear(); | ||
| size_t n_combinations = pow(2, nd); | ||
| for (size_t i = 0; i < n_combinations; i++) { | ||
| surrounding_points_relative_positions.push_back(convert_base_two(i, nd)); |
There was a problem hiding this comment.
I feel that the calls to convert_base_two is unnecessary because an integer has already all its bits itself. convert_base_two simply checks the bits of i and stores them into a vector of nd size. But maybe I am wrong, and I am not sure how to optimize this.
There was a problem hiding this comment.
This is not performance-critical, and this form is more legible than a bunch of (n >>i)&1 throughout the code.
in proxy_stubs wrt other proxys
uses CLI11.hpp, now we need to find a common place in the tree to share it with other tools also fixes Doxygen comments are noted by Haochuan
Thanks Haochuan for the feedback.
Fix the compilation error of comparing signed and unsigned integers.
67268e5 to
31f8ad6
Compare
Reduce allocations by reserving containers and moving allocations out of loops.
Implements weighted Poisson integration of free energy gradients.
Also fixes a small error in Neumann boundary conditions for the existing unweighted case.
TODO: