mailr23387 - /branches/frame_order_cleanup/lib/frame_order/


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on May 23, 2014 - 16:55:
Author: bugman
Date: Fri May 23 16:55:52 2014
New Revision: 23387

URL: http://svn.gna.org/viewcvs/relax?rev=23387&view=rev
Log:
Faster clearing of numpy arrays in the lib.frame_order modules.

The x[:] = 0.0 notation is now used to set all elements to zero, rather than 
nested looping over all
dimensions.  This however has a negligible effect on the test suite timings.


Modified:
    branches/frame_order_cleanup/lib/frame_order/double_rotor.py
    branches/frame_order_cleanup/lib/frame_order/free_rotor.py
    branches/frame_order_cleanup/lib/frame_order/iso_cone.py
    branches/frame_order_cleanup/lib/frame_order/iso_cone_free_rotor.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

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=23387&r1=23386&r2=23387&view=diff
==============================================================================
--- branches/frame_order_cleanup/lib/frame_order/double_rotor.py        
(original)
+++ branches/frame_order_cleanup/lib/frame_order/double_rotor.py        Fri 
May 23 16:55:52 2014
@@ -47,9 +47,7 @@
     """
 
     # Zeros.
-    for i in range(9):
-        for j in range(9):
-            matrix[i, j] = 0.0
+    matrix[:] = 0.0
 
     # Repetitive trig calculations.
     sinc_smax = sinc(smax/pi)
@@ -114,10 +112,8 @@
     """
 
     # Clear the data structures.
-    for i in range(len(pcs_theta)):
-        for j in range(len(pcs_theta[i])):
-            pcs_theta[i, j] = 0.0
-            pcs_theta_err[i, j] = 0.0
+    pcs_theta[:] = 0.0
+    pcs_theta_err[:] = 0.0
 
     # Loop over the samples.
     num = 0

Modified: branches/frame_order_cleanup/lib/frame_order/free_rotor.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/lib/frame_order/free_rotor.py?rev=23387&r1=23386&r2=23387&view=diff
==============================================================================
--- branches/frame_order_cleanup/lib/frame_order/free_rotor.py  (original)
+++ branches/frame_order_cleanup/lib/frame_order/free_rotor.py  Fri May 23 
16:55:52 2014
@@ -1,6 +1,6 @@
 
###############################################################################
 #                                                                            
 #
-# Copyright (C) 2009-2013 Edward d'Auvergne                                  
 #
+# Copyright (C) 2009-2014 Edward d'Auvergne                                  
 #
 #                                                                            
 #
 # This file is part of the program relax (http://www.nmr-relax.com).         
 #
 #                                                                            
 #
@@ -39,9 +39,7 @@
     """
 
     # Zeros.
-    for i in range(9):
-        for j in range(9):
-            matrix[i, j] = 0.0
+    matrix[:] = 0.0
 
     # Diagonal.
     matrix[0, 0] = 0.5

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=23387&r1=23386&r2=23387&view=diff
==============================================================================
--- branches/frame_order_cleanup/lib/frame_order/iso_cone.py    (original)
+++ branches/frame_order_cleanup/lib/frame_order/iso_cone.py    Fri May 23 
16:55:52 2014
@@ -90,10 +90,8 @@
     """
 
     # Clear the data structures.
-    for i in range(len(pcs_theta)):
-        for j in range(len(pcs_theta[i])):
-            pcs_theta[i, j] = 0.0
-            pcs_theta_err[i, j] = 0.0
+    pcs_theta[:] = 0.0
+    pcs_theta_err[:] = 0.0
 
     # Loop over the samples.
     num = 0
@@ -138,9 +136,7 @@
     """
 
     # Zeros.
-    for i in range(3):
-        for j in range(3):
-            matrix[i, j] = 0.0
+    matrix[:] = 0.0
 
     # The c33 element.
     matrix[2, 2] = (cos(angle) + 1.0) / 2.0
@@ -161,9 +157,7 @@
     """
 
     # Zeros.
-    for i in range(9):
-        for j in range(9):
-            matrix[i, j] = 0.0
+    matrix[:] = 0.0
 
     # Repetitive trig calculations.
     sinc_smax = sinc(smax/pi)

Modified: branches/frame_order_cleanup/lib/frame_order/iso_cone_free_rotor.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/lib/frame_order/iso_cone_free_rotor.py?rev=23387&r1=23386&r2=23387&view=diff
==============================================================================
--- branches/frame_order_cleanup/lib/frame_order/iso_cone_free_rotor.py 
(original)
+++ branches/frame_order_cleanup/lib/frame_order/iso_cone_free_rotor.py Fri 
May 23 16:55:52 2014
@@ -1,6 +1,6 @@
 
###############################################################################
 #                                                                            
 #
-# Copyright (C) 2009-2013 Edward d'Auvergne                                  
 #
+# Copyright (C) 2009-2014 Edward d'Auvergne                                  
 #
 #                                                                            
 #
 # This file is part of the program relax (http://www.nmr-relax.com).         
 #
 #                                                                            
 #
@@ -72,9 +72,7 @@
     """
 
     # Zeros.
-    for i in range(9):
-        for j in range(9):
-            matrix[i, j] = 0.0
+    matrix[:] = 0.0
 
     # The c11^2, c22^2, c12^2, and c21^2 elements.
     matrix[0, 0] = matrix[4, 4] = (s1 + 2.0) / 6.0

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=23387&r1=23386&r2=23387&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 May 23 16:55:52 2014
@@ -44,9 +44,7 @@
     """
 
     # Zeros.
-    for i in range(9):
-        for j in range(9):
-            matrix[i, j] = 0.0
+    matrix[:] = 0.0
 
     # Repetitive trig calculations.
     cos_tmax = cos(cone_theta)
@@ -113,10 +111,8 @@
     """
 
     # Clear the data structures.
-    for i in range(len(pcs_theta)):
-        for j in range(len(pcs_theta[i])):
-            pcs_theta[i, j] = 0.0
-            pcs_theta_err[i, j] = 0.0
+    pcs_theta[:] = 0.0
+    pcs_theta_err[:] = 0.0
 
     # Loop over the samples.
     num = 0

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=23387&r1=23386&r2=23387&view=diff
==============================================================================
--- branches/frame_order_cleanup/lib/frame_order/pseudo_ellipse.py      
(original)
+++ branches/frame_order_cleanup/lib/frame_order/pseudo_ellipse.py      Fri 
May 23 16:55:52 2014
@@ -624,12 +624,9 @@
     @type error_flag:           bool
     """
 
-
     # Clear the data structures.
-    for i in range(len(pcs_theta)):
-        for j in range(len(pcs_theta[i])):
-            pcs_theta[i, j] = 0.0
-            pcs_theta_err[i, j] = 0.0
+    pcs_theta[:] = 0.0
+    pcs_theta_err[:] = 0.0
 
     # Loop over the samples.
     num = 0

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=23387&r1=23386&r2=23387&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 May 23 16:55:52 2014
@@ -294,10 +294,8 @@
     """
 
     # Clear the data structures.
-    for i in range(len(pcs_theta)):
-        for j in range(len(pcs_theta[i])):
-            pcs_theta[i, j] = 0.0
-            pcs_theta_err[i, j] = 0.0
+    pcs_theta[:] = 0.0
+    pcs_theta_err[:] = 0.0
 
     # Loop over the samples.
     num = 0

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=23387&r1=23386&r2=23387&view=diff
==============================================================================
--- branches/frame_order_cleanup/lib/frame_order/rotor.py       (original)
+++ branches/frame_order_cleanup/lib/frame_order/rotor.py       Fri May 23 
16:55:52 2014
@@ -50,9 +50,7 @@
     """
 
     # Zeros.
-    for i in range(9):
-        for j in range(9):
-            matrix[i, j] = 0.0
+    matrix[:] = 0.0
 
     # Repetitive trig calculations.
     sinc_smax = sinc(smax/pi)
@@ -115,10 +113,8 @@
     """
 
     # Clear the data structures.
-    for i in range(len(pcs_theta)):
-        for j in range(len(pcs_theta[i])):
-            pcs_theta[i, j] = 0.0
-            pcs_theta_err[i, j] = 0.0
+    pcs_theta[:] = 0.0
+    pcs_theta_err[:] = 0.0
 
     # Loop over the samples.
     num = 0




Related Messages


Powered by MHonArc, Updated Fri May 23 17:40:02 2014