[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Toon-members] TooN Makefile.in numdiff.awk regressions/comple...
From: |
Edward Rosten |
Subject: |
[Toon-members] TooN Makefile.in numdiff.awk regressions/comple... |
Date: |
Mon, 01 Feb 2010 19:35:17 +0000 |
CVSROOT: /cvsroot/toon
Module name: TooN
Changes by: Edward Rosten <edrosten> 10/02/01 19:35:17
Modified files:
. : Makefile.in numdiff.awk
Added files:
regressions : complex.cc complex.txt
Log message:
Regression test for complex numbers.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/Makefile.in?cvsroot=toon&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/TooN/numdiff.awk?cvsroot=toon&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/TooN/regressions/complex.cc?cvsroot=toon&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/TooN/regressions/complex.txt?cvsroot=toon&rev=1.1
Patches:
Index: Makefile.in
===================================================================
RCS file: /cvsroot/toon/TooN/Makefile.in,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- Makefile.in 19 Jan 2010 10:28:09 -0000 1.24
+++ Makefile.in 1 Feb 2010 19:35:17 -0000 1.25
@@ -36,7 +36,7 @@
doxygen
-TESTS=lu slice vector_resize gauss_jordan eigen-sqrt determinant chol_toon
chol_lapack simplex sym_eigen fill so3
+TESTS=lu slice vector_resize gauss_jordan eigen-sqrt determinant chol_toon
chol_lapack simplex sym_eigen fill so3 complex
TEST_RESULT=$(TESTS:%=regressions/%.result)
Index: numdiff.awk
===================================================================
RCS file: /cvsroot/toon/TooN/numdiff.awk,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- numdiff.awk 21 Oct 2009 12:35:06 -0000 1.4
+++ numdiff.awk 1 Feb 2010 19:35:17 -0000 1.5
@@ -9,6 +9,29 @@
return x<0?-x:x
}
+
+function isfloat(x)
+{
+ return x ~ /^-?(([0-9]+\.[0-9]*)|(\.?[0-9]+))([eE][-+][0-9]+)?$/
+}
+
+function iscomplex(x)
+{
+ return x ~
/^\(-?(([0-9]+\.[0-9]*)|(\.?[0-9]+))([eE][-+][0-9]+)?,-?(([0-9]+\.[0-9]*)|(\.?[0-9]+))([eE][-+][0-9]+)?\)$/
+}
+
+function complexdiff(a, b, as, bs)
+{
+ gsub(/[()]/,"", a)
+ sub(/,/," ", a)
+ gsub(/[()]/,"", b)
+ sub(/,/," ", b)
+ split(a, as)
+ split(b, bs)
+
+ return abs(as[1] - bs[1]) + abs(as[2] - bs[2]);
+}
+
function ignore_and_process(line, a)
{
if(line ~ /^[[:space:]]*$/) #Ignore blank linkes
@@ -90,12 +113,16 @@
{
#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(isfloat(a1[i]) && isfloat(a2[i]))
{
if(abs(a1[i] - a2[i]) > t)
fail("number " a1[i] " " a2[i])
}
+ else if(iscomplex(a1[i]) && iscomplex(a2[i]))
+ {
+ if(complexdiff(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/complex.cc
===================================================================
RCS file: regressions/complex.cc
diff -N regressions/complex.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ regressions/complex.cc 1 Feb 2010 19:35:17 -0000 1.1
@@ -0,0 +1,37 @@
+#include <complex>
+#include "regressions/regression.h"
+#include <TooN/internal/planar_complex.hh>
+
+int main()
+{
+ complex<double> i(0,1);
+
+ Vector<3, complex<double> > v1 = makeVector<complex<double> >(1.+i,
1.+2.*i, 3);
+ Vector<3, complex<double> > v2 = makeVector<complex<double> >(1.-i,
1.-2.*i, 3);
+
+ cout << v2 * v1 << endl;
+ cout << v2.as_diagonal() * v1 << endl;
+
+
+ double re2[] = {1, 1, 3};
+ double im2[] = {-1, -2, 0};
+
+ Vector<3, complex<double>, ReferencePlanarComplex> v2ish(make_pair(re2,
im2));
+ cout << v1 * v2ish << endl;
+
+ double real[] = {1,2,3,4};
+ double imag[] = {5,6,7,8};
+
+
+ Vector<4, complex<double>, ReferencePlanarComplex> vec(make_pair(real,
imag));
+
+ cout << vec << endl;
+ cout << vec.slice<1,3>() << endl;
+ cout << vec.slice(2,2) << endl;
+
+ real[3] = 28;
+ imag[3] = 10;
+
+ cout << vec << endl;
+
+}
Index: regressions/complex.txt
===================================================================
RCS file: regressions/complex.txt
diff -N regressions/complex.txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ regressions/complex.txt 1 Feb 2010 19:35:17 -0000 1.1
@@ -0,0 +1,9 @@
+(16,0)
+(2,0) (5,0) (9,0)
+
+(16,0)
+
+(1,5) (2,6) (3,7) (4,8)
+(2,6) (3,7) (4,8)
+(3,7) (4,8)
+(1,5) (2,6) (3,7) (28,10)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Toon-members] TooN Makefile.in numdiff.awk regressions/comple...,
Edward Rosten <=