Changeset 3922 for trunk/test_more


Ignore:
Timestamp:
May 15, 2017 2:40:10 AM (3 years ago)
Author:
bradbell
Message:

merge to branch: trunk
from repository: https://github.com/coin-or/CppAD
start hash code: 7c6be616382d4f09bbb66749143820f9364b43f7
end hash code: 3f17dccb8fad7806e6519c2d9a3d62203fb0740c

commit 3f17dccb8fad7806e6519c2d9a3d62203fb0740c
Author: Brad Bell <bradbell@…>
Date: Sun May 14 23:25:01 2017 -0700

jenkins.sh: must copy autotools version of configure.hpp.

commit 27c213f75938a5fc3ced81ef24724793416f0f15
Author: Brad Bell <bradbell@…>
Date: Sun May 14 23:12:10 2017 -0700

autotools.omh: make some improvements to these instructions.

commit c7cc571e5ba9cd47cf6c580a6ae70fc0b293856f
Author: Brad Bell <bradbell@…>
Date: Sun May 14 20:38:20 2017 -0700

mul_level.cpp: include test of fabs.

commit ab06ab7963ae301a3f86198b5f7231af61ba340e
Author: Brad Bell <bradbell@…>
Date: Sun May 14 20:14:20 2017 -0700

  1. Move autotools settimg of CPPAD_HAS_* to comfigure.ac.
  2. Fix some 'ifdef CPPAD_HAS_*' -> 'if CPPAD_HAS_*'.
  3. Autotools automatic changes to */makefile.in, configure.


CMakeLists.txt: include setting of cppad_has_boost (not yet used).

commit 61d90e2891327fd4c3fba2e078f84699ffc38cc0
Author: Brad Bell <bradbell@…>
Date: Sun May 14 18:18:38 2017 -0700

  1. Define cppad_has_<package> in optional_package.cmake. Use it in cmake files (and CPPAD_HAS_<PACKAGE> is C++ files) to determine if package is available.


  1. Add accuracy specifications to CppAD::to_string and convert some more cases from using machine epsilon to using digits10.

commit c1370167ed9892b72879b7b6fd2a53659509129d
Author: Brad Bell <bradbell@…>
Date: Sun May 14 13:24:31 2017 -0700

Use package (not package_prefix variable) as argument to optional_package.

commit 5a43c975953d91b487a396695d5485b4bb786937
Author: Brad Bell <bradbell@…>
Date: Sun May 14 09:22:15 2017 -0700

base_to_string.hpp: use digits10 to simplify code.
numeric_limits.hpp: correct font in syntax.
base_alloc.cpp: test numeric_limits and to_string.

Location:
trunk/test_more
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/test_more/CMakeLists.txt

    r3904 r3922  
    2020# ADD_DEFINITIONS("-DCPPAD_MAX_NUM_THREADS=1")
    2121
    22 # adolc_sources, adolc_libs and CPPAD_ADOLC_TEST
    23 SET(sources base_adolc.cpp)
    24 sources_libs_define(adolc "${sources}" adolc ADOLC_TEST)
     22# adolc_sources, adolc_libs and CPPAD_HAS_ADOLC
     23IF( cppad_has_adolc )
     24        SET(adolc_sources base_adolc.cpp)
     25        SET(adolc_libs adolc)
     26ELSE( cppad_has_adolc )
     27        SET(adolc_sources "")
     28        SET(adolc_libs "")
     29ENDIF( cppad_has_adolc )
    2530
    26 # eigen_sources and CPPAD_EIGEN_TEST
    27 SET(sources cppad_eigen.cpp eigen_mat_inv.cpp)
    28 sources_libs_define(eigen "${sources}" "" EIGEN_TEST)
     31# eigen_sources and CPPAD_HAS_EIGEN
     32IF( cppad_has_eigen )
     33        SET(eigen_sources cppad_eigen.cpp eigen_mat_inv.cpp)
     34ELSE( cppad_has_eigen )
     35        SET(eigen_sources "")
     36ENDIF( cppad_has_eigen )
    2937
    3038# ipopt_prefix
    31 SET(sources ipopt_solve.cpp)
    32 sources_libs_define(ipopt "${sources}" "${ipopt_LIBRARIES}" IPOPT_TEST)
     39IF( cppad_has_ipopt )
     40        SET(ipopt_sources ipopt_solve.cpp)
     41        SET(ipopt_libs "${ipopt_LIBRARIES}")
     42ELSE( cppad_has_ipopt )
     43        SET(ipopt_sources "")
     44        SET(ipopt_libs "")
     45ENDIF( cppad_has_ipopt )
    3346
    3447# )
  • trunk/test_more/base_alloc.cpp

    r3779 r3922  
    1 // $Id$
    21/* --------------------------------------------------------------------------
    3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell
     2CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell
    43
    54CppAD is distributed under multiple licenses. This distribution is under
     
    1312# include <cppad/cppad.hpp>
    1413
    15 bool base_alloc_test(void)
     14namespace { // BEGIN empty namespace
     15
     16bool test_parameter(void)
    1617{       bool ok = true;
    17         using CppAD::thread_alloc;
    1818        typedef CppAD::AD<base_alloc> my_ad;
    1919
    20         // y = x^2
     20        // y = x + 0 + 1 + 2 + ... + N-1
    2121        CppAD::vector<my_ad>   a_x, a_y;
    2222        a_x.resize(1);
     
    3535        return ok;
    3636}
     37
     38bool test_numeric_limits(void)
     39{       bool ok = true;
     40        typedef CppAD::AD<base_alloc> my_ad;
     41        //
     42        base_alloc eps = Value( CppAD::numeric_limits<my_ad>::epsilon() );
     43        ok            &= *eps.ptrdbl_ == std::numeric_limits<double>::epsilon();
     44        //
     45        base_alloc min = Value( CppAD::numeric_limits<my_ad>::min() );
     46        ok            &= *min.ptrdbl_ == std::numeric_limits<double>::min();
     47        //
     48        base_alloc max = Value( CppAD::numeric_limits<my_ad>::max() );
     49        ok            &= *max.ptrdbl_ == std::numeric_limits<double>::max();
     50        //
     51        base_alloc nan = Value( CppAD::numeric_limits<my_ad>::quiet_NaN() );
     52        ok            &= *nan.ptrdbl_ != *nan.ptrdbl_;
     53        //
     54        int   digits10 = CppAD::numeric_limits<my_ad>::digits10;
     55        ok            &= digits10 == std::numeric_limits<double>::digits10;
     56        //
     57        return ok;
     58}
     59
     60bool test_to_string(void)
     61{       bool ok = true;
     62        typedef CppAD::AD<base_alloc> my_ad;
     63        //
     64        double      dbl_pi = 4.0 * std::atan(1.0);
     65        my_ad       ad_pi  = my_ad(dbl_pi);
     66        std::string str_pi = to_string( ad_pi );
     67        //
     68        // Check the length of the string "3.1415...". One extra character
     69        // for machine epsilon precision and another for the decimal point.
     70        ok &= str_pi.size() == size_t( 2 + std::numeric_limits<double>::digits10 );
     71        //
     72        // check value
     73        double eps   = std::numeric_limits<double>::epsilon();
     74        double check = std::atof( str_pi.c_str() );
     75        ok          &= (check / dbl_pi - 1.0) <= eps;
     76        //
     77        return ok;
     78}
     79
     80
     81} // END empty namespace
     82
     83bool base_alloc_test(void)
     84{       bool ok = true;
     85        //
     86        ok     &= test_parameter();
     87        ok     &= test_numeric_limits();
     88        ok     &= test_to_string();
     89        //
     90        return ok;
     91}
  • trunk/test_more/ipopt_solve.cpp

    r3757 r3922  
    1 // $Id$
    21/* --------------------------------------------------------------------------
    3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell
     2CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell
    43
    54CppAD is distributed under multiple licenses. This distribution is under
     
    1312Testing ipopt::solve
    1413*/
    15 # ifdef CPPAD_IPOPT_TEST
     14
     15// CPPAD_HAS_* defines
     16# include <cppad/configure.hpp>
     17
     18# if CPPAD_HAS_IPOPT
    1619
    1720# include <cppad/ipopt/solve.hpp>
  • trunk/test_more/makefile.am

    r3905 r3922  
    2525ADOLC_EXTRA_FILES =
    2626ADOLC_LIB         = -ladolc -lColPack -L$(ADOLC_DIR)/lib -L$(ADOLC_DIR)/lib64
    27 ADOLC_FLAGS       = -DCPPAD_ADOLC_TEST -I$(ADOLC_DIR)/include
     27ADOLC_FLAGS       = -I$(ADOLC_DIR)/include
    2828else
    2929ADOLC_EXTRA_FILES = base_adolc.cpp
     
    3838IPOPT_LIB         = -lipopt \
    3939        $(CPPAD_IPOPT_LIBS) $(FCLIBS) $(PTHREAD_LIB) $(DL_LIB)
    40 IPOPT_FLAGS       = -DCPPAD_IPOPT_TEST -I$(IPOPT_DIR)/include
     40IPOPT_FLAGS       = -I$(IPOPT_DIR)/include
    4141else
    4242IPOPT_EXTRA_FILES = ipopt_solve.cpp
     
    5555        -g \
    5656        $(CXX_FLAGS_EIGEN) \
    57         -DCPPAD_EIGEN_TEST \
    5857         -I$(EIGEN_DIR)/include
    5958else
  • trunk/test_more/makefile.in

    r3920 r3922  
    381381cppad_description = @cppad_description@
    382382cppad_eigenvector = @cppad_eigenvector@
     383cppad_has_adolc = @cppad_has_adolc@
     384cppad_has_boost = @cppad_has_boost@
    383385cppad_has_colpack = @cppad_has_colpack@
    384386cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@
     387cppad_has_eigen = @cppad_has_eigen@
     388cppad_has_fadbad = @cppad_has_fadbad@
    385389cppad_has_gettimeofday = @cppad_has_gettimeofday@
     390cppad_has_ipopt = @cppad_has_ipopt@
    386391cppad_has_mkstemp = @cppad_has_mkstemp@
    387392cppad_has_nullptr = @cppad_has_nullptr@
    388393cppad_has_rvalue = @cppad_has_rvalue@
     394cppad_has_sacado = @cppad_has_sacado@
    389395cppad_has_steady_clock = @cppad_has_steady_clock@
    390396cppad_has_tmpnam_s = @cppad_has_tmpnam_s@
     
    448454@CppAD_ADOLC_TRUE@ADOLC_LIB = -ladolc -lColPack -L$(ADOLC_DIR)/lib -L$(ADOLC_DIR)/lib64
    449455@CppAD_ADOLC_FALSE@ADOLC_FLAGS =
    450 @CppAD_ADOLC_TRUE@ADOLC_FLAGS = -DCPPAD_ADOLC_TEST -I$(ADOLC_DIR)/include
     456@CppAD_ADOLC_TRUE@ADOLC_FLAGS = -I$(ADOLC_DIR)/include
    451457@CppAD_IPOPT_FALSE@IPOPT_SRC_FILES =
    452458# -------------------------------------------------------------------------
     
    459465
    460466@CppAD_IPOPT_FALSE@IPOPT_FLAGS =
    461 @CppAD_IPOPT_TRUE@IPOPT_FLAGS = -DCPPAD_IPOPT_TEST -I$(IPOPT_DIR)/include
     467@CppAD_IPOPT_TRUE@IPOPT_FLAGS = -I$(IPOPT_DIR)/include
    462468@CppAD_EIGEN_DIR_FALSE@EIGEN_EXTRA_FILES = cppad_eigen.cpp eigen_mat_inv.cpp
    463469# -------------------------------------------------------------------------
     
    471477@CppAD_EIGEN_DIR_TRUE@  -g \
    472478@CppAD_EIGEN_DIR_TRUE@  $(CXX_FLAGS_EIGEN) \
    473 @CppAD_EIGEN_DIR_TRUE@  -DCPPAD_EIGEN_TEST \
    474479@CppAD_EIGEN_DIR_TRUE@   -I$(EIGEN_DIR)/include
    475480
  • trunk/test_more/mul_level.cpp

    r3871 r3922  
    1111
    1212
    13 # ifdef CPPAD_ADOLC_TEST
     13// CPPAD_HAS_* defines
     14# include <cppad/configure.hpp>
     15
     16# if CPPAD_HAS_ADOLC
    1417# include <adolc/adouble.h>
    1518# include <adolc/taping.h>
     
    154157}
    155158
    156 # ifdef CPPAD_ADOLC_TEST
     159# if CPPAD_HAS_ADOLC
    157160
    158161bool adolc(void)
     
    222225}
    223226
    224 # endif // CPPAD_ADOLC_TEST
     227# endif // CPPAD_HAS_ADOLC
    225228
    226229bool std_math(void)
     
    264267}
    265268
    266 // supress this test until ../bug/abs.sh is fixed
    267 # ifdef CPPAD_NOT_DEFINED
    268269bool fabs(void)
    269270{       bool ok = true;
     
    314315        return ok;
    315316}
    316 # endif
    317317
    318318} // END empty namespace
     
    322322        ok     &= One();
    323323        ok     &= Two();
    324 # ifdef CPPAD_ADOLC_TEST
     324# if CPPAD_HAS_ADOLC
    325325        ok     &= adolc();
    326326# endif
    327327        ok     &= std_math();
    328 # ifdef CPPAD_NOT_DEFINED
    329328        ok     &= fabs();
    330 # endif
    331 
    332         return ok;
    333 }
     329
     330        return ok;
     331}
  • trunk/test_more/test_more.cpp

    r3904 r3922  
    99Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
    1010-------------------------------------------------------------------------- */
     11
     12// CPPAD_HAS_* defines
     13# include <cppad/configure.hpp>
    1114
    1215// system include files used for I/O
     
    255258        ok &= Run( VecUnary,        "VecUnary"       );
    256259        ok &= Run( zdouble,         "zdouble"        );
    257 # ifdef CPPAD_ADOLC_TEST
     260#if CPPAD_HAS_ADOLC
    258261        ok &= Run( base_adolc,      "base_adolc"     );
    259262# endif
    260 # ifdef CPPAD_IPOPT_TEST
     263#if CPPAD_HAS_IPOPT
    261264        ok &= Run( ipopt_solve,     "ipopt_solve"    );
    262265# endif
     
    264267        ok &= Run( alloc_openmp,    "alloc_openmp"   );
    265268# endif
    266 # ifdef CPPAD_EIGEN_TEST
     269# if CPPAD_HAS_EIGEN
    267270        ok &= Run( cppad_eigen,     "cppad_eigen"    );
    268271        ok &= Run( eigen_mat_inv,   "eigen_mat_inv"  );
  • trunk/test_more/to_string.cpp

    r3768 r3922  
    1 // $Id$
    21/* --------------------------------------------------------------------------
    3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell
     2CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell
    43
    54CppAD is distributed under multiple licenses. This distribution is under
     
    3635                //
    3736                Float check   = std::atof( real.c_str() );
    38                 ok           &= std::fabs( check - pi ) <= 2.0 * eps;
     37                ok           &= std::fabs( check / pi - 1.0 ) <= 2.0 * eps;
    3938                //
    4039                check         = std::atof( imag.c_str() );
    41                 ok           &= std::fabs( check - e ) <= 2.0 * eps;
     40                ok           &= std::fabs( check / e - 1.0 ) <= 2.0 * eps;
    4241                //
    4342                return ok;
Note: See TracChangeset for help on using the changeset viewer.