mailr23947 - in /branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings: frame_rotations.log frame_rotations.py


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

Header


Content

Posted by edward on June 13, 2014 - 19:51:
Author: bugman
Date: Fri Jun 13 19:51:26 2014
New Revision: 23947

URL: http://svn.gna.org/viewcvs/relax?rev=23947&view=rev
Log:
Added another timing script for helping with speeding up the frame order 
analysis.

This is for the part where the rotation matrix for each Sobol' integration 
point is shifted into the
eigenframe.


Added:
    
branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/frame_rotations.log
    
branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/frame_rotations.py
      - copied, changed from r23936, 
branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/tensor_projections.py

Added: 
branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/frame_rotations.log
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/frame_rotations.log?rev=23947&view=auto
==============================================================================
--- 
branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/frame_rotations.log
 (added)
+++ 
branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/frame_rotations.log
 Fri Jun 13 19:51:26 2014
@@ -0,0 +1,37 @@
+Original matrices:
+[[[ 1.  2.  3.]
+  [ 2.  3.  4.]
+  [ 3.  4.  5.]]
+
+ [[ 1.  2.  3.]
+  [ 2.  3.  4.]
+  [ 3.  4.  5.]]]
+Shape: (100, 3, 3)
+
+R:
+[[-0.147233   -0.65802651  0.73846026]
+ [ 0.87841732  0.25618968  0.40342268]
+ [-0.45464871  0.70807342  0.54030231]]
+
+
+1st rotation - element by element R.Ri[i].RT.
+Rotations:
+[[[-0.10494087  1.08573414  0.47747559]
+  [ 1.08573414  5.63549417  4.81557522]
+  [ 0.47747559  4.81557522  3.4694467 ]]
+
+ [[-0.10494087  1.08573414  0.47747559]
+  [ 1.08573414  5.63549417  4.81557522]
+  [ 0.47747559  4.81557522  3.4694467 ]]]
+Timing (s): 24.9873549938
+
+2nd rotation - dot of tensordot, and axis swap.
+Rotations:
+[[[-0.10494087  1.08573414  0.47747559]
+  [ 1.08573414  5.63549417  4.81557522]
+  [ 0.47747559  4.81557522  3.4694467 ]]
+
+ [[-0.10494087  1.08573414  0.47747559]
+  [ 1.08573414  5.63549417  4.81557522]
+  [ 0.47747559  4.81557522  3.4694467 ]]]
+Timing (s): 3.01101016998

Copied: 
branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/frame_rotations.py
 (from r23936, 
branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/tensor_projections.py)
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/frame_rotations.py?p2=branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/frame_rotations.py&p1=branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/tensor_projections.py&r1=23936&r2=23947&rev=23947&view=diff
==============================================================================
--- 
branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/tensor_projections.py
       (original)
+++ 
branches/frame_order_cleanup/test_suite/shared_data/frame_order/timings/frame_rotations.py
  Fri Jun 13 19:51:26 2014
@@ -1,9 +1,7 @@
 # Python module imports.
 from numpy import *
-from numpy.linalg import norm
 from os import pardir, sep
 import sys
-from time import sleep
 from timeit import timeit
 
 # Modify the system path.
@@ -13,115 +11,44 @@
 from lib.geometry.rotations import euler_to_R_zyz
 
 
-def proj1(vect, A, N=1, verb=True):
-    d = zeros(len(vect), float64)
+def rot1(Ri, R, RT, N=1, verb=True):
+    d = zeros((len(Ri), 3, 3), float64)
     for i in range(N):
-        for j in xrange(len(vect)):
-            d[j] = dot(vect[j], dot(A, vect[j]))
+        for j in xrange(len(Ri)):
+            d[j] = dot(R, dot(Ri[j], RT))
     if verb:
-        print("\n1st projection - element by element r[i].A.r[i].")
-        print("Proj: %s" % d[:2])
+        print("\n1st rotation - element by element R.Ri[i].RT.")
+        print("Rotations:\n%s" % d[:2])
 
 
-def proj2(vect, A, N=1, verb=True):
+def rot2(Ri, R, RT, N=1, verb=True):
     for i in range(N):
-        d = diagonal(tensordot(vect, tensordot(A, transpose(vect), axes=1), 
axes=1))
+        d = dot(R, tensordot(Ri, RT, axes=1))
+        d = swapaxes(d, 0, 1)
     if verb:
-        print("\n2nd projection - diag of double tensordot.")
-        print("Proj: %s" % d[:2])
+        print("\n2nd rotation - dot of tensordot, and axis swap.")
+        print("Rotations:\n%s" % d[:2])
 
 
-def proj3(vect, A, N=1, verb=True):
-    for i in range(N):
-        d = diagonal(tensordot(tensordot(A, vect, axes=([0],[1])), vect, 
axes=([0],[1])))
-    if verb:
-        print("\n3rd projection - diag of double tensordot, no transpose.")
-        print("Proj: %s" % d[:2])
+# Some 200 3D matrices.
+Ri = array([[1, 2, 3], [2, 3, 4], [3, 4, 5]], float64)
+Ri = tile(Ri, (100, 1, 1))
+if __name__ == '__main__':
+    print("Original matrices:\n%s\nShape: %s" % (Ri[:2], Ri.shape))
 
-
-def proj4(vect, A, N=1, verb=True):
-    d = zeros(len(vect), float64)
-    for i in range(N):
-        a = tensordot(A, vect, axes=([0],[1]))
-        for j in range(len(vect)):
-            d[j] = dot(vect[j], a[:,j])
-    if verb:
-        print("\n4th projection - mixed tensordot() and per-vector dot().")
-        print("Proj: %s" % d[:2])
-
-
-def proj5(vect, A, N=1, verb=True):
-    d = zeros(len(vect), float64)
-    for i in range(N):
-        vect2 = vect**2
-        double_vect = 2.0 * vect
-        for j in xrange(len(vect)):
-            d[j] = vect2[j][0]*A[0, 0] + vect2[j][1]*A[1, 1] + 
vect2[j][2]*(A[2, 2]) + double_vect[j][0]*vect[j][1]*A[0, 1] + 
double_vect[j][0]*vect[j][2]*A[0, 2] + double_vect[j][1]*vect[j][2]*A[1, 2]
-    if verb:
-        print("\n5th projection - expansion and sum.")
-        print("Proj: %s" % d[:2])
-
-
-def proj6(vect, A, N=1, verb=True):
-    d = zeros(len(vect), float64)
-    for i in range(N):
-        d = vect[:,0]**2*A[0, 0] + vect[:,1]**2*A[1, 1] + vect[:,2]**2*(A[2, 
2]) + 2.0*vect[:,0]*vect[:,1]*A[0, 1] + 2.0*vect[:,0]*vect[:,2]*A[0, 2] + 
2.0*vect[:,1]*vect[:,2]*A[1, 2]
-    if verb:
-        print("\n6th projection - expansion.")
-        print("Proj: %s" % d[:2])
-
-
-def proj7(vect, A, N=1, verb=True):
-    d = zeros(len(vect), float64)
-    for i in range(N):
-        vect2 = vect**2
-        double_vect = 2.0 * vect
-        d = vect2[:,0]*A[0, 0] + vect2[:,1]*A[1, 1] + vect2[:,2]*(A[2, 2]) + 
double_vect[:,0]*vect[:,1]*A[0, 1] + double_vect[:,0]*vect[:,2]*A[0, 2] + 
double_vect[:,1]*vect[:,2]*A[1, 2]
-    if verb:
-        print("\n7th projection - expansion with pre-calculation.")
-        print("Proj: %s" % d[:2])
-
-
-# Some 200 vectors.
-vect = array([[1, 2, 3], [2, 2, 2]], float64)
-vect = tile(vect, (100, 1))
+# The rotation matrix.
+R = zeros((3, 3), float64)
+RT = transpose(R)
+euler_to_R_zyz(1, 1, 0.5, R)
 if __name__ == '__main__':
-    print("Original vectors:\n%s\nShape: %s" % (vect[:2], vect.shape))
-
-# Init the alignment tensor.
-A = zeros((3, 3), float64)
-A_5D = [1.42219822168827662867e-04, -1.44543001566521341940e-04, 
-7.07796211648713973798e-04, -6.01619494082773244303e-04, 
2.02008007072950861996e-04]
-A[0, 0] = A_5D[0]
-A[1, 1] = A_5D[1]
-A[2, 2] = -A_5D[0] -A_5D[1]
-A[0, 1] = A[1, 0] = A_5D[2]
-A[0, 2] = A[2, 0] = A_5D[3]
-A[1, 2] = A[2, 1] = A_5D[4]
-A *= 1e4
-if __name__ == '__main__':
-    print("\nTensor:\n%s\n" % A)
+    print("\nR:\n%s\n" % R)
 
 # Projections.
-N = 100
+N = 1000
 M = 100
 if __name__ == '__main__':
-    proj1(vect=vect, A=A, N=1, verb=True)
-    print("Timing (s): %s" % timeit("proj1(vect=vect, A=A, N=N, 
verb=False)", setup="from tensor_projections import proj1, vect, A, N", 
number=M))
+    rot1(Ri=Ri, R=R, RT=RT, N=1, verb=True)
+    print("Timing (s): %s" % timeit("rot1(Ri=Ri, R=R, RT=RT, N=N, 
verb=False)", setup="from frame_rotations import rot1, Ri, R, RT, N", 
number=M))
 
-    proj2(vect=vect, A=A, N=1, verb=True)
-    print("Timing (s): %s" % timeit("proj2(vect=vect, A=A, N=N, 
verb=False)", setup="from tensor_projections import proj2, vect, A, N", 
number=M))
-
-    proj3(vect=vect, A=A, N=1, verb=True)
-    print("Timing (s): %s" % timeit("proj3(vect=vect, A=A, N=N, 
verb=False)", setup="from tensor_projections import proj3, vect, A, N", 
number=M))
-
-    proj4(vect=vect, A=A, N=1, verb=True)
-    print("Timing (s): %s" % timeit("proj4(vect=vect, A=A, N=N, 
verb=False)", setup="from tensor_projections import proj4, vect, A, N", 
number=M))
-
-    proj5(vect=vect, A=A, N=1, verb=True)
-    print("Timing (s): %s" % timeit("proj5(vect=vect, A=A, N=N, 
verb=False)", setup="from tensor_projections import proj5, vect, A, N", 
number=M))
-
-    proj6(vect=vect, A=A, N=1, verb=True)
-    print("Timing (s): %s" % timeit("proj6(vect=vect, A=A, N=N, 
verb=False)", setup="from tensor_projections import proj6, vect, A, N", 
number=M))
-
-    proj7(vect=vect, A=A, N=1, verb=True)
-    print("Timing (s): %s" % timeit("proj7(vect=vect, A=A, N=N, 
verb=False)", setup="from tensor_projections import proj7, vect, A, N", 
number=M))
+    rot2(Ri=Ri, R=R, RT=RT, N=1, verb=True)
+    print("Timing (s): %s" % timeit("rot2(Ri=Ri, R=R, RT=RT, N=N, 
verb=False)", setup="from frame_rotations import rot2, Ri, R, RT, N", 
number=M))




Related Messages


Powered by MHonArc, Updated Fri Jun 13 20:00:03 2014