Author: tlinnet Date: Sun Jun 8 23:44:44 2014 New Revision: 23745 URL: http://svn.gna.org/viewcvs/relax?rev=23745&view=rev Log: Swith the looping from spin->frq to frq->spin. Since the number of dispersion points are the same for all spins, this allows to move the calculation of pA and kex array one level up. This saves alot of computation. Task #7807 (https://gna.org/task/index.php?7807): Speed-up of dispersion models for Clustered analysis. Modified: branches/disp_spin_speed/target_functions/relax_disp.py Modified: branches/disp_spin_speed/target_functions/relax_disp.py URL: http://svn.gna.org/viewcvs/relax/branches/disp_spin_speed/target_functions/relax_disp.py?rev=23745&r1=23744&r2=23745&view=diff ============================================================================== --- branches/disp_spin_speed/target_functions/relax_disp.py (original) +++ branches/disp_spin_speed/target_functions/relax_disp.py Sun Jun 8 23:44:44 2014 @@ -517,14 +517,19 @@ @rtype: float """ - # Loop over the spins. - for si in range(self.num_spins): - # Loop over the spectrometer frequencies. - for mi in range(self.num_frq): - # Extract number of dispersion points. - num_disp_points = self.num_disp_points[0][si][mi][0] - - # The R20 index. + + # Loop over the spectrometer frequencies. + for mi in range(self.num_frq): + # Extract number of dispersion points. Always the same per sin. + num_disp_points = self.num_disp_points[0][0][mi][0] + + # Calculate pA and kex per frequency. + pA_arr = np.array( [pA] * num_disp_points, float64) + kex_arr = np.array( [kex] * num_disp_points, float64) + + # Loop over the spins. + for si in range(self.num_spins): + # The R20 index. r20_index = mi + si*self.num_frq # Store r20a and r20b values per disp point. @@ -538,8 +543,8 @@ self.dw_frq_a[0][si][mi][0][:num_disp_points] = np.array( [dw_frq] * num_disp_points, float64) # Store pA and kex per disp point. - self.pA_a[0][si][mi][0][:num_disp_points] = np.array( [pA] * num_disp_points, float64) - self.kex_a[0][si][mi][0][:num_disp_points] = np.array( [kex] * num_disp_points, float64) + self.pA_a[0][si][mi][0][:num_disp_points] = pA_arr + self.kex_a[0][si][mi][0][:num_disp_points] = kex_arr # Extract the errors and values to numpy array. self.errors_a[0][si][mi][0][:num_disp_points] = self.errors[0][si][mi][0]