Open ajkerr0 opened 8 years ago
This could actually save important time when we are looking at cases with multiple drivers, very large molecules, etc.
If nothing else, this is a great exercise in working in arbitrary dimensions in numpy.
Thinking about it some more, this may not save any appreciable time because I think numpy's sum function goes like O(n) anyway, not O(log(n)). If the latter is the case, then yes, we should explore it.
Ok, it turns out that summing an array the way I was thinking (add nearest neighbors together, repeatedly add aggregates together) still has linear time complexity. I just thought about it on paper.
So pursuing this issue will not be worth it for now. We have already vectorized the important part of the calculation: the 3Nx3N sum. Python only has to do type checking for the sum of each dimension, and for each of the drivers, and for each of the crossing interactions.
Going to mark as low priority.
Full vectorization would be prime for parallelization
Putting everything in a single numpy array would also make it very clear where the N largest contributions come from.
Related to #68, where we were missing any numpy implementation that functioned correctly. Now we can take the extra step and skip the for loops in that solution by creating 3x3xNxN arrays (where N is 2 times the number of coordinates (3 times the number of atoms)).
The main obstacle is figuring out how to construct the higher dimensional arrays.
This should not be the highest priority since we believe the main bottleneck of the kappa calculation is the solving for the Green's function coefficients.