commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 02/09: volk: fixup QA's fcompare to test al


From: git
Subject: [Commit-gnuradio] [gnuradio] 02/09: volk: fixup QA's fcompare to test all differences
Date: Tue, 28 Jan 2014 20:10:55 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch maint
in repository gnuradio.

commit 01bd2af9635808c52bc9378ef82acb6df6ce0f6f
Author: Nathan West <address@hidden>
Date:   Mon Jan 27 14:58:30 2014 -0600

    volk: fixup QA's fcompare to test all differences
    
    This addresses bug 627 by adding a fabs call when checking if a number
    is close to 0. If this is the case we also make sure the other buffer
    is within tolerance. For the normal test case wrap the percent difference
    in fabs rather than just the difference.
---
 volk/lib/qa_utils.cc | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/volk/lib/qa_utils.cc b/volk/lib/qa_utils.cc
index 9bf4b71..d5d2d7c 100644
--- a/volk/lib/qa_utils.cc
+++ b/volk/lib/qa_utils.cc
@@ -231,8 +231,19 @@ bool fcompare(t *in1, t *in2, unsigned int vlen, float 
tol) {
     bool fail = false;
     int print_max_errs = 10;
     for(unsigned int i=0; i<vlen; i++) {
-        if(((t *)(in1))[i] < 1e-30) continue; //this is a hack: below around 
here we'll start to get roundoff errors due to limited precision
-        if(fabs(((t *)(in1))[i] - ((t *)(in2))[i])/(((t *)in1)[i]) > tol) {
+        // for very small numbers we'll see round off errors due to limited 
+        // precision. So a special test case... 
+        if(fabs(((t *)(in1))[i]) < 1e-30) {
+            if( fabs( ((t *)(in2))[i] ) > tol )
+            {
+                fail=true;
+                if(print_max_errs-- > 0) {
+                    std::cout << "offset " << i << " in1: " << t(((t 
*)(in1))[i]) << " in2: " << t(((t *)(in2))[i]) << std::endl;
+                }
+            }
+        }
+        // the primary test is the percent different greater than given tol
+        else if(fabs(((t *)(in1))[i] - ((t *)(in2))[i])/(((t *)in1)[i]) > tol) 
{
             fail=true;
             if(print_max_errs-- > 0) {
                 std::cout << "offset " << i << " in1: " << t(((t *)(in1))[i]) 
<< " in2: " << t(((t *)(in2))[i]) << std::endl;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]