Changeset 2237 for trunk/test_more


Ignore:
Timestamp:
Dec 28, 2011 6:47:15 AM (8 years ago)
Author:
bradbell
Message:

abs.sh: Demonstrate bug in multi-level abs function.
build.sh: copy configure.hpp from work directory to source.
mul_level.cpp: add abs test case but ifdef it out (does not work yet).
test_one.sh.in: proper handleing of lib64 (copied from example dir).

Location:
trunk/test_more
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test_more/mul_level.cpp

    r2031 r2237  
    261261}
    262262
     263// supress this test until ../bug/abs.sh is fixed
     264# ifdef CPPAD_NOT_DEFINED
     265bool abs(void)
     266{       bool ok = true;
     267        using CppAD::AD;
     268        using CppAD::Independent;
     269        using CppAD::ADFun;
     270        double eps = std::numeric_limits<double>::epsilon();
     271
     272
     273        typedef AD<double>      ADdouble; // for first level of taping
     274        typedef AD<ADdouble>   ADDdouble; // for second level of taping
     275        size_t n = 1;         // number independent variables
     276        size_t m = 1;         // number dependent and independent variables
     277
     278        CPPAD_TEST_VECTOR<double>       x(n),   y(m);
     279        CPPAD_TEST_VECTOR<ADdouble>    ax(n),  ay(m);
     280        CPPAD_TEST_VECTOR<ADDdouble>  aax(n), aay(m);
     281
     282        // create af(x) = abs(x)
     283        aax[0] = 1.;
     284        Independent( aax );
     285        aay[0] = abs(aax[0]);
     286        ADFun<ADdouble> af(aax, aay);
     287
     288        // create g(x) = af'(x)
     289        ax[0] = 1.;
     290        Independent( ax );
     291        ay = af.Jacobian(ax);
     292        ADFun<double> g(ax, ay);
     293
     294        // evaluate g(x) at same x as recording
     295        x[0] = 1.;
     296        y = g.Forward(0, x);
     297
     298        // check result
     299        double check  = 1.;
     300        ok &= CppAD::NearEqual(y[0], check, eps, eps);
     301
     302        // evaluate g(x) at different x from recording
     303        // (but abs is an atomic operation so derivative should work)
     304        x[0] = -1.;
     305        y = g.Forward(0, x);
     306
     307        // check result
     308        check  = -1.;
     309        ok &= CppAD::NearEqual(y[0], check, eps, eps);
     310
     311        return ok;
     312}
     313# endif
     314
    263315} // END empty namespace
    264316
     
    271323# endif
    272324        ok     &= std_math();
    273 
    274         return ok;
    275 }
     325# ifdef CPPAD_NOT_DEFINED
     326        ok     &= abs();
     327# endif
     328
     329        return ok;
     330}
  • trunk/test_more/test_one.sh.in

    r1771 r2237  
    4040        -I.. -I/usr/include/boost-1_33_1
    4141"
    42 if [ -e @ADOLC_DIR@/include/adolc/adouble.h ]
     42if [ -e @ADOLC_DIR@/include ]
    4343then
    44         cmd="$cmd -I@ADOLC_DIR@/include -L@ADOLC_DIR@/lib -ladolc"
     44        cmd="$cmd -I@ADOLC_DIR@/include"
    4545fi
    46 if [ -e @IPOPT_DIR@/lib/libipopt.a ]
     46if [ -e @IPOPT_DIR@/include ]
    4747then
    4848        cmd="$cmd -I@IPOPT_DIR@/include"
    49         cmd="$cmd -L@IPOPT_DIR@/lib -lipopt"
    50         cmd="$cmd @FCLIBS@ @PTHREAD_LIB@ @DL_LIB@"
    51         export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:@IPOPT_DIR@/lib"
    5249fi
     50for lib in lib lib64
     51do
     52        if [ -e @ADOLC_DIR@/$lib ]
     53        then
     54                cmd="$cmd -L@ADOLC_DIR@/$lib -ladolc"
     55                export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:@ADOLC_DIR@/$lib"
     56        fi
     57        if [ -e @IPOPT_DIR@/$lib ]
     58        then
     59                cmd="$cmd -L@IPOPT_DIR@/$lib -lipopt"
     60                cmd="$cmd @FCLIBS@ @PTHREAD_LIB@ @DL_LIB@"
     61                export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:@IPOPT_DIR@/$lib"
     62        fi
     63done
    5364if [ "$1" == 'ndebug.cpp' ]
    5465then
Note: See TracChangeset for help on using the changeset viewer.