bench-switch.py
Go to the documentation of this file.
1 from __future__ import print_function
2 
3 import eigenpy
4 import numpy as np
5 
6 import time
7 import timeit
8 
9 from IPython import get_ipython
10 ipython = get_ipython()
11 
12 quat = eigenpy.Quaternion()
13 a = [0., 0., 0.]
14 
15 cmd1 = "timeit np.array(a)"
16 print("\n")
17 print(cmd1)
18 ipython.magic(cmd1)
19 print("\n")
20 
21 cmd2 = "timeit np.matrix(a)"
22 print(cmd2)
23 ipython.magic(cmd2)
24 print("\n")
25 
26 eigenpy.switchToNumpyMatrix()
27 print("----------------------")
28 print("switch to numpy matrix")
29 print("----------------------")
30 print("\n")
31 
32 cmd3 = "timeit quat.coeffs()"
33 print(cmd3)
34 ipython.magic(cmd3)
35 print("\n")
36 
37 eigenpy.switchToNumpyArray()
38 print("---------------------")
39 print("switch to numpy array")
40 print("---------------------")
41 print("\n")
42 
43 cmd4 = "timeit quat.coeffs()"
44 print(cmd4)
45 ipython.magic(cmd4)
46 print("\n")
47 
48 cmd5 = "timeit np.asmatrix(quat.coeffs())"
49 print(cmd5)
50 ipython.magic(cmd5)
51 print("\n")
52 
53 a_matrix = np.matrix(a);
54 cmd6 = "timeit np.asarray(a_matrix)"
55 print(cmd6)
56 ipython.magic(cmd6)
57 print("\n")


eigenpy
Author(s): Justin Carpentier, Nicolas Mansard
autogenerated on Sat Apr 17 2021 02:37:59