Changeset 2963


Ignore:
Timestamp:
Oct 17, 2013 7:16:38 PM (6 years ago)
Author:
bradbell
Message:

General comments about this commit go here (delete this line).

comp_op.hpp: fix spelling typo in doxygen.
cskip_op.hpp: begin implementation of the CSkipOp operator.
op_code.hpp: remove operators from old design.
op.hpp: include new operator.

Location:
branches/opt_cond_exp
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • branches/opt_cond_exp/cppad/local/comp_op.hpp

    r2910 r2963  
    44
    55/* --------------------------------------------------------------------------
    6 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell
     6CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell
    77
    88CppAD is distributed under multiple licenses. This distribution is under
     
    2020\{
    2121\file comp_op.hpp
    22 Zero order forward mode check how man comparisons changed.
     22Zero order forward mode check how many comparisons changed.
    2323*/
    2424
  • branches/opt_cond_exp/cppad/local/op.hpp

    r2506 r2963  
    44
    55/* --------------------------------------------------------------------------
    6 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell
     6CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell
    77
    88CppAD is distributed under multiple licenses. This distribution is under
     
    2828# include <cppad/local/cos_op.hpp>
    2929# include <cppad/local/cosh_op.hpp>
     30# include <cppad/local/cskip_op.hpp>
    3031# include <cppad/local/csum_op.hpp>
    3132# include <cppad/local/discrete_op.hpp>
  • branches/opt_cond_exp/cppad/local/op_code.hpp

    r2962 r2963  
    5656        AtanOp,   // atan(variable)
    5757        BeginOp,  // used to mark the beginning of the tape
    58         BskipOp,  // begin a conditional skip of operations
    59         // arg[0] = index in cond_skip we will check for true
    60         // arg[1] = number of operations that we will skip if true
    6158        CExpOp,   // CondExpRel(left, right, trueCase, falseCase)
    6259        // arg[0]     = the Rel operator: Lt, Le, Eq, Ge, Gt, or Ne
     
    9188        DivvvOp,  //      variable   / variable
    9289        EndOp,    //  used to mark the end of the tape
    93         EskipOp,  // end a conditional skip of operations
    94         // arg[0] = index in cond_skip we will check for true
    95         // arg[1] = number of operations that we will skip if true
    9690        ExpOp,    //  exp(variable)
    9791        InvOp,    //                             independent variable
     
    110104        SinhOp,   // sinh(variable)
    111105        SqrtOp,   // sqrt(variable)
    112         SskipOp,  // set the next pair of conditional skip values
    113         // arg[0]   = index in operation sequence of a CExpOp
    114         // arg[1]   = index in cond_skip set to comparison result
    115         // arg[1]+1 = index in cond_skip set to not comparison result
    116106        StppOp,   //    z[parameter] = parameter
    117107        StpvOp,   //    z[parameter] = variable
     
    160150        1, // AtanOp
    161151        0, // BeginOp
    162         2, // BskipOp
    163152        6, // CExpOp
    164153        4, // ComOp
     
    172161        2, // DivvvOp
    173162        0, // EndOp
    174         2, // EskipOp
    175163        1, // ExpOp
    176164        0, // InvOp
     
    189177        1, // SinhOp
    190178        1, // SqrtOp
    191         3, // SskipOp
    192179        3, // StppOp
    193180        3, // StpvOp
     
    262249        2, // AtanOp
    263250        1, // BeginOp  offsets first variable to have index one (not zero)
    264         0, // BskipOp
    265251        1, // CExpOp
    266252        0, // ComOp
     
    274260        1, // DivvvOp
    275261        0, // EndOp
    276         0, // EskipOp
    277262        1, // ExpOp
    278263        1, // InvOp
     
    291276        2, // SinhOp
    292277        1, // SqrtOp
    293         0, // SskipOp
    294278        0, // StppOp
    295279        0, // StpvOp
     
    467451                "Atan"  ,
    468452                "Begin" ,
    469                 "Bskip" ,
    470453                "CExp"  ,
    471454                "Com"   ,
     
    479462                "Divvv" ,
    480463                "End"   ,
    481                 "Eskip" ,
    482464                "Exp"   ,
    483465                "Inv"   ,
     
    496478                "Sinh"  ,
    497479                "Sqrt"  ,
    498                 "Sskip" ,
    499480                "Stpp"  ,
    500481                "Stpv"  ,
     
    532513        switch( op )
    533514        {
    534                 case BskipOp:
    535                 case EskipOp:
    536                 /*
    537                 ind[0] = index in cond_skip we will check for true
    538                 ind[1] = number of operations that we will skip if true.
    539                 */
    540                 printOpField(os, "idx=", ind[0], ncol);
    541                 printOpField(os, "num=", ind[1], ncol);
    542                 break;
    543 
    544                 case SskipOp:
    545                 /*
    546                 arg[0]   = index in operation sequence of a CExpOp
    547                 arg[1]   = index in cond_skip set to comparison result
    548                 arg[1]+1 = index in cond_skip set to not comparison result
    549                 */
    550                 printOpField(os, "cdx=", ind[0], ncol);
    551                 printOpField(os, "sdx=", ind[1], ncol);
    552                 break;
    553 
    554515                case CSkipOp:
    555516                /*
  • branches/opt_cond_exp/cppad/local/player.hpp

    r2910 r2963  
    44
    55/* --------------------------------------------------------------------------
    6 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell
     6CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell
    77
    88CppAD is distributed under multiple licenses. This distribution is under
     
    340340        The input value of op does not matter. Its output value is the
    341341        next operator in the recording.
    342         For speed, \c next_forward does not check for the special case
    343         of <tt>op == CSumOp</tt>. In this case, the other return values
    344         from \c next_forward must be corrected by a call to \c forward_csum.
     342        For speed, \c next_forward does not check for the special cases
     343        where  <tt>op == CSumOp</tt> or <tt>op == CSkipOp</tt>. In these cases,
     344        the other return values from \c next_forward must be corrected by a call
     345        to \c forward_csum or \c forward_cskip respectively.
    345346
    346347        \param op_arg
     
    424425        }
    425426        /*!
     427        Correct \c next_forward return values when <tt>op == CSkipOp</tt>.
     428
     429        \param op
     430        The input value of op must be the return value from the previous
     431        call to \c next_forward and must be \c CSkipOp.
     432
     433        \param op_arg
     434        The input value of *op_arg must be the return value from the
     435        previous call to \c next_forward. Its output value is the
     436        beginning of the vector of argument indices for this operation.
     437
     438        \param op_index
     439        The input value of op_index does must be the return value from the
     440        previous call to \c next_forward. Its output value
     441        is the index of this operator in the recording.
     442
     443        \param var_index
     444        The input value of var_index must be the return value from the
     445        previous call to \c next_forward. Its output value is the
     446        index of the primary (last) result corresponding to this.
     447        */
     448        void forward_cskip(
     449        OpCode& op, const addr_t*& op_arg, size_t& op_index, size_t& var_index)
     450        {       using CppAD::NumRes;
     451                using CppAD::NumArg;
     452                CPPAD_ASSERT_UNKNOWN( op == CSkipOp );
     453                CPPAD_ASSERT_UNKNOWN( NumArg(CSkipOp) == 0 );
     454                CPPAD_ASSERT_UNKNOWN(
     455                op_arg[1] + op_arg[2] == op_arg[ 3 + op_arg[1] + op_arg[2] ]
     456                );
     457                /*
     458                The only thing that really needs fixing is op_arg_.
     459                Actual number of arugments for this operator is
     460                        op_arg[1] + op_arg[2] + 4.
     461                We must change op_arg_ so that when you add NumArg(CSkipOp)
     462                you get first argument for next operator in sequence.
     463                */
     464                op_arg_    += op_arg[1] + op_arg[2] + 4;
     465
     466                CPPAD_ASSERT_UNKNOWN( op_arg_ + NumArg(op) <= rec_op_arg_.size() );
     467                CPPAD_ASSERT_UNKNOWN( var_index_  < num_rec_var_ );
     468        }
     469        /*!
    426470        Get a non-constant version of op_arg returned by previous next_forward
    427471
     
    491535        The last operator sets op_arg equal to the beginning of the
    492536        argument indices for the entire recording.
    493         For speed, \c next_reverse does not check for the special case
    494         of <tt>op == CSumOp</tt>. In this case, the other return values
    495         from \c next_reverse must be corrected by a call to \c reverse_csum.
     537        For speed, \c next_reverse does not check for the special cases
     538        <tt>op == CSumOp</tt> or <tt>op == CSkipOp</tt>. In these cases, the other
     539        return values from \c next_reverse must be corrected by a call to
     540        \c reverse_csum or \c reverse_cskip respectively.
    496541
    497542
     
    575620                CPPAD_ASSERT_UNKNOWN( var_index_  < num_rec_var_ );
    576621        }
     622        /*!
     623        Correct \c next_reverse return values when <tt>op == CSkipOp</tt>.
     624
     625        \param op
     626        The input value of op must be the return value from the previous
     627        call to \c next_reverse and must be \c CSkipOp.
     628
     629        \param op_arg
     630        The input value of *op_arg must be the return value from the
     631        previous call to \c next_reverse. Its output value is the
     632        beginning of the vector of argument indices for this operation.
     633
     634        \param op_index
     635        The input value of op_index must be the return value from the
     636        previous call to \c next_reverse. Its output value
     637        is the index of the this operator in the recording.
     638
     639        \param var_index
     640        The input value of var_index must be the return value from the
     641        previous call to \c next_reverse. Its output value is the
     642        index of the primary (last) result corresponding to this operator.
     643        */
     644
     645        void reverse_cskip(
     646        OpCode& op, const addr_t*& op_arg, size_t& op_index, size_t& var_index)
     647        {       using CppAD::NumRes;
     648                using CppAD::NumArg;
     649                CPPAD_ASSERT_UNKNOWN( op == CSkipOp );
     650                CPPAD_ASSERT_UNKNOWN( NumArg(CSkipOp) == 0 );
     651                /*
     652                The things needs fixing are op_arg_ and op_arg. Currently,
     653                op_arg points first arugment for the previous operator.
     654                */
     655                --op_arg;
     656                op_arg_    -= (op_arg[0] + 4);
     657                op_arg      = op_arg_ + rec_op_arg_.data();
     658
     659                CPPAD_ASSERT_UNKNOWN(
     660                op_arg[1] + op_arg[2] == op_arg[ 3 + op_arg[1] + op_arg[2] ]
     661                );
     662                CPPAD_ASSERT_UNKNOWN( op_index_  < rec_op_.size() );
     663                CPPAD_ASSERT_UNKNOWN( op_arg_ + NumArg(op) <= rec_op_arg_.size() );
     664                CPPAD_ASSERT_UNKNOWN( var_index_  < num_rec_var_ );
     665        }
    577666
    578667};
  • branches/opt_cond_exp/makefile.am

    r2859 r2963  
    161161        cppad/local/cos_op.hpp \
    162162        cppad/local/cppad_assert.hpp \
     163        cppad/local/cskip_op.hpp \
    163164        cppad/local/csum_op.hpp \
    164165        cppad/local/declare_ad.hpp \
Note: See TracChangeset for help on using the changeset viewer.