Changeset 1650 for trunk/test_more


Ignore:
Timestamp:
Feb 7, 2010 5:14:40 PM (10 years ago)
Author:
bradbell
Message:

/home/bradbell/cppad/trunk: Fix Release build for MS compiler version of speed tests.

svn_status.sh: add comment to aid in automatic edits by new_stable.sh.
optimize.cpp: add test case that demonstrates an old bug.
whats_new_10.omh: user's view of the changes.
new_stable.sh: do not exclude automatically edited files in stable versions.
*.snl: convert from Visual Studio 7 to 2008.
*.vcproj: add missing files and fix Release build.
new_release.sh: imporvements pushed from 20100101.1 back to trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test_more/optimize.cpp

    r1608 r1650  
    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
     
    257257                return ok;
    258258        }
    259         // -------------------------------------------------------------------
     259        // ===================================================================
    260260        // Test duplicate operation analysis
    261261
     
    420420
    421421                // create f: X -> Y and stop tape recording
    422                 // Y[ X[0] ] = X[1] and other components of Y are zero.
    423422                CppAD::ADFun<double> F;
    424423                F.Dependent(X, Y);
     
    485484
    486485                // create f: X -> Y and stop tape recording
    487                 // Y[ X[0] ] = X[1] and other components of Y are zero.
    488486                CppAD::ADFun<double> F;
    489487                F.Dependent(X, Y);
     
    512510        }
    513511        // -------------------------------------------------------------------
     512        bool duplicate_four(void)
     513        {       // Check that unary expression matching not only checks hash code,
     514                // and operator, but also operand (old bug that has been fixed).
     515                bool ok = true;
     516                using CppAD::AD;
     517                size_t j;
     518
     519                // domain space vector
     520                size_t n  = 1;
     521                CPPAD_TEST_VECTOR< AD<double> > X(n);
     522                X[0] = 1.;
     523
     524                // range space vector
     525                size_t m = 1;
     526                CPPAD_TEST_VECTOR< AD<double> > Y(m);
     527
     528                // declare independent variables and start tape recording
     529                CppAD::Independent(X);
     530
     531                // check a huge number of same operation with different operands
     532                size_t n_operations = size_t(CPPAD_HASH_TABLE_SIZE) + 5;
     533                Y[0] = X[0];
     534                for(j = 0; j < n_operations; j++)
     535                        Y[0] = abs(Y[0]);
     536
     537                // create f: X -> Y and stop tape recording
     538                CppAD::ADFun<double> F;
     539                F.Dependent(X, Y);
     540
     541                // check number of variables in original function
     542                ok &= (F.size_var() ==  1 + n + n_operations );
     543       
     544                CPPAD_TEST_VECTOR<double> x(n), y(m);
     545                x[0] = 1.;
     546
     547                y   = F.Forward(0, x);
     548                ok &= ( y[0] == Value( Y[0] ) );
     549
     550                F.optimize();
     551
     552                // check same number of variables in optimized version
     553                ok &= (F.size_var() == 1 + n + n_operations );
     554
     555                y   = F.Forward(0, x);
     556                ok &= ( y[0] == Value( Y[0] ) );
     557
     558                return ok;
     559        }
     560        // ====================================================================
    514561        bool cummulative_sum(void)
    515562        {       // test conversion of a sequence of additions and subtraction
     
    859906        ok     &= duplicate_two();
    860907        ok     &= duplicate_three();
     908        ok     &= duplicate_four();
    861909        // convert sequence of additions to cummulative summation
    862910        ok     &= cummulative_sum();
Note: See TracChangeset for help on using the changeset viewer.