faster RigidBody::get_reference_frame()
Hi, right now RigidBody::get_reference_frame() is a common yet expensive operation (from profilng), especially within scores. The reason seems to be that IMP saves the quaternion, but not the rotation matrix.
Would it make sense to save a cache of the rotation matrix that would update if needed? Or is it possibly that memory cost would be too high?
hmm I am actually not seeing why it is so expensive, let me check it some more before anybody answers (unless you have an irresistible urge to do so :)
On Wed, Jun 18, 2014 at 12:14 PM, Barak Raveh barak.raveh@gmail.com wrote:
> Hi, right now RigidBody::get_reference_frame() is a common yet expensive > operation (from profilng), especially within scores. The reason seems to be > that IMP saves the quaternion, but not the rotation matrix. > > Would it make sense to save a cache of the rotation matrix that would > update if needed? Or is it possibly that memory cost would be too high? > > > -- > Barak >
Hi Barak If you are to touch the RigidBody code, I'd suggest to rewrite it completely with eigen, which would spare you these troubles (I guess). Also, check my code in core/internal/tunneler_helpers.h, and the two classes that use it, RigidBodyUmbrella and RigidBodyTunneler. I needed to reimplement the coordinate methods provided by RigidBody (local/global coords, rotation, translation etc, among which your get_reference_frame() ). This was because the reference frame returned by RigidBody::get_reference_frame is not consistent, but an arbitrary reflection can happen (see IMP issue #773). I reimplemented it with eigen, so this might be of interest to you.
For the particular case you mention, you'd want to cache q.matrix() if q is the Eigen::Quaternion, and use that rotation matrix to do the rotations. As the Eigen doc states (Eigen::QuaternionBase doc),
"If the quaternion is used to rotate several points (>1) then it is much more efficient to first convert it to a 3x3 Matrix http://eigen.tuxfamily.org/dox/classEigen_1_1Matrix.html. Comparison of the operation cost for n transformations:
* Quaternion2: 30n * Via a Matrix3: 24 + 15n
"
Y
Le 18/06/14 21:14, Barak Raveh a écrit : > Hi, right now RigidBody::get_reference_frame() is a common yet > expensive operation (from profilng), especially within scores. The > reason seems to be that IMP saves the quaternion, but not the rotation > matrix. > > Would it make sense to save a cache of the rotation matrix that would > update if needed? Or is it possibly that memory cost would be too high? > > > -- > Barak > > > _______________________________________________ > IMP-dev mailing list > IMP-dev@salilab.org > https://salilab.org/mailman/listinfo/imp-dev
participants (2)
-
Barak Raveh
-
Yannick Spill