1 from __future__
import print_function
4 import matrix
as eigenpy
9 print(
"===> From empty MatrixXd to Py")
10 M = eigenpy.emptyMatrix()
11 assert M.shape == (0, 0)
14 print(
"===> From empty VectorXd to Py")
15 v = eigenpy.emptyVector()
16 assert v.shape == (0,)
19 print(
"===> From Py to Matrix1")
20 eigenpy.matrix1x1(np.array([1]))
23 print(
"===> From MatrixXd to Py")
24 M = eigenpy.naturals(3, 3, verbose)
25 Mcheck = np.reshape(np.array(range(9), np.double), [3, 3])
26 assert np.array_equal(Mcheck, M)
29 print(
"===> From Matrix3d to Py")
30 M33 = eigenpy.naturals33(verbose)
31 assert np.array_equal(Mcheck, M33)
34 print(
"===> From VectorXd to Py")
35 v = eigenpy.naturalsX(3, verbose)
36 vcheck = np.array(range(3), np.double).T
37 assert np.array_equal(vcheck, v)
40 print(
"===> From Py to Eigen::MatrixXd")
42 print(
"===> From Py to Eigen::MatrixXd")
44 print(
"===> From Py to Eigen::MatrixXd")
45 Mref = np.reshape(np.array(range(64), np.double), [8, 8])
48 Mref_from_base = eigenpy.base(Mref)
49 assert np.array_equal(Mref, Mref_from_base)
52 Mref_from_plain = eigenpy.plain(Mref)
53 assert np.array_equal(Mref, Mref_from_plain)
56 print(
"===> Matrix 8x8")
58 assert np.array_equal(M, eigenpy.reflex(M, verbose))
61 print(
"===> Block 0:3x0:3")
63 assert np.array_equal(M, eigenpy.reflex(M, verbose))
66 print(
"===> Block 1:3x1:3")
68 assert np.array_equal(M, eigenpy.reflex(M, verbose))
71 print(
"===> Block 1:5:2x1:5:2")
72 M = Mref[1:5:2, 1:5:2]
73 assert np.array_equal(M, eigenpy.reflex(M, verbose))
76 print(
"===> Block 1:8:3x1:5")
78 assert np.array_equal(M, eigenpy.reflex(M, verbose))
81 print(
"===> Block transpose 1:8:3x1:6:2")
82 M = Mref[1:8:3, 0:6:2].T
83 assert np.array_equal(M, eigenpy.reflex(M, verbose))
86 print(
"===> Block Vector 1x0:6:2")
88 assert np.array_equal(M.squeeze(), eigenpy.reflex(M, verbose))
91 print(
"===> Block Vector 1x0:6:2 tanspose")
92 M = Mref[1:2, 0:6:2].T
93 assert np.array_equal(M.squeeze(), eigenpy.reflex(M, verbose))
96 print(
"===> Block Vector 0:6:2x1")
98 assert np.array_equal(M.squeeze(), eigenpy.reflex(M, verbose))
101 print(
"===> Block Vector 0:6:2x1 tanspose")
102 M = Mref[0:6:2, 1:2].T
103 assert np.array_equal(M.squeeze(), eigenpy.reflex(M, verbose))
106 print(
"===> From Py to Eigen::VectorXd")
108 print(
"===> From Py to Eigen::VectorXd")
110 print(
"===> From Py to Eigen::VectorXd")
113 print(
"===> Block Vector 0:6:2x1 1 dim")
119 print(
"===> Block Vector 0:6:2x1")
121 assert np.array_equal(M.squeeze(), eigenpy.reflexV(M, verbose))
124 print(
"===> Block Vector 0:6:2x1 transpose")
125 M = Mref[0:6:2, 1:2].T
130 print(
"===> From Py to Eigen::Matrix3d")
132 print(
"===> From Py to Eigen::Matrix3d")
134 print(
"===> From Py to Eigen::Matrix3d")
137 print(
"===> Block Vector 0:3x0:6:2 ")
139 assert np.array_equal(M, eigenpy.reflex33(M, verbose))
142 print(
"===> Block Vector 0:3x0:6:2 T")
151 print(
"===> From Py to Eigen::Vector3d")
153 print(
"===> From Py to Eigen::Vector3d")
155 print(
"===> From Py to Eigen::Vector3d")
162 mat1x1 = eigenpy.matrix1x1(value)
163 assert mat1x1.size == 1
164 assert mat1x1[0, 0] == value
166 vec1x1 = eigenpy.vector1x1(value)
167 assert vec1x1.size == 1
168 assert vec1x1[0] == value
171 mat6 = eigenpy.matrix6(0.0)
172 assert mat6.size == 36
176 mat = np.arange(0, 10).reshape(2, 5)
177 assert (eigenpy.asRowMajorFromColMajorMatrix(mat) == mat).all()
178 assert (eigenpy.asRowMajorFromRowMajorMatrix(mat) == mat).all()
180 vec = np.arange(0, 10)
181 assert (eigenpy.asRowMajorFromColMajorMatrix(vec) == vec).all()
182 assert (eigenpy.asRowMajorFromColMajorVector(vec) == vec).all()
183 assert (eigenpy.asRowMajorFromRowMajorMatrix(vec) == vec).all()
184 assert (eigenpy.asRowMajorFromRowMajorVector(vec) == vec).all()
void print(const Tensor &tensor)