Permalink
Browse files

added pure c++ test for condassing, apparantly condassign(double,...,…

…double) works differently thant condassign(adouble,...,adouble)
  • Loading branch information...
1 parent ad3cb7b commit b27e9a2f8ed0fd20f10e1e61539eed72cd2f6474 Sebastian committed Feb 22, 2010
View
10 adolc/tests/test_wrapped_functions.py
@@ -181,7 +181,7 @@ def test_double_condassign_if(self):
x = 3.
y = 4.
- cond = 0
+ cond = -1.
x = condassign(x,cond,y)
print x
assert x == 3.
@@ -198,7 +198,7 @@ def test_double_condassign_if_else(self):
x = 3.
y = 4.
z = 5.
- cond = 0
+ cond = -1.
x = condassign(x,cond,y,z)
assert x == 5
@@ -214,7 +214,7 @@ def test_adouble_condassign_if(self):
x = adouble(3.)
y = adouble(4.)
- cond = adouble(0)
+ cond = adouble(-3.)
x = condassign(x,cond,y)
assert x.val == 3.
@@ -231,10 +231,10 @@ def test_adouble_condassign_if_else(self):
x = adouble(3.)
y = adouble(4.)
z = adouble(5.)
- cond = adouble(0.)
+ cond = adouble(-3.)
x = condassign(x,cond,y,z)
- assert x.val == 5
+ assert x.val == 5
class LowLevelFunctionsTests ( TestCase ):
View
25 tests/misc_tests/adolc_tiny_unit_test/SConstruct
@@ -1,12 +1,21 @@
-LIBS = [
- 'adolc',
- ]
+
+adolc_include_path = '/home/b45ch1/workspace/SOLVINDSUITE/Packages/ADOL-C/Src/ADOL-C-2.1.0/ADOL-C/src'
+adolc_library_path = '/home/b45ch1/workspace/SOLVINDSUITE/Packages/ADOL-C/adolc_base/lib'
+
+colpack_include_path = '/home/b45ch1/workspace/SOLVINDSUITE/Packages/ADOL-C/adolc_base/include'
+colpack_library_path = '/home/b45ch1/workspace/SOLVINDSUITE/Packages/ADOL-C/adolc_base/lib'
+
+LIBS = ['adolc',
+ 'ColPack',
+ ]
LIBPATH = [
- '../../../adolc-2.0.0/lib',
- ]
+ adolc_library_path,
+ colpack_library_path,
+ ]
INCLUDEPATH = [
- '../../../adolc-2.0.0/include',
- ]
+ adolc_include_path,
+ colpack_include_path,
+ ]
env = Environment(
CPPPATH = INCLUDEPATH,
@@ -17,5 +26,5 @@ env = Environment(
SHLIBPREFIX="", #gets rid of lib prefix, i.e. get mylib.so instead of libmylib.so
)
Default('.')
-my_executable = env.Program(target='adolc.exe', source=['adolc.cpp'])
+my_executable = env.Program(target='test_adolc.exe', source=['test_adolc.cpp'])
View
63 tests/misc_tests/adolc_tiny_unit_test/adolc.cpp
@@ -1,63 +0,0 @@
-//g++ -Iadolc-1.11.0-trunk/include/ -Wl,--rpath -Wl,${PWD}/adolc-1.11.0-trunk/lib -Ladolc-1.11.0-trunk/lib -ladolc -o test -O3 test.cpp
-
-#include "adolc/adolc.h"
-#include <iostream>
-
-using namespace std;
-
-int test1(){
- /* this test emulates how pyadolc works with adubs:
- when sin(x) is called in Python, it calls
- adub sin ( const badouble& x ) { }
- which returns not an adub object but just a locint.
-
- */
-
- adouble x(2.);
- cout<<"x.loc="<<x.location<<endl;
- adub y1(sin(x).location);
- cout<<"y1.loc="<<y1.location<<endl;
- cout<<"y1="<<y1<<endl;
- adub y2(5.*x);
- cout<<"y2.loc="<<y2.location<<endl;
- cout<<"y2="<<y2<<endl;
-
-// print 'y1.loc=',y1.loc
-// print 'y1=',y1
-// y2 = 5.*x
-// print 'y2.loc=',y2.loc
-// print 'y1=',y1
-// print 'y2=',y2
-
-}
-
-
-int main(){
-// adouble a(1.);
-// adub *b = new adub(-a);
-// b = new adub(operator+(a,2.));
-// adub *c = new adub(operator+(a,2));
-// adub *d = new adub(operator+(2.,a));
-// adub *e = new adub(operator+(2,a));
-//
-//
-// cout<<a<<endl;
-// double *y = myalloc1(1);
-// double x;
-// x = 1.;
-//
-// trace_on(11);
-// ax<<=x;
-// ay = ax;
-// for(int i = 0; i != N; ++i){
-// ay = ay * ay;
-// }
-//
-// ay>>=*y;
-// trace_off();
-//
-// tape_doc(11, 1 , 1, &x, y );
-
- test1();
- return 0;
-}
View
55 tests/misc_tests/adolc_tiny_unit_test/test_adolc.cpp
@@ -0,0 +1,55 @@
+//g++ -Iadolc-1.11.0-trunk/include/ -Wl,--rpath -Wl,${PWD}/adolc-1.11.0-trunk/lib -Ladolc-1.11.0-trunk/lib -ladolc -o test -O3 test.cpp
+
+#include "adolc.h"
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+
+int test_condassign_on_adouble(){
+ adouble a(2.);
+ adouble cond(3.);
+ adouble cond2(-3.);
+ adouble b(4.);
+ adouble c(5.);
+
+ condassign(a,cond,b,c);
+ if(a != b)return -1;
+
+ condassign(a,cond2,b,c);
+ if(a != c)return -1;
+
+ return 0;
+}
+
+int test_condassign_on_double(){
+ double a(2.);
+ double cond(3.);
+ double cond2(-3.);
+ double b(4.);
+ double c(5.);
+
+ condassign(a,cond,b,c);
+ if(a != b) return -1;
+
+ condassign(a,cond2,b,c);
+ if(a != c) return -1;
+
+ return 0;
+}
+
+void check(int error, string test_name){
+ if(error != 0){
+ cout<<"Test "<<test_name<<" : failed!"<<endl;
+ }
+ else{
+ cout<<"Test "<<test_name<<" : OK!"<<endl;
+ }
+}
+
+int main(){
+ check(test_condassign_on_adouble(),"test_condassign_on_adouble");
+ check(test_condassign_on_double(),"test_condassign_on_double");
+ return 0;
+}
View
BIN tests/misc_tests/adolc_tiny_unit_test/test_adolc.exe
Binary file not shown.

0 comments on commit b27e9a2

Please sign in to comment.