Author: bugman Date: Fri May 23 19:39:53 2014 New Revision: 23389 URL: http://svn.gna.org/viewcvs/relax?rev=23389&view=rev Log: Small speed up for all the isotropic cone and pseudo-elliptic cone frame order models. The vector length calculation for the numeric PCS integration has been simplified and shifted outside of a loop to take advantage of the speed of numpy. Modified: trunk/lib/frame_order/matrix_ops.py Modified: trunk/lib/frame_order/matrix_ops.py URL: http://svn.gna.org/viewcvs/relax/trunk/lib/frame_order/matrix_ops.py?rev=23389&r1=23388&r2=23389&view=diff ============================================================================== --- trunk/lib/frame_order/matrix_ops.py (original) +++ trunk/lib/frame_order/matrix_ops.py Fri May 23 19:39:53 2014 @@ -23,8 +23,8 @@ """Module for the handling of Frame Order.""" # Python module imports. -from math import cos, sin, sqrt -from numpy import dot, inner, transpose +from math import cos, sin +from numpy import dot, inner, sqrt, transpose from numpy.linalg import norm # relax module imports. @@ -198,12 +198,12 @@ rot_vect_rev = transpose(dot(R_i, r_pivot_atom_rev) + r_ln_pivot) rot_vect = transpose(dot(R_i, r_pivot_atom) + r_ln_pivot) + # The vector length (to the 5th power). + length_rev = 1.0 / norm(rot_vect_rev, axis=1)**5 + length = 1.0 / norm(rot_vect, axis=1)**5 + # Loop over the atoms. for j in range(len(r_pivot_atom[0])): - # The vector length (to the 5th power). - length_rev = 1.0 / sqrt(inner(rot_vect_rev[j], rot_vect_rev[j]))**5 - length = 1.0 / sqrt(inner(rot_vect[j], rot_vect[j]))**5 - # Loop over the alignments. for i in range(len(pcs_theta)): # Skip missing data. @@ -213,10 +213,10 @@ # The projection. if full_in_ref_frame[i]: proj = dot(rot_vect[j], dot(A[i], rot_vect[j])) - length_i = length + length_i = length[j] else: proj = dot(rot_vect_rev[j], dot(A[i], rot_vect_rev[j])) - length_i = length_rev + length_i = length_rev[j] # The PCS. pcs_theta[i, j] += proj * length_i @@ -342,12 +342,12 @@ rot_vect_rev = transpose(dot(R_i, r_pivot_atom_rev) + r_ln_pivot) rot_vect = transpose(dot(R_i, r_pivot_atom) + r_ln_pivot) + # The vector length (to the 5th power). + length_rev = 1.0 / norm(rot_vect_rev, axis=1)**5 + length = 1.0 / norm(rot_vect, axis=1)**5 + # Loop over the atoms. for j in range(len(r_pivot_atom[0])): - # The vector length (to the 5th power). - length_rev = 1.0 / sqrt(inner(rot_vect_rev[j], rot_vect_rev[j]))**5 - length = 1.0 / sqrt(inner(rot_vect[j], rot_vect[j]))**5 - # Loop over the alignments. for i in range(len(pcs_theta)): # Skip missing data. @@ -357,10 +357,10 @@ # The projection. if full_in_ref_frame[i]: proj = dot(rot_vect[j], dot(A[i], rot_vect[j])) - length_i = length + length_i = length[j] else: proj = dot(rot_vect_rev[j], dot(A[i], rot_vect_rev[j])) - length_i = length_rev + length_i = length_rev[j] # The PCS. pcs_theta[i, j] += proj * length_i