1 from __future__
import print_function
4 import matrix
as eigenpy
8 if verbose: print(
"===> From empty MatrixXd to Py")
9 M = eigenpy.emptyMatrix()
10 assert M.shape == (0,0)
12 if verbose: print(
"===> From empty VectorXd to Py")
13 v = eigenpy.emptyVector()
14 assert v.shape == (0,)
16 if verbose: print(
"===> From MatrixXd to Py")
17 M = eigenpy.naturals(3,3,verbose)
18 Mcheck = np.reshape(np.array(range(9),np.double),[3,3])
19 assert np.array_equal(Mcheck,M)
21 if verbose: print(
"===> From Matrix3d to Py")
22 M33= eigenpy.naturals33(verbose)
23 assert np.array_equal(Mcheck,M33)
25 if verbose: print(
"===> From VectorXd to Py")
26 v = eigenpy.naturalsX(3,verbose)
27 vcheck = np.array(range(3),np.double).T
28 assert np.array_equal(vcheck ,v)
30 if verbose: print(
"===> From Py to Eigen::MatrixXd")
31 if verbose: print(
"===> From Py to Eigen::MatrixXd")
32 if verbose: print(
"===> From Py to Eigen::MatrixXd")
33 Mref = np.reshape(np.array(range(64),np.double),[8,8])
36 Mref_from_base = eigenpy.base(Mref)
37 assert( np.array_equal(Mref,Mref_from_base) );
40 Mref_from_plain = eigenpy.plain(Mref)
41 assert( np.array_equal(Mref,Mref_from_plain) );
43 if verbose: print(
"===> Matrix 8x8")
45 assert( np.array_equal(M,eigenpy.reflex(M,verbose)) );
47 if verbose: print(
"===> Block 0:3x0:3")
49 assert( np.array_equal(M,eigenpy.reflex(M,verbose)) );
51 if verbose: print(
"===> Block 1:3x1:3")
53 assert( np.array_equal(M,eigenpy.reflex(M,verbose)) );
55 if verbose: print(
"===> Block 1:5:2x1:5:2")
57 assert( np.array_equal(M,eigenpy.reflex(M,verbose)) );
59 if verbose: print(
"===> Block 1:8:3x1:5")
61 assert( np.array_equal(M,eigenpy.reflex(M,verbose)) );
63 if verbose: print(
"===> Block transpose 1:8:3x1:6:2")
64 M = Mref[1:8:3,0:6:2].T
65 assert( np.array_equal(M,eigenpy.reflex(M,verbose)) );
67 if verbose: print(
"===> Block Vector 1x0:6:2")
69 assert( np.array_equal(M.squeeze(),eigenpy.reflex(M,verbose)) );
71 if verbose: print(
"===> Block Vector 1x0:6:2 tanspose")
73 assert( np.array_equal(M.squeeze(),eigenpy.reflex(M,verbose)) );
75 if verbose: print(
"===> Block Vector 0:6:2x1")
77 assert( np.array_equal(M.squeeze(),eigenpy.reflex(M,verbose)) );
79 if verbose: print(
"===> Block Vector 0:6:2x1 tanspose")
81 assert( np.array_equal(M.squeeze(),eigenpy.reflex(M,verbose)) );
83 if verbose: print(
"===> From Py to Eigen::VectorXd")
84 if verbose: print(
"===> From Py to Eigen::VectorXd")
85 if verbose: print(
"===> From Py to Eigen::VectorXd")
87 if verbose: print(
"===> Block Vector 0:6:2x1 1 dim")
92 if verbose: print(
"===> Block Vector 0:6:2x1")
94 assert( np.array_equal(M.squeeze(),eigenpy.reflexV(M,verbose)) );
96 if verbose: print(
"===> Block Vector 0:6:2x1 transpose")
101 if verbose: print(
"===> From Py to Eigen::Matrix3d")
102 if verbose: print(
"===> From Py to Eigen::Matrix3d")
103 if verbose: print(
"===> From Py to Eigen::Matrix3d")
105 if verbose: print(
"===> Block Vector 0:3x0:6:2 ")
107 assert( np.array_equal(M,eigenpy.reflex33(M,verbose)) );
109 if verbose: print(
"===> Block Vector 0:3x0:6:2 T")
117 if verbose: print(
"===> From Py to Eigen::Vector3d")
118 if verbose: print(
"===> From Py to Eigen::Vector3d")
119 if verbose: print(
"===> From Py to Eigen::Vector3d")
126 mat1x1 = eigenpy.matrix1x1(value)
127 assert(mat1x1.size == 1)
128 assert(mat1x1[0,0] == value)
130 vec1x1 = eigenpy.vector1x1(value)
131 assert(vec1x1.size == 1)
132 assert(vec1x1[0] == value)
135 mat6 = eigenpy.matrix6(0.)
136 assert(mat6.size == 36)