40#include <visp3/core/vpMatrix.h>
42#ifdef ENABLE_VISP_NAMESPACE
54 std::cout <<
"Rotation vector size differ" << std::endl;
57 for (
unsigned int i = 0;
i < a1.
getRows();
i++) {
58 for (
unsigned int j = 0;
j < a1.
getCols();
j++) {
60 std::cout <<
"Array content differ" << std::endl;
71 std::cout <<
"Rotation vector size differ" << std::endl;
74 for (
unsigned int i = 0;
i < a1.
size();
i++) {
76 std::cout <<
"Rotation vector content differ" << std::endl;
86 std::cout <<
"Column vector size differ" << std::endl;
89 for (
unsigned int i = 0;
i < a1.
size();
i++) {
91 std::cout <<
"Column vector content differ" << std::endl;
101 std::cout <<
"Row vector size differ" << std::endl;
104 for (
unsigned int i = 0;
i < a1.
size();
i++) {
106 std::cout <<
"Row vector content differ" << std::endl;
115 double epsilon = 1
e-10;
117#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
120 std::cout <<
"a:\n" << a << std::endl;
121 a = { -1, -2, -3, 4, 5.5, 6.0f };
122 std::cout <<
"a:\n" << a << std::endl;
124 std::cout <<
"a.reshape(2,3):\n" << a << std::endl;
126 std::cout <<
"a.reshape(3,2):\n" << a << std::endl;
131 std::cout <<
"a2:\n" << a2 << std::endl;
134 std::cout <<
"a3:\n" << a3 << std::endl;
137 std::cout <<
"a4:\n" << a4 << std::endl;
140 a5 = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };
141 std::cout <<
"a5:\n" << a5 << std::endl;
144 std::cout <<
"a6:\n" << a6 << std::endl;
147 std::cout <<
"m:\n" << m << std::endl;
148 m = { -1, -2, -3, -4 };
149 std::cout <<
"m:\n" << m << std::endl;
151 std::cout <<
"m:\n" << m << std::endl;
153 vpMatrix m2(3, 2, { 1, 2, 3, 4, 5, 6 });
154 std::cout <<
"m2:\n" << m2 << std::endl;
156 vpMatrix m3 { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };
157 std::cout <<
"m3:\n" << m3 << std::endl;
160 m4 = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };
161 std::cout <<
"m4:\n" << m4 << std::endl;
164 std::cout <<
"m5:\n" << m5 << std::endl;
175 std::cout <<
"m1:\n" << m1 << std::endl;
177 m1 << -1, -2, -3, -4;
179 std::cout <<
"m1:\n" << m1 << std::endl;
182 m2 << 1, 2, 3, 4, 5, 6, 7, 8, 9;
183 std::cout <<
"m2:\n" << m2 << std::endl;
185 m2.resize(3, 3,
false);
186 std::cout <<
"m2:\n" << m2 << std::endl;
188 m2 << 0.0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11;
190 std::cout <<
"m2:\n" << m2 << std::endl;
194 std::cout <<
"** Test vpColVector" << std::endl;
196 for (
unsigned int i = 0;
i < 6;
i++) {
199 std::cout <<
"c_ref: " << c_ref.t() << std::endl;
200#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
203 std::cout <<
"c: " << c.
t() << std::endl;
204 if (!equal(c_ref, c, epsilon)) {
209 std::cout <<
"c_ref: " << c_ref.t() << std::endl;
211 std::cout <<
"c: " << c.
t() << std::endl;
212 if (!equal(c_ref, c, epsilon)) {
218 std::cout <<
"c1: " << c1.t() << std::endl;
219 if (!equal(c_ref, c1, epsilon)) {
223 std::cout <<
"c1: " << c1.t() << std::endl;
227 std::cout <<
"c2: " << c2.
t() << std::endl;
228 if (!equal(c_ref, c2, epsilon)) {
236 std::cout <<
"c: " << c << std::endl;
240 std::cout <<
"after c.reshape(2, 2): " << c.
t() << std::endl;
242 std::cout <<
"c:" << c << std::endl;
245 std::cerr <<
"Exception expected: c = c.reshape(2, 2);\n" <<
e.what() << std::endl;
248 std::cout <<
"c: " << c.
t() << std::endl;
251 std::cout <<
"ptr_array->reshape(2,2)" << std::endl;
252 std::cout <<
"c: (" << c.
getRows() <<
", " << c.
getCols() <<
"):\n" << c << std::endl;
253 std::cout <<
"dynamic_cast<vpColVector *>(ptr_array):\n" << *
dynamic_cast<vpColVector *
>(ptr_array) << std::endl;
254 std::cout <<
"ptr_array:\n" << *ptr_array << std::endl;
259 std::cout <<
"** Test vpRowVector" << std::endl;
261 for (
unsigned int i = 0;
i < 6;
i++) {
264 std::cout <<
"r_ref: " << r_ref << std::endl;
265#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
268 std::cout <<
"r: " <<
r << std::endl;
269 if (!equal(r_ref, r, epsilon)) {
272 r_ref.resize(3,
false);
274 std::cout <<
"r_ref: " << r_ref << std::endl;
276 std::cout <<
"r: " <<
r << std::endl;
277 if (!equal(r_ref, r, epsilon)) {
283 std::cout <<
"r1: " << r1 << std::endl;
284 if (!equal(r_ref, r1, epsilon)) {
288 std::cout <<
"r1: " << r1 << std::endl;
292 std::cout <<
"r2: " << r2 << std::endl;
293 if (!equal(r_ref, r2, epsilon)) {
301 std::cout <<
"r: " <<
r << std::endl;
304 std::cout <<
"m:\n" << m << std::endl;
308 std::cout <<
"after r.reshape(3, 1): " <<
r << std::endl;
311 std::cerr <<
"Exception: r.reshape(3, 1);\n" <<
e.what() << std::endl;
317 std::cout <<
"** Test vpThetaUVector" << std::endl;
319 std::cout <<
"tu_ref: " << tu_ref.t() << std::endl;
320#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
323 std::cout <<
"tu: " <<
tu.t() << std::endl;
324 if (!equal(tu_ref, tu, epsilon)) {
331 tu << 0, M_PI_2, M_PI;
332 std::cout <<
"tu: " <<
tu.t() << std::endl;
333 if (!equal(tu_ref, tu, epsilon)) {
337 tu << 0, M_PI_2, M_PI;
338 std::cout <<
"tu: " <<
tu.t() << std::endl;
339 if (!equal(tu_ref, tu, epsilon)) {
346 std::cout <<
"** Test vpRxyzVector" << std::endl;
348 std::cout <<
"rxyz_ref: " << rxyz_ref.t() << std::endl;
349#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
352 std::cout <<
"rxyz: " << rxyz.
t() << std::endl;
353 if (!equal(rxyz_ref, rxyz, epsilon)) {
360 rxyz << 0, M_PI_2, M_PI;
361 std::cout <<
"rxyz: " << rxyz.
t() << std::endl;
362 if (!equal(rxyz_ref, rxyz, epsilon)) {
366 rxyz << 0, M_PI_2, M_PI;
367 std::cout <<
"rxyz: " << rxyz.
t() << std::endl;
368 if (!equal(rxyz_ref, rxyz, epsilon)) {
375 std::cout <<
"** Test vpRzyxVector" << std::endl;
377 std::cout <<
"rzyx_ref: " << rzyx_ref.t() << std::endl;
378#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
381 std::cout <<
"rzyx: " << rzyx.
t() << std::endl;
382 if (!equal(rzyx_ref, rzyx, epsilon)) {
389 rzyx << 0, M_PI_2, M_PI;
390 std::cout <<
"rzyx: " << rzyx.
t() << std::endl;
391 if (!equal(rzyx_ref, rzyx, epsilon)) {
395 rzyx << 0, M_PI_2, M_PI;
396 std::cout <<
"rzyx: " << rzyx.
t() << std::endl;
397 if (!equal(rzyx_ref, rzyx, epsilon)) {
404 std::cout <<
"** Test vpRzyzVector" << std::endl;
406 std::cout <<
"rzyz_ref: " << rzyz_ref.t() << std::endl;
407#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
410 std::cout <<
"rzyz: " << rzyz.
t() << std::endl;
411 if (!equal(rzyz_ref, rzyz, epsilon)) {
418 rzyz << 0, M_PI_2, M_PI;
419 std::cout <<
"rzyz: " << rzyz.
t() << std::endl;
420 if (!equal(rzyz_ref, rzyz, epsilon)) {
424 rzyz << 0, M_PI_2, M_PI;
425 std::cout <<
"rzyz: " << rzyz.
t() << std::endl;
426 if (!equal(rzyz_ref, rzyz, epsilon)) {
433 std::cout <<
"** Test vpQuaternionVector" << std::endl;
436 std::cout <<
"q_ref: " << q_ref.t() << std::endl;
437#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
440 std::cout <<
"q: " << q.
t() << std::endl;
441 if (!equal(q_ref, q, epsilon)) {
448 q << q_ref[0], q_ref[1], q_ref[2], q_ref[3];
449 std::cout <<
"q: " << q.
t() << std::endl;
450 if (!equal(q_ref, q, epsilon)) {
454 q << q_ref[0], q_ref[1], q_ref[2], q_ref[3];
455 std::cout <<
"q: " << q.
t() << std::endl;
456 if (!equal(q_ref, q, epsilon)) {
463 std::cout <<
"** Test vpTranslationVector" << std::endl;
465 std::cout <<
"t_ref: " << t_ref.t() << std::endl;
466#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
469 std::cout <<
"t: " <<
t.t() << std::endl;
470 if (!equal(t_ref, t, epsilon)) {
478 std::cout <<
"t: " <<
t.t() << std::endl;
479 if (!equal(t_ref, t, epsilon)) {
484 std::cout <<
"t: " <<
t.t() << std::endl;
485 if (!equal(t_ref, t, epsilon)) {
492 std::cout <<
"** Test vpRotationMatrix" << std::endl;
494 std::cout <<
"R_ref:\n" << R_ref << std::endl;
495#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
498 std::cout <<
"R:\n" <<
R << std::endl;
499 if (!equal(R_ref, R, epsilon)) {
505 R = { 0, 0, -1, 0, -1, 0, -1, 0, 0 };
506 std::cout <<
"R:\n" <<
R << std::endl;
507 if (!equal(R_ref, R, epsilon)) {
514 R << 0, 0, -1, 0, -1, 0, -1, 0, 0;
515 std::cout <<
"R:\n" <<
R << std::endl;
516 if (!equal(R_ref, R, epsilon)) {
520 R << 0, 0, -1, 0, -1, 0, -1, 0, 0;
521 std::cout <<
"R:\n" <<
R << std::endl;
522 if (!equal(R_ref, R, epsilon)) {
529 for (
size_t i = 0;
i < 4; ++
i) {
530 data[
i] =
static_cast<double>(
i);
533 std::cout <<
"M = " << m << std::endl;
537 if (!equal(m1, m, epsilon) || m.
data == m1.
data) {
543 if (!equal(m2, m, epsilon) || m.
data == m2.
data) {
549 std::cout <<
"Test succeed" << std::endl;
Implementation of a generic 2D array used as base class for matrices and vectors.
unsigned int getCols() const
Type * data
Address of the first element of the data array.
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
unsigned int size() const
Return the number of elements of the 2D array.
unsigned int getRows() const
void reshape(unsigned int nrows, unsigned int ncols)
Implementation of column vector and the associated operations.
void reshape(vpMatrix &M, const unsigned int &nrows, const unsigned int &ncols)
error that can be emitted by ViSP classes.
static bool equal(double x, double y, double threshold=0.001)
Implementation of a matrix and operations on matrices.
static vpMatrix view(double *data, unsigned int rows, unsigned int cols)
Create a matrix view of a raw data array. The view can modify the contents of the raw data array,...
Implementation of a rotation vector as quaternion angle minimal representation.
Implementation of a rotation matrix and operations on such kind of matrices.
Implementation of a generic rotation vector.
Implementation of row vector and the associated operations.
void resize(unsigned int i, bool flagNullify=true)
Implementation of a rotation vector as Euler angle minimal representation.
Implementation of a rotation vector as Euler angle minimal representation.
Implementation of a rotation vector as Euler angle minimal representation.
Implementation of a rotation vector as axis-angle minimal representation.
Class that consider the case of a translation vector.