Sergey wrote:
Yes, such function would be definitely useful. Sometimes, it is useful to play with some reasonable, but a bit ad-hoc hoppings. I propose that that the function "connect" must take a function name "crit" as an input parameter. Where "crit" is a function taking two sites as parameters, e.g.
crit(A,B): if norm(A-B) < 2 and 0
It could be nice to have an efficient realization of "connect" . Is there a way to do it faster than N^2 ?
I believe that it can be made something like O(N log N) by using an appropriate data structure, perhaps a k-d tree. But it's clearly O(N^2) if crit is to be called for all pairs of sites. How about, instead of crit, having a function that returns all hoppings within some maximum distance. If you want to use crit, you can do something like this: sys[ (hop for hop in connect(A, B) if crit(hop)) ] = value Wouldn't that be the same as your suggestion, only more generic? Christoph