Changeset 3595


Ignore:
Timestamp:
Jan 12, 2015 10:03:43 AM (5 years ago)
Author:
bradbell
Message:

merge to branch: branches/compare_op
from repository: https://github.com/bradbell/cppad
start hash code: f4baab0ea7c2679ba9351b0439b6efebfa77ba04
end hash code: 6fe607ca30db07b356fd3a9fe9779fa2dfd382d8

commit 6fe607ca30db07b356fd3a9fe9779fa2dfd382d8
Author: Brad Bell <bradbell@…>
Date: Mon Jan 12 07:56:41 2015 -0700

Keep CompareChange? in optimized versions of tape and when NDEBUG is defined.

commit b4c0e51489cc0878499a331b4af4875b2781d8d8
Author: Brad Bell <bradbell@…>
Date: Sun Jan 11 17:01:59 2015 -0700

new_branch.sh: final procedure (only hand tested).

Location:
branches/compare_op
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/compare_op/bin/new_branch.sh

    r3593 r3595  
    6666        else
    6767                echo_eval svn revert --recursive $svn_directory
     68                echo_eval svn update $svn_directory
    6869                svn_status=`svn status $svn_directory | \
    6970                        sed -n -e '/^\?/p' | sed -e 's|^\? *||'`
     
    9495fi 
    9596# -----------------------------------------------------------------------------
     97echo_eval git checkout master
     98git_branch_name=`echo $svn_branch_path | sed -e 's|^branches/||'`
     99echo_eval git branch $git_branch_name
     100echo_eval git checkout $git_branch_name
     101git push --set-upstream origin $git_branch_name
     102# -----------------------------------------------------------------------------
    96103cat << EOF > $svn_directory/new_branch.log
    97104copy trunk to:   $svn_branch_path
    98105start hash code: $hash_origin
     106end   hash code: $hash_origin
    99107EOF
    100108echo_eval svn copy --file new_branch.log \
    101         $repository/trunk $repository/$branch_path
    102 # -----------------------------------------------------------------------------
    103 echo_eval git checkout master
    104 git_branch_name=`echo $svn_branch_path | sed -e 's|^branches/||'`
    105 echo_eval git branch $git_branch_name
     109        $svn_repository/trunk $svn_repository/$svn_branch_path
  • branches/compare_op/cppad/local/ad_fun.hpp

    r3301 r3595  
    44
    55/* --------------------------------------------------------------------------
    6 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell
     6CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell
    77
    88CppAD is distributed under multiple licenses. This distribution is under
     
    398398        }
    399399
    400 # ifndef NDEBUG
    401         /// in not NDEBUG case, number of comparison operations that change
     400        /// how many comparision operations have a different result
    402401        size_t CompareChange(void) const
    403402        {       return compare_change_; }
    404 # endif
    405403
    406404        /// calculate entire Jacobian
  • branches/compare_op/cppad/local/compare.hpp

    r2506 r3595  
    44
    55/* --------------------------------------------------------------------------
    6 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell
     6CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell
    77
    88CppAD is distributed under multiple licenses. This distribution is under
     
    185185
    186186// -------------------------------- < -------------------------
    187 # ifdef NDEBUG
    188 
    189187template <class Base>
    190188CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION
    191189bool operator < (const AD<Base> &left , const AD<Base> &right)
    192190{       bool result =  (left.value_ < right.value_);
    193         return result;
    194 }
    195 
    196 # else
    197 template <class Base>
    198 CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION
    199 bool operator < (const AD<Base> &left , const AD<Base> &right)
    200 {       bool result =  (left.value_ < right.value_);
    201191
    202192        ADTape<Base> *tape = CPPAD_NULL;
     
    211201        return result;
    212202}
    213 # endif
    214203
    215204// convert other cases into the case above
     
    217206
    218207// -------------------------------- <= -------------------------
    219 # ifdef NDEBUG
    220 
    221208template <class Base>
    222209CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION
    223210bool operator <= (const AD<Base> &left , const AD<Base> &right)
    224211{       bool result =  (left.value_ <= right.value_);
    225         return result;
    226 }
    227 
    228 # else
    229 template <class Base>
    230 CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION
    231 bool operator <= (const AD<Base> &left , const AD<Base> &right)
    232 {       bool result =  (left.value_ <= right.value_);
    233212
    234213        ADTape<Base> *tape = CPPAD_NULL;
     
    243222        return result;
    244223}
    245 # endif
    246224
    247225// convert other cases into the case above
     
    250228
    251229// -------------------------------- > -------------------------
    252 # ifdef NDEBUG
    253 
    254230template <class Base>
    255231CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION
    256232bool operator > (const AD<Base> &left , const AD<Base> &right)
    257233{       bool result =  (left.value_ > right.value_);
    258         return result;
    259 }
    260 
    261 # else
    262 template <class Base>
    263 CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION
    264 bool operator > (const AD<Base> &left , const AD<Base> &right)
    265 {       bool result =  (left.value_ > right.value_);
    266234
    267235        ADTape<Base> *tape = CPPAD_NULL;
     
    277245        return result;
    278246}
    279 # endif
    280247
    281248// convert other cases into the case above
     
    283250
    284251// -------------------------------- >= -------------------------
    285 # ifdef NDEBUG
    286 
    287252template <class Base>
    288253CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION
    289254bool operator >= (const AD<Base> &left , const AD<Base> &right)
    290255{       bool result =  (left.value_ >= right.value_);
    291         return result;
    292 }
    293 
    294 # else
    295 template <class Base>
    296 CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION
    297 bool operator >= (const AD<Base> &left , const AD<Base> &right)
    298 {       bool result =  (left.value_ >= right.value_);
    299256
    300257        ADTape<Base> *tape = CPPAD_NULL;
     
    309266        return result;
    310267}
    311 # endif
    312268
    313269// convert other cases into the case above
     
    316272
    317273// -------------------------------- == -------------------------
    318 # ifdef NDEBUG
    319 
    320274template <class Base>
    321275CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION
    322276bool operator == (const AD<Base> &left , const AD<Base> &right)
    323277{       bool result =  (left.value_ == right.value_);
    324         return result;
    325 }
    326 
    327 # else
    328 template <class Base>
    329 CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION
    330 bool operator == (const AD<Base> &left , const AD<Base> &right)
    331 {       bool result =  (left.value_ == right.value_);
    332278
    333279        ADTape<Base> *tape = CPPAD_NULL;
     
    342288        return result;
    343289}
    344 # endif
    345290
    346291// convert other cases into the case above
     
    348293
    349294// -------------------------------- != -------------------------
    350 # ifdef NDEBUG
    351 
    352295template <class Base>
    353296CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION
    354297bool operator != (const AD<Base> &left , const AD<Base> &right)
    355298{       bool result =  (left.value_ != right.value_);
    356         return result;
    357 }
    358 
    359 # else
    360 template <class Base>
    361 CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION
    362 bool operator != (const AD<Base> &left , const AD<Base> &right)
    363 {       bool result =  (left.value_ != right.value_);
    364299
    365300        ADTape<Base> *tape = CPPAD_NULL;
     
    374309        return result;
    375310}
     311
     312// convert other cases into the case above
     313CPPAD_FOLD_BOOL_VALUED_BINARY_OPERATOR(!=)
     314
     315} // END CppAD namespace
     316
    376317# endif
    377 
    378 // convert other cases into the case above
    379 CPPAD_FOLD_BOOL_VALUED_BINARY_OPERATOR(!=)
    380 
    381 } // END CppAD namespace
    382 
    383 # endif
  • branches/compare_op/cppad/local/optimize.hpp

    r3507 r3595  
    44
    55/* --------------------------------------------------------------------------
    6 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell
     6CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell
    77
    88CppAD is distributed under multiple licenses. This distribution is under
     
    8888See the discussion about
    8989$cref/sequence constructors/FunConstruct/Sequence Constructor/$$.
    90 
    91 $head Comparison Operators$$
    92 Any comparison operators that are in the tape are removed by this operation.
    93 Hence the return value of $cref CompareChange$$ will always be zero
    94 for an optimized tape (even if $code NDEBUG$$ is not defined).
    9590
    9691$head Atomic Functions$$
     
    20902085                bool keep;
    20912086                switch( op )
    2092                 {       case ComOp:
     2087                {       // case ComOp: (see wish_list/Optimize/CompareChange entry.
    20932088                        case PriOp:
    20942089                        keep = false;
     
    24062401                        break;
    24072402                        // ---------------------------------------------------
     2403                        // Operations with 4 arguments and no results
     2404                        case ComOp:
     2405                        CPPAD_ASSERT_NARG_NRES(op, 4, 0);
     2406                        new_arg[0] = arg[0];
     2407                        new_arg[1] = arg[1];
     2408                        if( arg[1] & 2 )
     2409                                new_arg[2] = tape[arg[2]].new_var;
     2410                        else
     2411                                new_arg[2] = rec->PutPar( play->GetPar(arg[2]) );
     2412                        if( arg[1] & 4 )
     2413                                new_arg[3] = tape[arg[3]].new_var;
     2414                        else
     2415                                new_arg[3] = rec->PutPar( play->GetPar(arg[3]) );
     2416                        rec->PutArg(
     2417                                new_arg[0] ,
     2418                                new_arg[1] ,
     2419                                new_arg[2] ,
     2420                                new_arg[3]
     2421                        );
     2422                        rec->PutOp(op);
     2423                        break;
     2424                        // ---------------------------------------------------
    24082425                        // Operations with no arguments and one result
    24092426                        case InvOp:
  • branches/compare_op/omh/forward/compare_change.omh

    r3173 r3595  
    11/* $Id$ */
    22/* --------------------------------------------------------------------------
    3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell
     3CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell
    44
    55CppAD is distributed under multiple licenses. This distribution is under
     
    7979it may not be worth re-taping a new AD operation sequence.
    8080
    81 $head Restrictions$$
    82 $index NDEBUG, CompareChange$$
    83 Computation of this function requires extra operations in the tape.
    84 If $cref/NDEBUG/Faq/Speed/NDEBUG/$$ is defined,
    85 of if a tape $cref/optimization/optimize/$$ has been preformed,
    86 these operations are not included in the tape and
    87 the value of $icode c$$ is always zero (and does not correspond
    88 to the actual number of comparison changes).
    89 
    9081$head Example$$
    9182$children%
  • branches/compare_op/omh/whats_new/whats_new_15.omh

    r3583 r3595  
    1414$dollar @$$
    1515$spell
     16        op
    1617        onetape
    1718        CppAD
     
    2930The purpose of this section is to
    3031assist you in learning about changes between various versions of CppAD.
     32
     33$head compare_op branch$$
     34$list number$$
     35The $cref CompareChange$$ function
     36$codei%
     37        %f%.CompareChange()
     38%$$
     39is now available when $cref/NDEBUG/Faq/Speed/NDEBUG/$$ is defined
     40(it used to not be so).
     41In addition, it returns correct values after
     42$codei%
     43        %f%.optimize()
     44%$$
     45is called (it used to always return zero after $cref optimize$$).
     46See the wish list
     47$cref/optimize compare_change/WishList/Optimization/CompareChange/$$ entry.
     48$lend
    3149
    3250$head 01-09$$
  • branches/compare_op/omh/wish_list.omh

    r3301 r3595  
    11$Id$
    22/* --------------------------------------------------------------------------
    3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell
     3CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell
    44
    55CppAD is distributed under multiple licenses. This distribution is under
     
    1212$begin WishList$$
    1313$spell
     14        onetape
     15        Op
    1416        jacobian
    1517        nz
     
    173175$index tape, optimize$$
    174176
     177$subhead CompareChange$$
     178The $code ComOp$$ operators are no longer removed by
     179the $cref optimize$$ procedure (so that $cref CompareChange$$
     180can be used after optimization).
     181This caused a 5% slow down in the
     182$cref speed_cppad$$ tests (using the
     183$cref/optimize/speed_main/option_list/optimize/$$ and
     184$cref/onetape/speed_main/option_list/onetape/$$ options).
     185Perhaps $code optimize$$ should have an option whereby
     186these operators can be removed.
     187
    175188$subhead Expression Hashing$$
    176189During expression sequence $cref/optimization/optimize/$$,
  • branches/compare_op/test_more/compare_change.cpp

    r2570 r3595  
    11/* $Id$ */
    22/* --------------------------------------------------------------------------
    3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell
     3CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell
    44
    55CppAD is distributed under multiple licenses. This distribution is under
     
    1919bool CompareChange(void)
    2020{       bool ok = true;
    21 # ifndef NDEBUG
    2221
    2322        using namespace CppAD;
     
    287286        delete f;
    288287
    289 # endif
    290288        return ok;
    291289}
Note: See TracChangeset for help on using the changeset viewer.