]> rtime.felk.cvut.cz Git - opencv.git/blobdiff - opencv/tests/cxcore/src/amath.cpp
check the matrix condition number in matrix-invert test, since LU method does not...
[opencv.git] / opencv / tests / cxcore / src / amath.cpp
index a8ad7c8f9cff859e967a73fdf473d37e962bd250..b8e26f5538a59f59644cdf330014cb22c937f3e4 100644 (file)
@@ -68,6 +68,7 @@ public:
 protected:
     void get_test_array_types_and_sizes( int test_case_idx, CvSize** sizes, int** types );
     double get_success_error_level( int /*test_case_idx*/, int i, int j );
+    bool test_nd;
 };
 
 
@@ -86,6 +87,7 @@ CxCore_MathTestImpl::CxCore_MathTestImpl( const char* test_name, const char* tes
     whole_size_list = 0;
     depth_list = math_depths;
     cn_list = 0;
+    test_nd = false;
 }
 
 
@@ -110,6 +112,7 @@ void CxCore_MathTestImpl::get_test_array_types_and_sizes( int test_case_idx,
         for( j = 0; j < count; j++ )
             types[i][j] = type;
     }
+    test_nd = cvTsRandInt(rng)%3 == 0;
 }
 
 CxCore_MathTestImpl math_test( "math", "" );
@@ -139,6 +142,7 @@ protected:
     void get_test_array_types_and_sizes( int test_case_idx, CvSize** sizes, int** types );
     void get_minmax_bounds( int i, int j, int type, CvScalar* low, CvScalar* high );
     double get_success_error_level( int /*test_case_idx*/, int i, int j );
+    int prepare_test_case( int test_case );
     void run_func();
     void prepare_to_validation( int test_case_idx );
     int out_type;
@@ -165,9 +169,9 @@ void CxCore_ExpTest::get_test_array_types_and_sizes( int test_case_idx, CvSize**
 {
     CxCore_MathTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
     out_type = types[OUTPUT][0];
-    if( CV_MAT_DEPTH(types[INPUT][0]) == CV_32F && (cvRandInt(ts->get_rng()) & 3) == 0 )
+    /*if( CV_MAT_DEPTH(types[INPUT][0]) == CV_32F && (cvRandInt(ts->get_rng()) & 3) == 0 )
         types[OUTPUT][0] = types[REF_OUTPUT][0] =
-            out_type = (types[INPUT][0] & ~CV_MAT_DEPTH_MASK)|CV_64F;
+            out_type = (types[INPUT][0] & ~CV_MAT_DEPTH_MASK)|CV_64F;*/
 }
 
 void CxCore_ExpTest::get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, CvScalar* low, CvScalar* high )
@@ -180,10 +184,44 @@ void CxCore_ExpTest::get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, CvSc
     *high = cvScalarAll(CV_MAT_DEPTH(out_type)==CV_64F? u : u*0.5);
 }
 
+int CxCore_ExpTest::prepare_test_case( int test_case )
+{
+    int code = CxCore_MathTest::prepare_test_case(test_case);
+    if( code < 0 )
+        return code;
+
+    CvRNG* rng = ts->get_rng();
+
+    int i, j, k, count = cvTsRandInt(rng) % 10;
+    CvMat* src = &test_mat[INPUT][0];
+    int depth = CV_MAT_DEPTH(src->type);
+
+    // add some extremal values
+    for( k = 0; k < count; k++ )
+    {
+        i = cvTsRandInt(rng) % src->rows;
+        j = cvTsRandInt(rng) % (src->cols*CV_MAT_CN(src->type));
+        int sign = cvTsRandInt(rng) % 2 ? 1 : -1;
+        if( depth == CV_32F )
+            ((float*)(src->data.ptr + src->step*i))[j] = FLT_MAX*sign;
+        else
+            ((double*)(src->data.ptr + src->step*i))[j] = DBL_MAX*sign;
+    }
+
+    return code;
+}
+
 
 void CxCore_ExpTest::run_func()
 {
-    cvExp( test_array[INPUT][0], test_array[OUTPUT][0] );
+    if(!test_nd)
+        cvExp( test_array[INPUT][0], test_array[OUTPUT][0] );
+    else
+    {
+        cv::MatND a = cv::cvarrToMatND(test_array[INPUT][0]);
+        cv::MatND b = cv::cvarrToMatND(test_array[OUTPUT][0]);
+        cv::exp(a, b);
+    }
 }
 
 
@@ -246,8 +284,8 @@ CxCore_LogTest::CxCore_LogTest()
 void CxCore_LogTest::get_test_array_types_and_sizes( int test_case_idx, CvSize** sizes, int** types )
 {
     CxCore_MathTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
-    if( CV_MAT_DEPTH(types[INPUT][0]) == CV_32F && (cvRandInt(ts->get_rng()) & 3) == 0 )
-        types[INPUT][0] = (types[INPUT][0] & ~CV_MAT_DEPTH_MASK)|CV_64F;
+    /*if( CV_MAT_DEPTH(types[INPUT][0]) == CV_32F && (cvRandInt(ts->get_rng()) & 3) == 0 )
+        types[INPUT][0] = (types[INPUT][0] & ~CV_MAT_DEPTH_MASK)|CV_64F;*/
 }
 
 
@@ -267,7 +305,14 @@ void CxCore_LogTest::get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, CvSc
 
 void CxCore_LogTest::run_func()
 {
-    cvLog( test_array[INPUT][0], test_array[OUTPUT][0] );
+    if(!test_nd)
+        cvLog( test_array[INPUT][0], test_array[OUTPUT][0] );
+    else
+    {
+        cv::MatND a = cv::cvarrToMatND(test_array[INPUT][0]);
+        cv::MatND b = cv::cvarrToMatND(test_array[OUTPUT][0]);
+        cv::log(a, b);
+    }
 }
 
 
@@ -346,7 +391,7 @@ CxCore_PowTest::CxCore_PowTest()
 void CxCore_PowTest::get_test_array_types_and_sizes( int test_case_idx, CvSize** sizes, int** types )
 {
     CvRNG* rng = ts->get_rng();
-    int depth = cvTsRandInt(rng) % CV_64F;
+    int depth = cvTsRandInt(rng) % (CV_64F+1);
     int cn = cvTsRandInt(rng) % 4 + 1;
     int i, j;
     CvArrTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
@@ -357,8 +402,8 @@ void CxCore_PowTest::get_test_array_types_and_sizes( int test_case_idx, CvSize**
         power = (int)(cvTsRandInt(rng)%21 - 10);
     else
     {
-        i = cvTsRandInt(rng)%16;
-        power = i == 15 ? 0.5 : i == 14 ? -0.5 : cvTsRandReal(rng)*10 - 5;
+        i = cvTsRandInt(rng)%17;
+        power = i == 16 ? 1./3 : i == 15 ? 0.5 : i == 14 ? -0.5 : cvTsRandReal(rng)*10 - 5;
     }
 
     for( i = 0; i < max_arr; i++ )
@@ -368,6 +413,7 @@ void CxCore_PowTest::get_test_array_types_and_sizes( int test_case_idx, CvSize**
         for( j = 0; j < count; j++ )
             types[i][j] = type;
     }
+    test_nd = cvTsRandInt(rng)%3 == 0;
 }
 
 
@@ -444,7 +490,33 @@ void CxCore_PowTest::get_minmax_bounds( int /*i*/, int /*j*/, int type, CvScalar
 
 void CxCore_PowTest::run_func()
 {
-    cvPow( test_array[INPUT][0], test_array[OUTPUT][0], power );
+    if(!test_nd)
+    {
+        if( fabs(power-1./3) <= DBL_EPSILON && CV_MAT_DEPTH(test_mat[INPUT][0].type) == CV_32F )
+        {
+            cv::Mat a(&test_mat[INPUT][0]), b(&test_mat[OUTPUT][0]);
+            
+            a = a.reshape(1);
+            b = b.reshape(1);
+            for( int i = 0; i < a.rows; i++ )
+            {
+                b.at<float>(i,0) = (float)fabs(cvCbrt(a.at<float>(i,0)));
+                for( int j = 1; j < a.cols; j++ )
+                    b.at<float>(i,j) = (float)fabs(cv::cubeRoot(a.at<float>(i,j)));
+            }
+        }
+        else
+            cvPow( test_array[INPUT][0], test_array[OUTPUT][0], power );
+    }
+    else
+    {
+        cv::MatND a = cv::cvarrToMatND(test_array[INPUT][0]);
+        cv::MatND b = cv::cvarrToMatND(test_array[OUTPUT][0]);
+        if(power == 0.5)
+            cv::sqrt(a, b);
+        else
+            cv::pow(a, power, b);
+    }
 }
 
 
@@ -661,8 +733,24 @@ void CxCore_CartToPolarTest::get_test_array_types_and_sizes( int test_case_idx,
 
 void CxCore_CartToPolarTest::run_func()
 {
-    cvCartToPolar( test_array[INPUT][0], test_array[INPUT][1],
-                   test_array[OUTPUT][0], test_array[OUTPUT][1], use_degrees );
+    if(!test_nd)
+    {
+        cvCartToPolar( test_array[INPUT][0], test_array[INPUT][1],
+                    test_array[OUTPUT][0], test_array[OUTPUT][1], use_degrees );
+    }
+    else
+    {
+        cv::Mat X = cv::cvarrToMat(test_array[INPUT][0]);
+        cv::Mat Y = cv::cvarrToMat(test_array[INPUT][1]);
+        cv::Mat mag = test_array[OUTPUT][0] ? cv::cvarrToMat(test_array[OUTPUT][0]) : cv::Mat();
+        cv::Mat ph = test_array[OUTPUT][1] ? cv::cvarrToMat(test_array[OUTPUT][1]) : cv::Mat();
+        if(!mag.data)
+            cv::phase(X, Y, ph, use_degrees != 0);
+        else if(!ph.data)
+            cv::magnitude(X, Y, mag);
+        else
+            cv::cartToPolar(X, Y, mag, ph, use_degrees != 0);
+    }
 }
 
 
@@ -791,8 +879,19 @@ void CxCore_PolarToCartTest::get_test_array_types_and_sizes( int test_case_idx,
 
 void CxCore_PolarToCartTest::run_func()
 {
-    cvPolarToCart( test_array[INPUT][1], test_array[INPUT][0],
-                   test_array[OUTPUT][0], test_array[OUTPUT][1], use_degrees );
+    if(!test_nd)
+    {
+        cvPolarToCart( test_array[INPUT][1], test_array[INPUT][0],
+                    test_array[OUTPUT][0], test_array[OUTPUT][1], use_degrees );
+    }
+    else
+    {
+        cv::Mat X = test_array[OUTPUT][0] ? cv::cvarrToMat(test_array[OUTPUT][0]) : cv::Mat();
+        cv::Mat Y = test_array[OUTPUT][1] ? cv::cvarrToMat(test_array[OUTPUT][1]) : cv::Mat();
+        cv::Mat mag = test_array[INPUT][1] ? cv::cvarrToMat(test_array[INPUT][1]) : cv::Mat();
+        cv::Mat ph = test_array[INPUT][0] ? cv::cvarrToMat(test_array[INPUT][0]) : cv::Mat();
+        cv::polarToCart(mag, ph, X, Y, use_degrees != 0);
+    }
 }
 
 
@@ -1172,12 +1271,14 @@ protected:
     void run_func();
     void prepare_to_validation( int test_case_idx );
     CvScalar alpha;
+    bool test_nd;
 };
 
 CxCore_ScaleAddTest::CxCore_ScaleAddTest() :
-    CxCore_MatrixTest( "matrix-scaleadd", "cvScaleAdd", 3, 1, false, false, 2 )
+    CxCore_MatrixTest( "matrix-scaleadd", "cvScaleAdd", 3, 1, false, false, 4 )
 {
     alpha = cvScalarAll(0);
+    test_nd = false;
 }
 
 
@@ -1185,6 +1286,8 @@ void CxCore_ScaleAddTest::get_test_array_types_and_sizes( int test_case_idx, CvS
 {
     CxCore_MatrixTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
     sizes[INPUT][2] = cvSize(1,1);
+    types[INPUT][2] &= CV_MAT_DEPTH_MASK;
+    test_nd = cvTsRandInt(ts->get_rng()) % 2 != 0;
 }
 
 
@@ -1195,6 +1298,7 @@ void CxCore_ScaleAddTest::get_timing_test_array_types_and_sizes( int test_case_i
     CxCore_MatrixTest::get_timing_test_array_types_and_sizes( test_case_idx, sizes, types,
                                                               whole_sizes, are_images );
     sizes[INPUT][2] = cvSize(1,1);
+    types[INPUT][2] &= CV_MAT_DEPTH_MASK;
 }
 
 
@@ -1203,62 +1307,30 @@ int CxCore_ScaleAddTest::prepare_test_case( int test_case_idx )
     int code = CxCore_MatrixTest::prepare_test_case( test_case_idx );
     if( code > 0 )
         alpha = cvGet1D( &test_mat[INPUT][2], 0 );
+    if( test_nd )
+        alpha.val[1] = 0;
     return code;
 }
 
 
 void CxCore_ScaleAddTest::run_func()
 {
-    cvScaleAdd( test_array[INPUT][0], alpha, test_array[INPUT][1], test_array[OUTPUT][0] );
+    if(!test_nd)
+        cvScaleAdd( test_array[INPUT][0], alpha, test_array[INPUT][1], test_array[OUTPUT][0] );
+    else
+    {
+        cv::MatND c = cv::cvarrToMatND(test_array[OUTPUT][0]);
+        cv::scaleAdd( cv::cvarrToMatND(test_array[INPUT][0]), alpha.val[0],
+                      cv::cvarrToMatND(test_array[INPUT][1]), c);
+    }
 }
 
 
 void CxCore_ScaleAddTest::prepare_to_validation( int )
 {
-    int rows = test_mat[INPUT][0].rows;
-    int type = CV_MAT_TYPE(test_mat[INPUT][0].type);
-    int cn = CV_MAT_CN(type);
-    int ncols = test_mat[INPUT][0].cols*cn;
-    int i, j;
-
-    for( i = 0; i < rows; i++ )
-    {
-        uchar* src1 = test_mat[INPUT][0].data.ptr + test_mat[INPUT][0].step*i;
-        uchar* src2 = test_mat[INPUT][1].data.ptr + test_mat[INPUT][1].step*i;
-        uchar* dst = test_mat[REF_OUTPUT][0].data.ptr + test_mat[REF_OUTPUT][0].step*i;
-
-        switch( type )
-        {
-        case CV_32FC1:
-            for( j = 0; j < ncols; j++ )
-                ((float*)dst)[j] = (float)(((float*)src1)[j]*alpha.val[0] + ((float*)src2)[j]);
-            break;
-        case CV_32FC2:
-            for( j = 0; j < ncols; j += 2 )
-            {
-                double re = ((float*)src1)[j];
-                double im = ((float*)src1)[j+1];
-                ((float*)dst)[j] = (float)(re*alpha.val[0] - im*alpha.val[1] + ((float*)src2)[j]);
-                ((float*)dst)[j+1] = (float)(re*alpha.val[1] + im*alpha.val[0] + ((float*)src2)[j+1]);
-            }
-            break;
-        case CV_64FC1:
-            for( j = 0; j < ncols; j++ )
-                ((double*)dst)[j] = ((double*)src1)[j]*alpha.val[0] + ((double*)src2)[j];
-            break;
-        case CV_64FC2:
-            for( j = 0; j < ncols; j += 2 )
-            {
-                double re = ((double*)src1)[j];
-                double im = ((double*)src1)[j+1];
-                ((double*)dst)[j] = (double)(re*alpha.val[0] - im*alpha.val[1] + ((double*)src2)[j]);
-                ((double*)dst)[j+1] = (double)(re*alpha.val[1] + im*alpha.val[0] + ((double*)src2)[j+1]);
-            }
-            break;
-        default:
-            assert(0);
-        }
-    }
+    cvTsAdd( &test_mat[INPUT][0], cvScalarAll(alpha.val[0]),
+             &test_mat[INPUT][1], cvScalarAll(1.),
+             cvScalarAll(0.), &test_mat[REF_OUTPUT][0], 0 );
 }
 
 CxCore_ScaleAddTest scaleadd_test;
@@ -1293,6 +1365,7 @@ CxCore_GEMMTest::CxCore_GEMMTest() :
     CxCore_MatrixTest( "matrix-gemm", "cvGEMM", 5, 1, false, false, 2 )
 {
     test_case_count = 100;
+    max_log_array_size = 10;
     default_timing_param_names = matrix_gemm_param_names;
     alpha = beta = 0;
 }
@@ -1589,9 +1662,13 @@ protected:
     void get_timing_test_array_types_and_sizes( int test_case_idx,
                                                 CvSize** sizes, int** types,
                                                 CvSize** whole_sizes, bool* are_images );
+    int prepare_test_case( int test_case_idx );
     void print_timing_params( int test_case_idx, char* ptr, int params_left );
     void run_func();
     void prepare_to_validation( int test_case_idx );
+
+    double scale;
+    bool diagMtx;
 };
 
 
@@ -1622,6 +1699,8 @@ void CxCore_TransformTest::get_test_array_types_and_sizes( int test_case_idx, Cv
     types[INPUT][1] = mattype;
     types[INPUT][2] = CV_MAKETYPE(mattype, dst_cn);
 
+    scale = 1./((cvTsRandInt(rng)%4)*50+1);
+
     if( bits & 2 )
     {
         sizes[INPUT][2] = cvSize(0,0);
@@ -1637,6 +1716,7 @@ void CxCore_TransformTest::get_test_array_types_and_sizes( int test_case_idx, Cv
             sizes[INPUT][2] = cvSize(1,dst_cn);
         types[INPUT][2] &= ~CV_MAT_CN_MASK;
     }
+    diagMtx = (bits & 16) != 0;
 
     sizes[INPUT][1] = cvSize(mat_cols,dst_cn);
 }
@@ -1651,8 +1731,26 @@ void CxCore_TransformTest::get_timing_test_array_types_and_sizes( int test_case_
     sizes[INPUT][1] = cvSize(cn + (cn < 4), cn);
     sizes[INPUT][2] = cvSize(0,0);
     types[INPUT][1] = types[INPUT][2] = CV_64FC1;
+    scale = 1./1000;
 }
 
+int CxCore_TransformTest::prepare_test_case( int test_case_idx )
+{
+    int code = CxCore_MatrixTest::prepare_test_case( test_case_idx );
+    if( code > 0 )
+    {
+        cvTsAdd(&test_mat[INPUT][1], cvScalarAll(scale), &test_mat[INPUT][1],
+                cvScalarAll(0), cvScalarAll(0), &test_mat[INPUT][1], 0 );
+        if(diagMtx)
+        {
+            CvMat* w = cvCloneMat(&test_mat[INPUT][1]);
+            cvSetIdentity(w, cvScalarAll(1));
+            cvMul(w, &test_mat[INPUT][1], &test_mat[INPUT][1]);
+            cvReleaseMat(&w);
+        }
+    }
+    return code;
+}
 
 void CxCore_TransformTest::print_timing_params( int test_case_idx, char* ptr, int params_left )
 {
@@ -1699,6 +1797,7 @@ public:
     CxCore_PerspectiveTransformTest();
 protected:
     void get_test_array_types_and_sizes( int test_case_idx, CvSize** sizes, int** types );
+    double get_success_error_level( int test_case_idx, int i, int j );
     void get_timing_test_array_types_and_sizes( int test_case_idx,
                                                 CvSize** sizes, int** types,
                                                 CvSize** whole_sizes, bool* are_images );
@@ -1734,6 +1833,14 @@ void CxCore_PerspectiveTransformTest::get_test_array_types_and_sizes( int test_c
 }
 
 
+double CxCore_PerspectiveTransformTest::get_success_error_level( int test_case_idx, int i, int j )
+{
+    int depth = CV_MAT_DEPTH(test_mat[INPUT][0].type);
+    return depth == CV_32F ? 1e-4 : depth == CV_64F ? 1e-8 :
+               CxCore_MatrixTest::get_success_error_level(test_case_idx, i, j);
+}
+
+
 void CxCore_PerspectiveTransformTest::get_timing_test_array_types_and_sizes( int test_case_idx,
                         CvSize** sizes, int** types, CvSize** whole_sizes, bool* are_images )
 {
@@ -1995,10 +2102,22 @@ void CxCore_CovarMatrixTest::get_test_array_types_and_sizes( int test_case_idx,
     single_matrix = flags & CV_COVAR_ROWS;
     t_flag = (bits & 256) != 0;
 
+    const int min_count = 2;
+
     if( !t_flag )
-        len = sizes[INPUT][0].width, count = sizes[INPUT][0].height;
+    {
+        len = sizes[INPUT][0].width;
+        count = sizes[INPUT][0].height;
+        count = MAX(count, min_count);
+        sizes[INPUT][0] = cvSize(len, count);
+    }
     else
-        len = sizes[INPUT][0].height, count = sizes[INPUT][0].width;
+    {
+        len = sizes[INPUT][0].height;
+        count = sizes[INPUT][0].width;
+        count = MAX(count, min_count);
+        sizes[INPUT][0] = cvSize(count, len);
+    }
 
     if( single_matrix && t_flag )
         flags = (flags & ~CV_COVAR_ROWS) | CV_COVAR_COLS;
@@ -2432,8 +2551,8 @@ int CxCore_InvertTest::prepare_test_case( int test_case_idx )
 
 void CxCore_InvertTest::get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, CvScalar* low, CvScalar* high )
 {
-    *low = cvScalarAll(-2.);
-    *high = cvScalarAll(2.);
+    *low = cvScalarAll(-1.);
+    *high = cvScalarAll(1.);
 }
 
 
@@ -2443,7 +2562,7 @@ void CxCore_InvertTest::run_func()
 }
 
 
-static double cvTsSVDet( CvMat* mat )
+static double cvTsSVDet( CvMat* mat, double* ratio )
 {
     int type = CV_MAT_TYPE(mat->type);
     int i, nm = MIN( mat->rows, mat->cols );
@@ -2456,11 +2575,13 @@ static double cvTsSVDet( CvMat* mat )
     {
         for( i = 0; i < nm; i++ )
             det *= w->data.fl[i];
+        *ratio = w->data.fl[nm-1] < FLT_EPSILON ? FLT_MAX : w->data.fl[0]/w->data.fl[nm-1];
     }
     else
     {
         for( i = 0; i < nm; i++ )
             det *= w->data.db[i];
+        *ratio = w->data.db[nm-1] < FLT_EPSILON ? DBL_MAX : w->data.db[0]/w->data.db[nm-1];
     }
 
     cvReleaseMat( &w );
@@ -2470,8 +2591,9 @@ static double cvTsSVDet( CvMat* mat )
 void CxCore_InvertTest::prepare_to_validation( int )
 {
     CvMat* input = &test_mat[INPUT][0];
-    double det = method != CV_LU ? cvTsSVDet( input ) : 0;
-    double threshold = (CV_MAT_DEPTH(input->type) == CV_32F ? FLT_EPSILON : DBL_EPSILON)*100;
+    double ratio = 0, det = cvTsSVDet( input, &ratio );
+    double threshold = (CV_MAT_DEPTH(input->type) == CV_32F ? FLT_EPSILON : DBL_EPSILON)*500;
+    double rthreshold = CV_MAT_DEPTH(input->type) == CV_32F ? 1e6 : 1e12;
 
     if( CV_MAT_TYPE(input->type) == CV_32FC1 )
         cvTsConvert( input, &test_mat[TEMP][1] );
@@ -2479,7 +2601,9 @@ void CxCore_InvertTest::prepare_to_validation( int )
         cvTsCopy( input, &test_mat[TEMP][1], 0 );
 
     if( (method == CV_LU && result == 0) ||
-        ((method != CV_LU && det < threshold) || result < threshold) )
+        det < threshold ||
+        (method == CV_LU && ratio > rthreshold) ||
+        (method == CV_SVD && result < threshold) )
     {
         cvTsZero( &test_mat[OUTPUT][0] );
         cvTsZero( &test_mat[REF_OUTPUT][0] );
@@ -2677,6 +2801,7 @@ protected:
     void get_timing_test_array_types_and_sizes( int test_case_idx,
                                                 CvSize** sizes, int** types,
                                                 CvSize** whole_sizes, bool* are_images );
+    double get_success_error_level( int test_case_idx, int i, int j );
     int write_default_params( CvFileStorage* fs );
     void print_timing_params( int test_case_idx, char* ptr, int params_left );
     void get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, CvScalar* low, CvScalar* high );
@@ -2854,6 +2979,14 @@ void CxCore_SVDTest::get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, CvSc
     *high = cvScalarAll(2.);
 }
 
+double CxCore_SVDTest::get_success_error_level( int test_case_idx, int i, int j )
+{
+    int input_depth = CV_MAT_DEPTH(cvGetElemType( test_array[INPUT][0] ));
+    double input_precision = input_depth < CV_32F ? 0 : input_depth == CV_32F ?
+                            5e-5 : 5e-11;
+    double output_precision = CvArrTest::get_success_error_level( test_case_idx, i, j );
+    return MAX(input_precision, output_precision);
+}
 
 void CxCore_SVDTest::run_func()
 {