[AMBER] cpptraj matrix dist modifications

From: Gard Nelson <Gard.Nelson.NantBio.com>
Date: Thu, 11 Jun 2015 18:59:19 +0000

Hi all,

I'm trying to modify the "dist" function of cpptraj's matrix command. I modified the CalcDistanceMatrix function (lines 384-397 of Action_Matrix.cpp) to the following: (new code in bold)

void Action_Matrix::CalcDistanceMatrix(Frame const& currentFrame) {
  DataSet_MatrixDbl::iterator mat = ((DataSet_MatrixDbl*)Mat_)->begin();
  double dst;
  if (!useMask2_) {
    // Upper Triangle
    for (AtomMask::const_iterator atom2 = mask1_.begin(); atom2 != mask1_.end(); ++atom2)
      for (AtomMask::const_iterator atom1 = atom2; atom1 != mask1_.end(); ++atom1)
        dst = sqrt(DIST2_NoImage(currentFrame.XYZ(*atom2), currentFrame.XYZ(*atom1)));
        *(mat++) += dst;
  } else {
    // Full matrix
    for (AtomMask::const_iterator atom2 = mask2_.begin(); atom2 != mask2_.end(); ++atom2)
      for (AtomMask::const_iterator atom1 = mask1_.begin(); atom1 != mask1_.end(); ++atom1)
        dst = sqrt(DIST2_NoImage(currentFrame.XYZ(*atom2), currentFrame.XYZ(*atom1)));
        *(mat++) += dst;
  }
}

The function I want to implement uses the distance in several places, so making multiple calls to DIST2_NoImage slows things down dramatically. All I intended to do with the above code is assign the distance to a variable and then add that variable to the matrix. I could then use that variable (dst) wherever it's needed.

However, making this change results in the output matrix having a small value in the (1,1) position and being uniformly 0 everywhere else, which is not the functionality I expected. I am stumped over why the change I made isn't transparent and would greatly appreciate any help in making the code work.

Thanks,
Gard
CONFIDENTIALITY NOTICE
This e-mail message and any attachments are only for the use of the intended recipient and may contain information that is privileged, confidential or exempt from disclosure under applicable law. If you are not the intended recipient, any disclosure, distribution or other use of this e-mail message or attachments is prohibited. If you have received this e-mail message in error, please delete and notify the sender immediately. Thank you.
_______________________________________________
AMBER mailing list
AMBER.ambermd.org
http://lists.ambermd.org/mailman/listinfo/amber
Received on Thu Jun 11 2015 - 12:00:03 PDT
Custom Search