Author: bugman Date: Fri Jun 13 17:43:50 2014 New Revision: 23943 URL: http://svn.gna.org/viewcvs/relax?rev=23943&view=rev Log: Small speed up for all of the frame order models. The PCS averaging in the quasi-random numerical integration functions now uses the multiply() and divide() numpy methods to eliminate a loop over the alignments. For this, a new dimension over the spins was added to the PCS constant calculated in the target function __init__() method. In one test of the pseudo-ellipse, the time dropped from 191 seconds to 172. Modified: branches/frame_order_cleanup/lib/frame_order/double_rotor.py branches/frame_order_cleanup/lib/frame_order/iso_cone.py branches/frame_order_cleanup/lib/frame_order/iso_cone_torsionless.py branches/frame_order_cleanup/lib/frame_order/pseudo_ellipse.py branches/frame_order_cleanup/lib/frame_order/pseudo_ellipse_torsionless.py branches/frame_order_cleanup/lib/frame_order/rotor.py branches/frame_order_cleanup/target_functions/frame_order.py Modified: branches/frame_order_cleanup/lib/frame_order/double_rotor.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/lib/frame_order/double_rotor.py?rev=23943&r1=23942&r2=23943&view=diff ============================================================================== --- branches/frame_order_cleanup/lib/frame_order/double_rotor.py (original) +++ branches/frame_order_cleanup/lib/frame_order/double_rotor.py Fri Jun 13 17:43:50 2014 @@ -24,7 +24,7 @@ # Python module imports. from math import pi, sqrt -from numpy import dot, inner, sinc, transpose +from numpy import divide, dot, inner, multiply, sinc, transpose # relax module imports. from lib.frame_order.matrix_ops import rotate_daeg @@ -135,8 +135,8 @@ # Average the PCS. else: - for i in range(len(pcs_theta)): - pcs_theta[i] = c[i] * pcs_theta[i] / float(num) + multiply(c, pcs_theta, pcs_theta) + divide(pcs_theta, float(num), pcs_theta) def pcs_pivot_motion_double_rotor(full_in_ref_frame=None, r_pivot_atom=None, r_pivot_atom_rev=None, r_ln_pivot=None, A=None, R_eigen=None, RT_eigen=None, Ri_prime=None, pcs_theta=None, pcs_theta_err=None, missing_pcs=None): Modified: branches/frame_order_cleanup/lib/frame_order/iso_cone.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/lib/frame_order/iso_cone.py?rev=23943&r1=23942&r2=23943&view=diff ============================================================================== --- branches/frame_order_cleanup/lib/frame_order/iso_cone.py (original) +++ branches/frame_order_cleanup/lib/frame_order/iso_cone.py Fri Jun 13 17:43:50 2014 @@ -24,7 +24,7 @@ # Python module imports. from math import cos, pi, sqrt -from numpy import sinc +from numpy import divide, multiply, sinc # relax module imports. from lib.frame_order.matrix_ops import pcs_pivot_motion_full_qrint, rotate_daeg @@ -115,8 +115,8 @@ # Average the PCS. else: - for i in range(len(pcs_theta)): - pcs_theta[i] = c[i] * pcs_theta[i] / float(num) + multiply(c, pcs_theta, pcs_theta) + divide(pcs_theta, float(num), pcs_theta) def populate_1st_eigenframe_iso_cone(matrix, angle): Modified: branches/frame_order_cleanup/lib/frame_order/iso_cone_torsionless.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/lib/frame_order/iso_cone_torsionless.py?rev=23943&r1=23942&r2=23943&view=diff ============================================================================== --- branches/frame_order_cleanup/lib/frame_order/iso_cone_torsionless.py (original) +++ branches/frame_order_cleanup/lib/frame_order/iso_cone_torsionless.py Fri Jun 13 17:43:50 2014 @@ -24,6 +24,7 @@ # Python module imports. from math import cos, sqrt +from numpy import divide, multiply # relax module imports. from lib.frame_order.matrix_ops import pcs_pivot_motion_torsionless_qrint, rotate_daeg @@ -134,5 +135,5 @@ # Average the PCS. else: - for i in range(len(pcs_theta)): - pcs_theta[i] = c[i] * pcs_theta[i] / float(num) + multiply(c, pcs_theta, pcs_theta) + divide(pcs_theta, float(num), pcs_theta) Modified: branches/frame_order_cleanup/lib/frame_order/pseudo_ellipse.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/lib/frame_order/pseudo_ellipse.py?rev=23943&r1=23942&r2=23943&view=diff ============================================================================== --- branches/frame_order_cleanup/lib/frame_order/pseudo_ellipse.py (original) +++ branches/frame_order_cleanup/lib/frame_order/pseudo_ellipse.py Fri Jun 13 17:43:50 2014 @@ -24,7 +24,7 @@ # Python module imports. from math import cos, pi, sin, sqrt -from numpy import sinc +from numpy import divide, multiply, repeat, sinc, tile try: from scipy.integrate import quad except ImportError: @@ -659,8 +659,8 @@ # Average the PCS. else: - for i in range(len(pcs_theta)): - pcs_theta[i] = c[i] * pcs_theta[i] / float(num) + multiply(c, pcs_theta, pcs_theta) + divide(pcs_theta, float(num), pcs_theta) def tmax_pseudo_ellipse(phi, theta_x, theta_y): Modified: branches/frame_order_cleanup/lib/frame_order/pseudo_ellipse_torsionless.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/lib/frame_order/pseudo_ellipse_torsionless.py?rev=23943&r1=23942&r2=23943&view=diff ============================================================================== --- branches/frame_order_cleanup/lib/frame_order/pseudo_ellipse_torsionless.py (original) +++ branches/frame_order_cleanup/lib/frame_order/pseudo_ellipse_torsionless.py Fri Jun 13 17:43:50 2014 @@ -24,6 +24,7 @@ # Python module imports. from math import cos, pi, sin, sqrt +from numpy import divide, multiply try: from scipy.integrate import quad except ImportError: @@ -320,5 +321,5 @@ # Average the PCS. else: - for i in range(len(pcs_theta)): - pcs_theta[i] = c[i] * pcs_theta[i] / float(num) + multiply(c, pcs_theta, pcs_theta) + divide(pcs_theta, float(num), pcs_theta) Modified: branches/frame_order_cleanup/lib/frame_order/rotor.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/lib/frame_order/rotor.py?rev=23943&r1=23942&r2=23943&view=diff ============================================================================== --- branches/frame_order_cleanup/lib/frame_order/rotor.py (original) +++ branches/frame_order_cleanup/lib/frame_order/rotor.py Fri Jun 13 17:43:50 2014 @@ -24,7 +24,7 @@ # Python module imports. from math import pi, sqrt -from numpy import dot, inner, sinc, transpose +from numpy import divide, dot, inner, multiply, sinc, transpose from numpy.linalg import norm try: from scipy.integrate import quad @@ -136,8 +136,8 @@ # Average the PCS. else: - for i in range(len(pcs_theta)): - pcs_theta[i] = c[i] * pcs_theta[i] / float(num) + multiply(c, pcs_theta, pcs_theta) + divide(pcs_theta, float(num), pcs_theta) def pcs_pivot_motion_rotor_qrint(full_in_ref_frame=None, r_pivot_atom=None, r_pivot_atom_rev=None, r_ln_pivot=None, A=None, R_eigen=None, RT_eigen=None, Ri_prime=None, pcs_theta=None, pcs_theta_err=None, missing_pcs=None): Modified: branches/frame_order_cleanup/target_functions/frame_order.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/target_functions/frame_order.py?rev=23943&r1=23942&r2=23943&view=diff ============================================================================== --- branches/frame_order_cleanup/target_functions/frame_order.py (original) +++ branches/frame_order_cleanup/target_functions/frame_order.py Fri Jun 13 17:43:50 2014 @@ -270,7 +270,7 @@ # Initialise the data structures. self.paramag_unit_vect = zeros(atomic_pos.shape, float64) self.paramag_dist = zeros(self.num_spins, float64) - self.pcs_const = zeros(self.num_align, float64) + self.pcs_const = zeros((self.num_align, self.num_spins), float64) self.r_pivot_atom = zeros((self.num_spins, 3), float32) self.r_pivot_atom_rev = zeros((self.num_spins, 3), float32) self.r_ln_pivot = self.pivot - self.paramag_centre @@ -1045,7 +1045,7 @@ # The PCS calculation. vect = self.r_ln_pivot[0] + r_pivot_atom length = norm(vect) - self.pcs_theta[align_index, j] = pcs_tensor(self.pcs_const[align_index] / length**5, vect, self.A_3D[align_index]) + self.pcs_theta[align_index, j] = pcs_tensor(self.pcs_const[align_index, j] / length**5, vect, self.A_3D[align_index]) # Calculate and sum the single alignment chi-squared value (for the PCS). chi2_sum = chi2_sum + chi2(self.pcs[align_index], self.pcs_theta[align_index], self.pcs_error[align_index])