Hi Troels,
For speed, maybe you should send in the single value parameters
together with the array versions into the lib.dispersion modules? The
check:
+ if np.allclose(dw, np.zeros(dw.shape)) or np.allclose(pA,
np.ones(dw.shape)) or np.allclose(kex, np.zeros(dw.shape)):
will be very expensive.
Regards,
Edward
On 8 June 2014 19:48, <tlinnet@xxxxxxxxxxxxx> wrote:
Author: tlinnet
Date: Sun Jun 8 19:48:35 2014
New Revision: 23737
URL: http://svn.gna.org/viewcvs/relax?rev=23737&view=rev
Log:
Re-implemented safety checks in lib/dispersion/cr72.py.
This is now implemented for both rank-1 float array and of higher
dimensions.
This makes the unit tests pass for multi dimensional computing.
Task #7807 (https://gna.org/task/index.php?7807): Speed-up of
dispersion
models for Clustered analysis.
Modified:
branches/disp_spin_speed/lib/dispersion/cr72.py
Modified: branches/disp_spin_speed/lib/dispersion/cr72.py
URL:
http://svn.gna.org/viewcvs/relax/branches/disp_spin_speed/lib/dispersion/cr72.py?rev=23737&r1=23736&r2=23737&view=diff
==============================================================================
--- branches/disp_spin_speed/lib/dispersion/cr72.py (original)
+++ branches/disp_spin_speed/lib/dispersion/cr72.py Sun Jun 8
19:48:35 2014
@@ -128,9 +128,15 @@
rank_1 = False
# Catch parameter values that will result in no exchange,
returning
flat R2eff = R20 lines (when kex = 0.0, k_AB = 0.0).
+ # For rank-1 float array.
if rank_1:
if dw == 0.0 or pA == 1.0 or kex == 0.0:
back_calc[:] = array([r20a]*num_points)
+ return
+ # For higher dimensions, return same structure.
+ else:
+ if np.allclose(dw, np.zeros(dw.shape)) or np.allclose(pA,
np.ones(dw.shape)) or np.allclose(kex, np.zeros(dw.shape)):
+ back_calc[:] = r20a
return
# The B population.
@@ -165,16 +171,23 @@
# Catch math domain error of cosh(val > 710).
# This is when etapos > 710.
- if rank_1:
- if max(etapos) > 700:
+ if max(etapos) > 700:
+ if rank_1:
back_calc[:] = array([r20a]*num_points)
+ return
+ # For higher dimensions, return same structure.
+ else:
+ back_calc[:] = r20a
return
# The arccosh argument - catch invalid values.
fact = Dpos * cosh(etapos) - Dneg * cos(etaneg)
- if rank_1:
- if min(fact) < 1.0:
+ if min(fact) < 1.0:
+ if rank_1:
back_calc[:] = array([r20_kex]*num_points)
+ return
+ else:
+ back_calc[:] = r20_kex
return
# Calculate R2eff.
@@ -182,8 +195,10 @@
# Catch errors, taking a sum over array is the fastest way to
check
for
# +/- inf (infinity) and nan (not a number).
- if rank_1:
- if not isfinite(sum(R2eff)):
+ if not isfinite(sum(R2eff)):
+ if rank_1:
R2eff = array([1e100]*num_points)
+ else:
+ R2eff = np.ones(R2eff.shape) * 1e100
back_calc[:] = R2eff
_______________________________________________
relax (http://www.nmr-relax.com)
This is the relax-commits mailing list
relax-commits@xxxxxxx
To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits
_______________________________________________
relax (http://www.nmr-relax.com)
This is the relax-devel mailing list
relax-devel@xxxxxxx
To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-devel