45 #include <visp3/core/vpTime.h>
47 #include <visp3/core/vpMatrix.h>
48 #include <visp3/core/vpColVector.h>
54 bool testSvdOpenCvGSLCoherence(
double epsilon);
56 bool testRandom(
double epsilon);
60 #define abs(x) ((x) < 0 ? - (x) : (x))
63 bool testRandom(
double epsilon)
68 for (
unsigned int i=0 ; i < L0.getRows() ; i++)
69 for (
unsigned int j=0 ; j < L0.getCols() ; j++)
70 L1[i][j] = L0[i][j] = (
double)rand()/(double)RAND_MAX;
73 vpMatrix V0(L0.getCols(), L0.getCols()) ;
75 vpMatrix V1(L1.getCols(), L1.getCols()) ;
86 for(
unsigned int i=0;i<6;i++)
87 error=std::max(abs(diff[i]),error);
95 bool testSvdOpenCvGSLCoherence(
double epsilon)
97 #if (VISP_HAVE_OPENCV_VERSION >= 0x020101) && defined (VISP_HAVE_GSL) // Require opencv >= 2.1.1
111 for (
unsigned int i=0 ; i < A.
getRows() ; i++)
112 for (
unsigned int j=0 ; j < A.
getCols() ; j++)
113 B[i][j] = A[i][j] = (
double)rand()/(double)RAND_MAX;
119 for (
unsigned int i=0 ; i < A.
getRows() ; i++){
120 error = error | (abs(wA[i]-wB[i])>epsilon);
135 for (
unsigned int i=0 ; i < L.getRows() ; i++)
136 for (
unsigned int j=0 ; j < L.getCols() ; j++)
137 L[i][j] = 2*i+j + cos((
double)(i+j))+((double)(i)) ;
140 std::cout <<
"--------------------------------------"<<std::endl ;
143 vpMatrix V(L.getCols(), L.getCols()) ;
149 std::cout <<
"svdNr Numerical recipes \n time " <<t << std::endl;
151 std::cout <<
"--------------------------------------"<<std::endl ;
159 std::cout <<
"svdGsl_mod \n time " <<t << std::endl;
162 std::cout <<
"--------------------------------------"<<std::endl ;
163 std::cout <<
"TESTING RANDOM MATRICES:" ;
166 for(
unsigned int i=0;i<2000;i++)
167 ret = ret & testRandom(0.00001);
169 std:: cout <<
"Success"<< std:: endl;
171 std:: cout <<
"Fail"<< std:: endl;
173 std::cout <<
"--------------------------------------"<<std::endl ;
176 std::cout <<
"--------------------------------------"<<std::endl ;
177 std::cout <<
"TESTING OPENCV-GSL coherence:" ;
180 for(
unsigned int i=0;i<1;i++)
181 ret2 = ret2 & testSvdOpenCvGSLCoherence(0.00001);
183 std:: cout <<
"Success"<< std:: endl;
185 std:: cout <<
"Fail"<< std:: endl;
187 std::cout <<
"--------------------------------------"<<std::endl ;
193 std::cout <<
"svdFlake\n time " <<t << std::endl;
198 std::cout <<
"Catch an exception: " << e << std::endl;
Implementation of a matrix and operations on matrices.
void resize(const unsigned int nrows, const unsigned int ncols, const bool flagNullify=true)
static vpColVector sort(const vpColVector &v)
error that can be emited by ViSP classes.
unsigned int getCols() const
Return the number of columns of the 2D array.
VISP_EXPORT double measureTimeMs()
unsigned int getRows() const
Return the number of rows of the 2D array.
Implementation of column vector and the associated operations.
void resize(const unsigned int i, const bool flagNullify=true)