Changeset 3871 for trunk/test_more


Ignore:
Timestamp:
Jan 22, 2017 11:31:03 PM (3 years ago)
Author:
bradbell
Message:

merge to branch: trunk
from repository: https://github.com/coin-or/CppAD
start hash code: b103d4dd72a281b542373a3a7e256c8020b7b981
end hash code: 009923c51f128bfb79e69fc4911448c92133b535

commit 009923c51f128bfb79e69fc4911448c92133b535
Author: Brad Bell <bradbell@…>
Date: Sun Jan 22 21:28:33 2017 -0700

Automatic chagnes to auto-tools build files.

commit 53ed3ca52d097a6cd1bcfcdb28be39d2f446a84a
Author: Brad Bell <bradbell@…>
Date: Sun Jan 22 21:26:57 2017 -0700

Convert uses of abs to fabs where makes sense
(next step would be to deprecate abs).

commit 1987621469c32497425bb94b07de1f4050252d7c
Author: Brad Bell <bradbell@…>
Date: Sun Jan 22 18:49:06 2017 -0700

Convert example/*.cpp to test fabs, instead of abs.

commit 5a1d19e113a7205860e2434a6dc1919f4ad3f2d5
Author: Brad Bell <bradbell@…>
Date: Sun Jan 22 16:22:40 2017 -0700

Convert test_more/*.cpp to test fabs, instead of abs.

commit 9ce5faad42ead227abd2b0c23732971b793ca19c
Author: Brad Bell <bradbell@…>
Date: Sun Jan 22 15:00:22 2017 -0700

  1. Change use abs to define fabs in the base type definitions.
  2. Advanced to cppad-201701122.
Location:
trunk/test_more
Files:
1 added
1 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/test_more/CMakeLists.txt

    r3857 r3871  
    1 # $Id$
    21# -----------------------------------------------------------------------------
    3 # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell
     2# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell
    43#
    54# CppAD is distributed under multiple licenses. This distribution is under
     
    4342        old_reciprocal.cpp
    4443        old_mat_mul.cpp
    45         abs.cpp
     44        fabs.cpp
    4645        acos.cpp
    4746        acosh.cpp
  • trunk/test_more/cond_exp.cpp

    r3666 r3871  
    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
     
    416415        using CppAD::NearEqual;
    417416        using CppAD::log;
    418         using CppAD::abs;
    419417        double eps = 100. * std::numeric_limits<double>::epsilon();
    420418
     
    459457        CPPAD_TESTVECTOR(double) dw(n);  // derivative of weighted function
    460458
    461         // a case where abs( x[j] ) > 0 for all j
     459        // a case where fabs( x[j] ) > 0 for all j
    462460        double check  = 0.;
    463461        double sign   = 1.;
     
    465463        {       sign *= -1.;
    466464                x[j] = sign * double(j + 1);
    467                 check += log( abs( x[j] ) );
     465                check += log( fabs( x[j] ) );
    468466        }
    469467
     
    477475        for(j = 0; j < n; j++)
    478476        {       if( x[j] > 0. )
    479                         ok &= NearEqual(dw[j], 1./abs( x[j] ), eps, eps);
    480                 else    ok &= NearEqual(dw[j], -1./abs( x[j] ), eps, eps);
     477                        ok &= NearEqual(dw[j], 1./fabs( x[j] ), eps, eps);
     478                else    ok &= NearEqual(dw[j], -1./fabs( x[j] ), eps, eps);
    481479        }
    482480
     
    498496        for(j = 0; j < n; j++)
    499497        {       if( x[j] > 0. )
    500                         ok &= NearEqual(dw[j], 1./abs( x[j] ), eps, eps);
     498                        ok &= NearEqual(dw[j], 1./fabs( x[j] ), eps, eps);
    501499                else if( x[j] < 0. )
    502                         ok &= NearEqual(dw[j], -1./abs( x[j] ), eps, eps);
     500                        ok &= NearEqual(dw[j], -1./fabs( x[j] ), eps, eps);
    503501                else
    504502                        ok &= NearEqual(dw[j], 0.0, eps, eps);
  • trunk/test_more/cond_exp_rev.cpp

    r3666 r3871  
    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
     
    3231
    3332        // AbsOp
    34         ay.push_back( CondExpGt(ax[0], azero, ax[0], abs(ax[1]) ));
     33        ay.push_back( CondExpGt(ax[0], azero, ax[0], fabs(ax[1]) ));
    3534
    3635        // AcosOp
  • trunk/test_more/forward_dir.cpp

    r3683 r3871  
    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
     
    101100                size_t m = 1;
    102101                CPPAD_TESTVECTOR(AD<double>) ay(m);
    103                 ay[0] = abs( ax[0] ) + abs( 2.0 * ax[1] );
     102                ay[0] = fabs( ax[0] ) + fabs( 2.0 * ax[1] );
    104103
    105104                // create f: x -> y and stop tape recording
     
    126125                //
    127126                // Y_0  (t)    = F[X_0(t)]
    128                 //             = abs(0.5 + 1t + 2t^2) + abs( 2*(-1.0 + 2t + 3t^2 ) )
     127                //             = fabs(0.5 + 1t + 2t^2) + fabs( 2*(-1.0 + 2t + 3t^2 ) )
    129128                double y_1_0   = -3.0;
    130129                double y_2_0   = -4.0;
    131130                //
    132131                // Y_1  (t)    = F[X_1(t)]
    133                 //             = abs(0.5 + 2t + 3t^2) + abs( 2*(-1.0 + 3t + 4t^2 ) )
     132                //             = fabs(0.5 + 2t + 3t^2) + fabs( 2*(-1.0 + 3t + 4t^2 ) )
    134133                double y_1_1   = -4.0;
    135134                double y_2_1   = -5.0;
     
    10861085                y0  = f.Forward(0, x0);
    10871086                ok &= size_t( y0.size() ) == m;
    1088                 ok &= NearEqual(y0[0], CppAD::abs(x0[0]), eps, eps);
     1087                ok &= NearEqual(y0[0], fabs(x0[0]), eps, eps);
    10891088
    10901089                // first order Taylor coefficients
  • trunk/test_more/forward_order.cpp

    r3779 r3871  
    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
     
    5756
    5857        // other functions
    59         Y[i] = abs( X[i] );         i++;   // AbsOp
     58        Y[i] = fabs( X[i] );        i++;   // AbsOp
    6059        Y[i] = X[i-1] + X[i] + 2.0; i++;   // AddvvOp, AddvpOp
    6160        Y[i] = cosh( X[i] );        i++;   // CoshOp
     
    109108        }
    110109
    111         // y_i = abs( x_i )
    112         y[0] = CppAD::abs( x[i] );
     110        // y_i = fabs( x_i )
     111        y[0] = fabs( x[i] );
    113112        y[1] = CppAD::sign( x[i] );
    114113        y[2] = 0.0;
  • trunk/test_more/makefile.am

    r3815 r3871  
    1 # $Id$
    21# -----------------------------------------------------------------------------
    3 # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell
     2# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell
    43#
    54# CppAD is distributed under multiple licenses. This distribution is under
     
    8988        $(OPENMP_SRC_FILES) \
    9089        test_more.cpp \
    91         abs.cpp \
     90        fabs.cpp \
    9291        acos.cpp \
    9392        acosh.cpp \
  • trunk/test_more/makefile.in

    r3839 r3871  
    113113libeigen_a_OBJECTS = $(am_libeigen_a_OBJECTS)
    114114am__test_more_SOURCES_DIST = base_adolc.cpp ipopt_solve.cpp \
    115         alloc_openmp.cpp test_more.cpp abs.cpp acos.cpp acosh.cpp \
     115        alloc_openmp.cpp test_more.cpp fabs.cpp acos.cpp acosh.cpp \
    116116        adfun_copy.cpp asin.cpp asinh.cpp assign.cpp add.cpp \
    117117        add_eq.cpp add_zero.cpp atan.cpp atanh.cpp atan2.cpp azmul.cpp \
     
    140140@CppAD_OPENMP_TRUE@am__objects_3 = alloc_openmp.$(OBJEXT)
    141141am_test_more_OBJECTS = $(am__objects_1) $(am__objects_2) \
    142         $(am__objects_3) test_more.$(OBJEXT) abs.$(OBJEXT) \
     142        $(am__objects_3) test_more.$(OBJEXT) fabs.$(OBJEXT) \
    143143        acos.$(OBJEXT) acosh.$(OBJEXT) adfun_copy.$(OBJEXT) \
    144144        asin.$(OBJEXT) asinh.$(OBJEXT) assign.$(OBJEXT) add.$(OBJEXT) \
     
    288288CYGPATH_W = @CYGPATH_W@
    289289
    290 # $Id$
    291290# -----------------------------------------------------------------------------
    292 # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell
     291# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell
    293292#
    294293# CppAD is distributed under multiple licenses. This distribution is under
     
    501500        $(OPENMP_SRC_FILES) \
    502501        test_more.cpp \
    503         abs.cpp \
     502        fabs.cpp \
    504503        acos.cpp \
    505504        acosh.cpp \
     
    655654        -rm -f *.tab.c
    656655
    657 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/abs.Po@am__quote@
    658656@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/acos.Po@am__quote@
    659657@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/acosh.Po@am__quote@
     
    690688@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/expm1.Po@am__quote@
    691689@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/extern_value.Po@am__quote@
     690@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fabs.Po@am__quote@
    692691@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/for_hess.Po@am__quote@
    693692@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/for_sparse_hes.Po@am__quote@
  • trunk/test_more/mul_cond_rev.cpp

    r3735 r3871  
    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
     
    5655        a2y[i++]  = CondExpGt(a2x[0], a2zero, a2nan_var, a2zero);
    5756        // abs
    58         a2y[i++]  = CondExpGt(a2x[0], a2zero, abs( a2y[0] ), a2zero);
     57        a2y[i++]  = CondExpGt(a2x[0], a2zero, fabs( a2y[0] ), a2zero);
    5958        // add
    6059        a2y[i++]  = CondExpGt(a2x[0], a2zero, a2nan_var + a2nan_var, a2zero);
     
    124123        a1y[i++]  = CondExpGt(a1x[0], a1zero, a1nan_var, a1zero);
    125124        // abs
    126         a1y[i++]  = CondExpGt(a1x[0], a1zero, abs( a1y[0] ), a1zero);
     125        a1y[i++]  = CondExpGt(a1x[0], a1zero, fabs( a1y[0] ), a1zero);
    127126        // add
    128127        a1y[i++]  = CondExpGt(a1x[0], a1zero, a1nan_var + a1nan_var, a1zero);
  • trunk/test_more/mul_level.cpp

    r3869 r3871  
    266266// supress this test until ../bug/abs.sh is fixed
    267267# ifdef CPPAD_NOT_DEFINED
    268 bool abs(void)
     268bool fabs(void)
    269269{       bool ok = true;
    270270        using CppAD::AD;
     
    283283        CPPAD_TESTVECTOR(ADDdouble)  aax(n), aay(m);
    284284
    285         // create af(x) = abs(x)
     285        // create af(x) = fabs(x)
    286286        aax[0] = 1.;
    287287        Independent( aax );
    288         aay[0] = abs(aax[0]);
     288        aay[0] = fabs(aax[0]);
    289289        ADFun<ADdouble> af(aax, aay);
    290290
     
    327327        ok     &= std_math();
    328328# ifdef CPPAD_NOT_DEFINED
    329         ok     &= abs();
     329        ok     &= fabs();
    330330# endif
    331331
  • trunk/test_more/optimize.cpp

    r3856 r3871  
    1 // $Id$
    21/* --------------------------------------------------------------------------
    3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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
     
    425424                // unary operator where operand is arg[0]
    426425                // (note that sin corresponds to two tape variables)
    427                 not_used = CppAD::abs(x[0]);
     426                not_used = fabs(x[0]);
    428427                y[0]     = sin(x[0]);
    429428                original += 3;
     
    988987                Y[0] = X[0];
    989988                for(j = 0; j < n_operations; j++)
    990                         Y[0] = abs(Y[0]);
     989                        Y[0] = fabs(Y[0]);
    991990
    992991                // create f: X -> Y and stop tape recording
  • trunk/test_more/test_more.cpp

    r3811 r3871  
    1 // $Id$
    21/* --------------------------------------------------------------------------
    3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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
     
    1817
    1918// prototype external compiled tests (this line expected by bin/new_test.sh)
    20 extern bool abs(void);
     19extern bool fabs(void);
    2120extern bool acos(void);
    2221extern bool acosh(void);
     
    155154
    156155        // run external compiled tests (this line expected by bin/new_test.sh)
    157         ok &= Run( abs,             "abs"            );
     156        ok &= Run( fabs,            "fabs"           );
    158157        ok &= Run( acos,            "acos"           );
    159158        ok &= Run( acosh,           "acosh"          );
  • trunk/test_more/vec_unary.cpp

    r3856 r3871  
    1 // $Id$
    21/* --------------------------------------------------------------------------
    3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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
     
    2120{
    2221        using namespace CppAD;
    23         using CppAD::abs;
    2422        using CppAD::sin;
    2523        using CppAD::atan;
     
    5654        j    = 2.;
    5755        Y[j] = X[2];
    58         Z[2] = abs( Y[j] );
     56        Z[2] = fabs( Y[j] );
    5957
    6058        j    = 3.;
     
    8583        for(i = 0; i < n; i++)
    8684                x[i] = 2. / double(i + 1);
    87         x[7] = abs( x[7] );
     85        x[7] = fabs( x[7] );
    8886
    8987        z    = f.Forward(0, x);
     
    9189        ok  &= NearEqual(z[0],      - x[0], eps99, eps99);
    9290        ok  &= NearEqual(z[1], sin( x[1] ), eps99, eps99);
    93         ok  &= NearEqual(z[2], abs( x[2] ), eps99, eps99);
     91        ok  &= NearEqual(z[2], fabs( x[2] ), eps99, eps99);
    9492        ok  &= NearEqual(z[3], atan(x[3] ), eps99, eps99);
    9593        ok  &= NearEqual(z[4], cos( x[4] ), eps99, eps99);
Note: See TracChangeset for help on using the changeset viewer.