toon-members
[Top][All Lists]
Advanced

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

[Toon-members] TooN numdiff.awk regressions/invert.cc regressi...


From: Edward Rosten
Subject: [Toon-members] TooN numdiff.awk regressions/invert.cc regressi...
Date: Wed, 23 Sep 2009 13:43:56 +0000

CVSROOT:        /cvsroot/toon
Module name:    TooN
Changes by:     Edward Rosten <edrosten>        09/09/23 13:43:56

Added files:
        .              : numdiff.awk 
        regressions    : invert.cc slice.cc invert.txt slice.txt 
                         regression.h 

Log message:
        Testing framework.
        
        run make test

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/numdiff.awk?cvsroot=toon&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/TooN/regressions/invert.cc?cvsroot=toon&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/TooN/regressions/slice.cc?cvsroot=toon&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/TooN/regressions/invert.txt?cvsroot=toon&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/TooN/regressions/slice.txt?cvsroot=toon&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/TooN/regressions/regression.h?cvsroot=toon&rev=1.1

Patches:
Index: numdiff.awk
===================================================================
RCS file: numdiff.awk
diff -N numdiff.awk
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ numdiff.awk 23 Sep 2009 13:43:55 -0000      1.1
@@ -0,0 +1,66 @@
+function fail( x)
+{
+       print name " Failed " x
+       exit(0)
+}
+
+function abs(x)
+{
+       return x<0?-x:x
+}
+
+BEGIN{
+       
+       if(t == "")
+               t = 1e-6
+
+       for(;;)
+       {
+               #Get the next non blank line from the two files
+               do
+                status1 = (getline s1 < f1)
+               while(status1 && s1 ~ /^[[:space:]]*$/)
+
+               do
+                status2 = (getline s2 < f2)
+               while(status2 && s2 ~ /^[[:space:]]*$/)
+               
+               #Check to see if the files have both ended
+               if(status1 != status2)
+                       fail("file length mismatch")
+               else if(status1 == 0 && status2 == 0)
+               {
+                       print name " Passed"
+                       exit(0)
+               }
+
+               if(s1 == "Crash!!!" || s2 == "Crash!!!")
+                       fail("Crash!!!")
+
+               #If there are valid lines left, then split them
+               #into fields
+               n1 = split(s1, a1)
+               n2 = split(s2, a2)
+
+               #Check for matching linesize
+               if(n1 != n2)
+                       fail("line length mismatch >>>"s1"<<< >>>"s2"<<<<");
+               
+               #Compare fields
+               for(i=1; i <= n1; i++)
+               {
+                       #If both fields are floats, then use a threshold based
+                       #match otherwise use an exact match
+                       if(a1[i] ~ 
/^-?(([0-9]+\.[0-9]*)|(\.?[0-9]+))([eE][-+][0-9]+)?$/ &&
+                          a2[i] ~ 
/^-?(([0-9]+\.[0-9]*)|(\.?[0-9]+))([eE][-+][0-9]+)?$/)
+                       {
+                               if(abs(a1[i] - a2[i]) > t)
+                                       fail("number  " a1[i] " " a2[i])
+                       }
+                       else if(a1[i] != a2[i])
+                               fail("string >>>"a1[i]"<<< >>>"a2[i]"<<<<")
+               }
+       }
+
+
+}

Index: regressions/invert.cc
===================================================================
RCS file: regressions/invert.cc
diff -N regressions/invert.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ regressions/invert.cc       23 Sep 2009 13:43:55 -0000      1.1
@@ -0,0 +1,7 @@
+#include "regressions/regression.h"
+
+int main()
+{
+       cout << setprecision(10) 
+            << LU<2>(Matrix<2>(Data(1, 2, 3, 4))).get_inverse();
+}

Index: regressions/slice.cc
===================================================================
RCS file: regressions/slice.cc
diff -N regressions/slice.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ regressions/slice.cc        23 Sep 2009 13:43:55 -0000      1.1
@@ -0,0 +1,7 @@
+#include "regressions/regression.h"
+
+int main()
+{
+       Vector<5> v = makeVector(1, 2, 3, 4, 5);
+       cout << v.slice<0,3>() << endl;
+}

Index: regressions/invert.txt
===================================================================
RCS file: regressions/invert.txt
diff -N regressions/invert.txt
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ regressions/invert.txt      23 Sep 2009 13:43:55 -0000      1.1
@@ -0,0 +1,2 @@
+  -2.00000   1.00000
+   1.50000  -0.50000

Index: regressions/slice.txt
===================================================================
RCS file: regressions/slice.txt
diff -N regressions/slice.txt
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ regressions/slice.txt       23 Sep 2009 13:43:55 -0000      1.1
@@ -0,0 +1 @@
+1 2 3

Index: regressions/regression.h
===================================================================
RCS file: regressions/regression.h
diff -N regressions/regression.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ regressions/regression.h    23 Sep 2009 13:43:55 -0000      1.1
@@ -0,0 +1,7 @@
+#include <TooN/TooN.h>
+#include <TooN/LU.h>
+#include <TooN/SVD.h>
+#include <TooN/helpers.h>
+#include <iomanip>
+using namespace std;
+using namespace TooN;




reply via email to

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