Changeset 2955


Ignore:
Timestamp:
Oct 16, 2013 10:56:16 AM (6 years ago)
Author:
bradbell
Message:

op_code.hpp: fix bug in printing atomic op codes.
optimize.hpp: improve comments about cummulative summation.

Location:
branches/opt_cond_exp/cppad/local
Files:
2 edited

Legend:

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

    r2953 r2955  
    651651                case UserOp:
    652652                CPPAD_ASSERT_UNKNOWN( NumArg(op) == 4 );
    653                 {       atomic_base<Base>* atom = atomic_base<Base>::list(ind[0]);
    654                         std::string name = atom->afun_name();
     653                {       std::string name = atomic_base<Base>::class_name(ind[0]);
    655654                        printOpField(os, " f=",   name.c_str(), ncol);
    656655                        printOpField(os, " i=", ind[1], ncol);
  • branches/opt_cond_exp/cppad/local/optimize.hpp

    r2954 r2955  
    155155        yes_connected      ,
    156156
    157         /// There is only one parrent operation that connects this variable to
    158         /// the independent variables and it is one of the following:
    159         ///  AddvvOp, AddpvOp, SubpvOp, SubvpOp, or SubvvOp.
     157        /// There is only one parrent that connects this variable to the
     158        /// independent variables and the parent is a summation operation; i.e.,
     159        /// AddvvOp, AddpvOp, SubpvOp, SubvpOp, or SubvvOp.
    160160        sum_connected      ,
    161161
    162         /// Satisfies sum_connected and in addition
    163         /// the parrent operation is one of the following:
    164         ///  AddvvOp, AddpvOp, SubpvOp, SubvpOp, or SubvvOp.
     162        /// Satisfies the sum_connected assumptions above and in addition
     163        /// this variable is the result of summation operator.
    165164        csum_connected
    166 
    167165};
    168166
     
    945943<tt>tape[i].new_var</tt>
    946944is not yet defined for any node \c i that is \c csum_connected
    947 to the \a current node.
     945to the \a current node
     946(or that is \c sum_connected to a node that is \c csum_connected).
    948947For example; suppose that index \c j corresponds to a variable
    949948in the current operator,
     
    959958
    960959\li <tt>tape[current].connect_type</tt> must be \c yes_connected.
     960
     961\li <tt>tape[j].connect_type == csum_connected</tt> for some index
     962j that is a variable operand for the current operation.
    961963*/
    962964
     
    988990        work.op_stack.push( var );
    989991        Base sum_par(0);
     992
     993# ifndef NDEBUG
     994        bool ok = false;
     995        if( var.op == SubvpOp )
     996                ok = tape[ tape[current].arg[0] ].connect_type == csum_connected;
     997        if( var.op == AddpvOp || var.op == SubpvOp )
     998                ok = tape[ tape[current].arg[1] ].connect_type == csum_connected;
     999        if( var.op == AddvvOp || var.op == SubvvOp )
     1000        {       ok  = tape[ tape[current].arg[0] ].connect_type == csum_connected;
     1001                ok |= tape[ tape[current].arg[1] ].connect_type == csum_connected;
     1002        }
     1003        CPPAD_ASSERT_UNKNOWN( ok );
     1004# endif
    9901005        while( ! work.op_stack.empty() )
    9911006        {       var     = work.op_stack.top();
     
    12591274                        if( tape[i_var].connect_type != not_connected )
    12601275                        {
     1276                                // check for case where arg[0] is sum_connected
    12611277                                if( tape[arg[0]].connect_type == not_connected )
    12621278                                        tape[arg[0]].connect_type = sum_connected;
    1263                                 else
    1264                                         tape[arg[0]].connect_type = yes_connected;
     1279                                else    tape[arg[0]].connect_type = yes_connected;
     1280
     1281                                // check for case where i_var is sum_connected to and
     1282                                // it is the result of a summation.
    12651283                                if( tape[i_var].connect_type == sum_connected )
    12661284                                        tape[i_var].connect_type = csum_connected;
     
    12731291                        if( tape[i_var].connect_type != not_connected )
    12741292                        {
     1293                                // check for case where arg[1] is sum_connected
    12751294                                if( tape[arg[1]].connect_type == not_connected )
    12761295                                        tape[arg[1]].connect_type = sum_connected;
    1277                                 else
    1278                                         tape[arg[1]].connect_type = yes_connected;
     1296                                else    tape[arg[1]].connect_type = yes_connected;
     1297
     1298                                // check for case where i_var is sum_connected to and
     1299                                // it is the result of a summation.
    12791300                                if( tape[i_var].connect_type == sum_connected )
    12801301                                        tape[i_var].connect_type = csum_connected;
     
    12881309                        if( tape[i_var].connect_type != not_connected )
    12891310                        {
     1311                                // check for case where arg[0] is sum_connected
    12901312                                if( tape[arg[0]].connect_type == not_connected )
    12911313                                        tape[arg[0]].connect_type = sum_connected;
    1292                                 else
    1293                                         tape[arg[0]].connect_type = yes_connected;
    1294 
     1314                                else    tape[arg[0]].connect_type = yes_connected;
     1315
     1316                                // check for case where arg[1] is sum_connected
    12951317                                if( tape[arg[1]].connect_type == not_connected )
    12961318                                        tape[arg[1]].connect_type = sum_connected;
    1297                                 else
    1298                                         tape[arg[1]].connect_type = yes_connected;
     1319                                else    tape[arg[1]].connect_type = yes_connected;
     1320
     1321                                // check for case where i_var is sum_connected to and
     1322                                // it is the result of a summation.
    12991323                                if( tape[i_var].connect_type == sum_connected )
    13001324                                        tape[i_var].connect_type = csum_connected;
Note: See TracChangeset for help on using the changeset viewer.