Update to 2.0.0 tree from current Fremantle build
[opencv] / tests / cxts / cxts_math.cpp
index 3e82b8f..8b37c18 100644 (file)
@@ -156,12 +156,23 @@ void cvTsRandUni( CvRNG* rng, CvMat* a, CvScalar param0, CvScalar param1 )
 }
 
 
-void cvTsZero( CvMat* c )
+void cvTsZero( CvMat* c, const CvMat* mask )
 {
-    int i, width;
-    width = c->cols*CV_ELEM_SIZE(c->type);
+    int i, j, elem_size = CV_ELEM_SIZE(c->type), width = c->cols;
+    
     for( i = 0; i < c->rows; i++ )
-        memset( c->data.ptr + i*c->step, 0, width );
+    {
+        if( !mask )
+            memset( c->data.ptr + i*c->step, 0, width*elem_size );
+        else
+        {
+            const uchar* mrow = mask->data.ptr + mask->step*i;
+            uchar* cptr = c->data.ptr + c->step*i;
+            for( j = 0; j < width; j++, cptr += elem_size )
+                if( mrow[j] )
+                    memset( cptr, 0, elem_size );
+        }
+    }
 }
 
 
@@ -1277,7 +1288,7 @@ int cvTsCmpEps( const CvMat* check_arr, const CvMat* etalon, double* _max_diff,
                     goto _exit_;
                 }
                 a_val = fabs(a_val - b_val);
-                threshold = element_wise_relative_error ? fabs(b_val) + 1e-5 : maxval;
+                threshold = element_wise_relative_error ? fabs(b_val) + 1 : maxval;
                 if( a_val > threshold*success_err_level )
                 {
                     maxdiff = a_val/threshold;
@@ -1305,7 +1316,7 @@ int cvTsCmpEps( const CvMat* check_arr, const CvMat* etalon, double* _max_diff,
                     goto _exit_;
                 }
                 a_val = fabs(a_val - b_val);
-                threshold = element_wise_relative_error ? fabs(b_val)+FLT_EPSILON : maxval;
+                threshold = element_wise_relative_error ? fabs(b_val)+1 : maxval;
                 if( a_val > threshold*success_err_level )
                 {
                     maxdiff = a_val/threshold;
@@ -3149,7 +3160,7 @@ void cvTsTransform( const CvMat* a, CvMat* b, const CvMat* transmat, const CvMat
     // prepare cn x (cn + 1) transform matrix
     if( mat_depth == CV_32F )
     {
-        shiftstep = shift && shift->step ? shift->step/sizeof(float) : 1;
+        shiftstep = shift && shift->rows > 1 ? shift->step/sizeof(float) : 1;
         for( i = 0; i < transmat->rows; i++ )
         {
             mat[i*(cn+1) + cn] = 0.;
@@ -3163,7 +3174,7 @@ void cvTsTransform( const CvMat* a, CvMat* b, const CvMat* transmat, const CvMat
     {
         assert( mat_depth == CV_64F );
 
-        shiftstep = shift && shift->step ? shift->step/sizeof(double) : 1;
+        shiftstep = shift && shift->rows > 1 ? shift->step/sizeof(double) : 1;
         for( i = 0; i < transmat->rows; i++ )
         {
             mat[i*(cn+1) + cn] = 0.;