rmcgibbo/mdtraj — pull request #246 by rmcgibbo (2014-01-02 09:21:28+00:00)
Title: rmsd: possible to use precomputed centering/g values

Adds a new keyword argument with which you can "activate" the use of precentered and precomputed RMSD trace values. This is a potentially unsafe feature, because if you compute the traces, then modify the coordinates, then compute an RMSD you'll get an incorrect result, because the two will be out of sync. So the default behavior is to recenter and recompute the Gs each time.

The speed difference is only significant when you have a good numbers of atoms, because of memory bandwidth. I optimized the centering calculation a lot with SSE and careful cache management, but you can't avoid the fact that it requires another pass through the data.

Using [this](https://gist.github.com/rmcgibbo/8216696) script on 4fb06e5199dbbdcecce4e91340d535bcef7963ac, here are some timings. They are pretty consistent with the 3x speed difference that @kyleabeauchamp noticed on NTL9 (~600 atoms) on a different thread https://github.com/rmcgibbo/mdtraj/pull/220#issuecomment-30058880.

```
50 atoms
md.rmsd(t, t, 0) : 0.135 seconds
md.rmsd(t, t, 0, precomputed=True): 0.094 seconds

200 atoms
md.rmsd(t, t, 0) : 0.403 seconds
md.rmsd(t, t, 0, precomputed=True): 0.149 seconds

400 atoms
md.rmsd(t, t, 0) : 0.788 seconds
md.rmsd(t, t, 0, precomputed=True): 0.265 seconds
```