48 #include <visp3/core/vpTranslationVector.h> 50 template<
typename Type>
51 bool test(
const std::string &s,
const vpArray2D<Type> &A,
const std::vector<Type> &bench)
53 static unsigned int cpt = 0;
54 std::cout <<
"** Test " << ++cpt << std::endl;
55 std::cout << s <<
"(" << A.
getRows() <<
"," << A.
getCols() <<
") = \n" << A << std::endl;
56 if(bench.size() != A.
size()) {
57 std::cout <<
"Test fails: bad size wrt bench" << std::endl;
60 for (
unsigned int i=0; i<A.
size(); i++) {
61 if (std::fabs(A.
data[i]-bench[i]) > std::fabs(A.
data[i])*std::numeric_limits<double>::epsilon()) {
62 std::cout <<
"Test fails: bad content" << std::endl;
76 std::vector<double> bench;
77 if (test(
"A", A, bench) ==
false)
84 std::vector<double> bench(12);
85 for(
unsigned int i=0; i<3; i++) {
86 for(
unsigned int j=0; j<4; j++) {
87 A[i][j] = (double)(i+j);
88 bench[i*4+j] = (double)(i+j);
91 if (test(
"A", A, bench) ==
false)
95 if (test(
"B", B, bench) ==
false)
97 std::cout <<
"Min/Max: " << B.getMinValue() <<
" " << B.getMaxValue() << std::endl;
102 std::vector<double> bench1(12, 2);
103 if (test(
"A", A, bench1) ==
false)
107 std::vector<double> bench2(30, 0);
108 if (test(
"A", A, bench2) ==
false)
112 std::vector<double> bench3(30, -2);
113 if (test(
"A", A, bench3) ==
false)
121 std::vector<float> bench;
122 if (test(
"A", A, bench) ==
false)
129 std::vector<float> bench(12);
130 for(
unsigned int i=0; i<3; i++) {
131 for(
unsigned int j=0; j<4; j++) {
132 A[i][j] = (float)(i+j);
133 bench[i*4+j] = (float)(i+j);
136 if (test(
"A", A, bench) ==
false)
140 if (test(
"B", B, bench) ==
false)
142 std::cout <<
"Min/Max: " << B.getMinValue() <<
" " << B.getMaxValue() << std::endl;
147 std::vector<float> bench1(12, 2);
148 if (test(
"A", A, bench1) ==
false)
152 std::vector<float> bench2(30, 0);
153 if (test(
"A", A, bench2) ==
false)
157 std::vector<float> bench3(30, -2);
158 if (test(
"A", A, bench3) ==
false)
161 std::cout <<
"All tests succeed" << std::endl;
void resize(const unsigned int nrows, const unsigned int ncols, const bool flagNullify=true)
unsigned int getRows() const
Return the number of rows of the 2D array.
Type * data
Address of the first element of the data array.
Implementation of a generic 2D array used as vase class of matrices and vectors.
unsigned int size() const
Return the number of elements of the 2D array.
unsigned int getCols() const
Return the number of columns of the 2D array.