Changeset 1682


Ignore:
Timestamp:
Apr 25, 2010 12:51:28 AM (10 years ago)
Author:
bradbell
Message:

/home/bradbell/cppad/stable/20100101: Bug fixes in sub_op.hpp and build.sh.

sub.cpp: test that demonstrates the bug in sub_op.hpp.
sub_op.hpp: bug fix (same as at revision 1681).
build.sh: fix bug in version setting during build.sh all.

Location:
stable/20100101
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable/20100101/build.sh

    r1665 r1682  
    174174        #
    175175        # change Autoconf version to today
    176         version=$yyyymmdd
    177         #
    178         exit 0
    179 fi
     176        configure_ac_version=$yyyymmdd
     177        #
     178        exit 0
     179fi
     180version="$configure_ac_version"
    180181#
    181182# -----------------------------------------------------------------------------
  • stable/20100101/cppad/local/sub_op.hpp

    r1447 r1682  
    55
    66/* --------------------------------------------------------------------------
    7 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-09 Bradley M. Bell
     7CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-10 Bradley M. Bell
    88
    99CppAD is distributed under multiple licenses. This distribution is under
     
    291291        CPPAD_ASSERT_UNKNOWN( NumArg(SubvpOp) == 2 );
    292292        CPPAD_ASSERT_UNKNOWN( NumRes(SubvpOp) == 1 );
    293         CPPAD_ASSERT_UNKNOWN( arg[1] < i_z );
     293        CPPAD_ASSERT_UNKNOWN( arg[0] < i_z );
    294294        CPPAD_ASSERT_UNKNOWN( d < nc_taylor );
    295295
     
    335335        CPPAD_ASSERT_UNKNOWN( NumArg(SubvpOp) == 2 );
    336336        CPPAD_ASSERT_UNKNOWN( NumRes(SubvpOp) == 1 );
    337         CPPAD_ASSERT_UNKNOWN( arg[1] < i_z );
     337        CPPAD_ASSERT_UNKNOWN( arg[0] < i_z );
    338338
    339339        // Parameter value
  • stable/20100101/test_more/sub.cpp

    r1447 r1682  
    11/* $Id$ */
    22/* --------------------------------------------------------------------------
    3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-09 Bradley M. Bell
     3CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-10 Bradley M. Bell
    44
    55CppAD is distributed under multiple licenses. This distribution is under
     
    1919namespace { // BEGIN empty namespace
    2020
    21 bool SubTestOne(void)
     21bool One(void)
    2222{       bool ok = true;
    2323
     
    7575}
    7676
    77 bool SubTestTwo(void)
     77bool Two(void)
    7878{       bool ok = true;
    7979
     
    132132}
    133133
    134 
    135 bool SubTestThree(void)
     134bool Three(void)
    136135{       bool ok = true;
    137136        using namespace CppAD;
     
    157156}
    158157
     158bool Four(void)
     159{       bool ok = true;
     160        using namespace CppAD;
     161
     162        // special cases where parameter number is equal to
     163        // variable index in result.
     164        size_t n = 1;
     165        CPPAD_TEST_VECTOR< AD<double> > X(n);
     166        X[0] = 1.;
     167        Independent(X);
     168        size_t m = 1;
     169        CPPAD_TEST_VECTOR< AD<double> > Y(m);
     170        if( 0. < X[0] && X[0] < 10. )
     171                Y[0] = X[0] - 2.;
     172        else    Y[0] = X[0] - 2.;
     173        ADFun<double> f(X, Y);
     174       
     175        CPPAD_TEST_VECTOR<double> y(m), x(n);
     176        x[0] = 1.;
     177        y    = f.Forward(0, x);
     178        ok  &= (y[0] == -1.);
     179       
     180        CPPAD_TEST_VECTOR<double> dy(m), dx(n);
     181        dx[0] = 1.;
     182        dy    = f.Forward(1, dx);
     183        ok  &= (dy[0] == 1.);
     184
     185        return ok;
     186}
     187
     188
    159189} // END empty namespace
    160190
    161191bool Sub(void)
    162192{       bool ok = true;
    163         ok &= SubTestOne();
    164         ok &= SubTestTwo();
    165         ok &= SubTestThree();
     193        ok &= One();
     194        ok &= Two();
     195        ok &= Three();
     196        ok &= Four();
    166197        return ok;
    167198}
Note: See TracChangeset for help on using the changeset viewer.