Closed js850 closed 9 years ago
Cool, it is a very good idea to make this thing into an iterator! I feel that mostly it is good to accept within reason longer CPU time for saving memory, because it is in general easier to get more CPU time than more (and fast) memory.
To say anything competent I would need to look at the code much more carefully. Just two fast thoughts.
As far as C++ is concerned, we can hope that the Boost.Coroutines make it into the standard.
yes, that would be great.
For beauty and confusion level of the code, would it help to encapsulate/structure it more?
This is by no means the most elegant way of doing it. It's just what I came up with, and I don't have much experience converting multiple loops into an iterator. I'd be happy for suggestions.
If I remember correctly, in boost graph library (e.g. breadth first search), they don't use iterators, they use loops with callback functions. The callback functions are implemented as templates to avoid speed losses. That might be another idea.
Looks good to me.
I improved the speed of the iterators by removing some of the unnecessary if (done())
calls. It is now effectively the same speed as the previous implementation.
@ruehle : I added a pure c++ benchmarking script in cpp_tests/source/benchmarks/. The benchmark is compiled along with the c++ tests, but is run as a separate executable. Currently the script simply does a minimization of a large LJ system.
I abandoned the iterator concept and now use the visitor design pattern. It is faster and simpler. #108 now supersedes this PR
I replaced the array of atom pairs with an iterator over atom pairs.
To do this using generators would be trivial (more or less)
Unfortunately c++ doesn't have co-routines, so I basically had to invert the triple loop. It turned out to be ugly, but it works.
upsides
downsides
What do you think, should we merge this PR?