Changeset 1524


Ignore:
Timestamp:
Sep 21, 2009 11:07:03 PM (11 years ago)
Author:
bradbell
Message:

trunk: Heading toward having two vectors of set classes to choose from.

change connection to vector_pack:
check_doxygen.sh, ad_fun.hpp, for_jac_sweep.hpp, load_op.hpp
rev_sparse_jac.hpp, store_op.hpp, rev_sparse_hes.hpp, rev_jac_sweep.hpp,
cond_op.hpp, sparse_binary_op.hpp, sparse_unary_op.hpp

*/test_one.sh.in: detect and report error when file does not exist.
makefile.am: change connection.hpp to vector_set.hpp.
makefile.in: changes automatically generated from change in makefile.am
prototype_op.hpp: notes about changing documentation (to do).
vector_set.hpp: connection->vector_pack, n_from->n_set, n_to->limit
connection.hpp: move to vector_set.hpp.
op.hpp: include vector_set.hpp.

Location:
trunk
Files:
18 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/check_doxygen.sh

    r1516 r1524  
    1919        cond_op.hpp
    2020        configure.hpp
    21         connection.hpp
    2221        cos_op.hpp
    2322        cosh_op.hpp
     
    5049        store_op.hpp
    5150        sub_op.hpp
     51        vector_set.hpp
    5252"
    5353for name in $list
  • trunk/cppad/local/ad_fun.hpp

    r1523 r1524  
    261261
    262262        // results of the forward mode Jacobian sparsity calculations
    263         connection       for_jac_sparsity_;
     263        vector_pack      for_jac_sparsity_;
    264264
    265265        template <typename ADvector>
  • trunk/cppad/local/cond_op.hpp

    r1523 r1524  
    1212Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
    1313-------------------------------------------------------------------------- */
    14 # include <cppad/local/connection.hpp>
    1514CPPAD_BEGIN_NAMESPACE
    1615
     
    345344        const size_t*      arg           ,
    346345        size_t             num_par       ,
    347         connection&        sparsity      )
     346        vector_pack&       sparsity      )
    348347{
    349348        CPPAD_ASSERT_UNKNOWN( arg[0] < static_cast<size_t> (CompareNe) );
     
    429428        const size_t*       arg           ,
    430429        size_t              num_par       ,
    431         connection&         sparsity      )
     430        vector_pack&        sparsity      )
    432431{       
    433432        CPPAD_ASSERT_UNKNOWN( arg[0] < static_cast<size_t> (CompareNe) );
     
    530529        size_t               num_par       ,
    531530        bool*                jac_reverse   ,
    532         connection&          hes_sparsity  )
     531        vector_pack&         hes_sparsity  )
    533532{       
    534533
  • trunk/cppad/local/for_jac_sweep.hpp

    r1523 r1524  
    1212Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
    1313-------------------------------------------------------------------------- */
    14 # include <cppad/local/connection.hpp>
    1514CPPAD_BEGIN_NAMESPACE
    1615
     
    7574        size_t                numvar       ,
    7675        player<Base>*         play         ,
    77         connection&           var_sparsity )
     76        vector_pack&          var_sparsity )
    7877{
    7978        OpCode           op;
     
    9998        // vecad_ind maps a VecAD index (the beginning of the
    10099        // VecAD object) to its from index in vecad_sparsity
    101         size_t n_to            = var_sparsity.n_to();
     100        size_t n_to            = var_sparsity.limit();
    102101        size_t num_vecad_ind   = play->num_rec_vecad_ind();
    103102        size_t num_vecad_vec   = play->num_rec_vecad_vec();
    104         connection       vecad_sparsity;
     103        vector_pack      vecad_sparsity;
    105104        vecad_sparsity.resize(num_vecad_vec, n_to);
    106105        size_t* vecad_ind      = CPPAD_NULL;
  • trunk/cppad/local/load_op.hpp

    r1523 r1524  
    304304        size_t             num_combined   ,
    305305        const size_t*      combined       ,
    306         connection&        var_sparsity   ,
    307         connection&        vecad_sparsity )
     306        vector_pack&       var_sparsity   ,
     307        vector_pack&       vecad_sparsity )
    308308{
    309309        CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 );
     
    312312        CPPAD_ASSERT_UNKNOWN( arg[0] < num_combined );
    313313        size_t i_v = combined[ arg[0] - 1 ];
    314         CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_from() );
     314        CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_set() );
    315315
    316316        var_sparsity.assignment(i_z, i_v, vecad_sparsity);
     
    331331        size_t             num_combined   ,
    332332        const size_t*      combined       ,
    333         connection&        var_sparsity   ,
    334         connection&        vecad_sparsity )
     333        vector_pack&       var_sparsity   ,
     334        vector_pack&       vecad_sparsity )
    335335{
    336336        CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 );
     
    339339        CPPAD_ASSERT_UNKNOWN( arg[0] < num_combined );
    340340        size_t i_v = combined[ arg[0] - 1 ];
    341         CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_from() );
     341        CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_set() );
    342342
    343343        vecad_sparsity.binary_union(i_v, i_v, i_z, var_sparsity);
     
    350350Reverse mode Hessian sparsity operations for LdpOp and LdvOp
    351351
    352 This routine is given the connections corresponding to
     352This routine is given the (EDIT THIS) connections corresponding to
    353353G(z , v[x] , w , u ... )
    354 and it uses them to compute the connections corresponding to
     354and it uses them to compute the (EDIT THIS) connections corresponding to
    355355\verbatim
    356356        H( v[x] , w , u , ... ) = G[ z( v[x] ) , v[x] , w , u , ... ]
     
    378378        size_t             num_combined   ,
    379379        const size_t*      combined       ,
    380         connection&        var_sparsity   ,
    381         connection&        vecad_sparsity ,
     380        vector_pack&       var_sparsity   ,
     381        vector_pack&       vecad_sparsity ,
    382382        bool*              var_jacobian   ,
    383383        bool*              vecad_jacobian )
     
    388388        CPPAD_ASSERT_UNKNOWN( arg[0] < num_combined );
    389389        size_t i_v = combined[ arg[0] - 1 ];
    390         CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_from() );
     390        CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_set() );
    391391
    392392        vecad_sparsity.binary_union(i_v, i_v, i_z, var_sparsity);
  • trunk/cppad/local/op.hpp

    r1464 r1524  
    1313Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
    1414-------------------------------------------------------------------------- */
     15
     16// used by the sparse operators
     17# include <cppad/local/vector_set.hpp>
    1518
    1619# include <cppad/local/std_math_ad.hpp>
  • trunk/cppad/local/prototype_op.hpp

    r1523 r1524  
    10661066
    10671067\param var_sparsity
    1068 The connections in \a var_sparsity with from node index \a i_z
     1068The connections (EDIT THIS) in \a var_sparsity with from node index \a i_z
    10691069are the sparsity pattern for z.
    1070 These connections are an output for forward mode operations,
     1070These connections (EDIT THIS) are an output for forward mode operations,
    10711071and an input for reverse mode operations.
    10721072
    10731073\param vecad_sparsity
    1074 The connections in \a vecad_sparsity with from node index \a i_v
     1074The connections (EDIT THIS) in \a vecad_sparsity with from node index \a i_v
    10751075are the sparsity bit pattern for the vector v.
    1076 These connections are an input for forward mode operations.
     1076These connections (EDIT THIS) are an input for forward mode operations.
    10771077For reverse mode operations,
    10781078the sparsity pattern for z is added to the sparsity pattern for v.
     
    10831083\li 0         <  \a arg[0]
    10841084\li \a arg[0] < \a num_combined
    1085 \li i_v       < \a vecad_sparsity.n_from()
     1085\li i_v       < \a vecad_sparsity.n_set()
    10861086*/
    10871087inline void sparse_load_op(
     
    10911091        size_t              num_combined   ,
    10921092        const size_t*       combined       ,
    1093         connection&         var_sparsity   ,
    1094         connection&         vecad_sparsity )
     1093        vector_pack&        var_sparsity   ,
     1094        vector_pack&        vecad_sparsity )
    10951095{
    10961096        // This routine is only for documentaiton, it should not be used
     
    12501250
    12511251\param var_sparsity
    1252 The connections in \a var_sparsity corresponding to the from index \a arg[2]
     1252The connections (EDIT THIS) in \a var_sparsity corresponding to the from index \a arg[2]
    12531253correspond to the variable y.
    12541254These are an input for forward mode operations.
     
    12571257
    12581258\param vecad_sparsity
    1259 The connections in \a vecad_sparsity corresponding to the from index \a i_v
     1259The connections (EDIT THIS) in \a vecad_sparsity corresponding to the from index \a i_v
    12601260correspond to the vector v.
    12611261These are an input for reverse mode operations.
     
    12681268\li 0 <  \a arg[0]
    12691269\li \a arg[0] < \a num_combined
    1270 \li \a arg[2] < \a var_sparsity.n_from()
    1271 \li i_v       < \a vecad_sparsity.n_from()
     1270\li \a arg[2] < \a var_sparsity.n_set()
     1271\li i_v       < \a vecad_sparsity.n_set()
    12721272*/
    12731273inline void sparse_store_op(
     
    13171317
    13181318\param for_jac_sparsity
    1319 The connections for the from node \a i_x
     1319The connections (EDIT THIS) for the from node \a i_x
    13201320is the forward mode Jacobian sparsity pattern for the variable x.
    13211321
    13221322\param rev_hes_sparsity
    1323 The connections for the from node with from index \a i_z in \a rev_hes_sparsity
     1323The connections (EDIT THIS) for the from node with from index \a i_z in \a rev_hes_sparsity
    13241324is the Hessian sparsity pattern for the fucntion G
    13251325where one of the partials derivative is with respect to z.
    13261326\n
    13271327\n
    1328 The connections for the form node with index \a i_x in \a rev_hes_sparsity
     1328The connections (EDIT THIS) for the form node with index \a i_x in \a rev_hes_sparsity
    13291329is the Hessian sparsity pattern
    13301330where one of the partials derivative is with respect to x.
     
    13391339        size_t              i_x               ,
    13401340        bool*               rev_jacobian      ,
    1341         connection&         for_jac_sparsity  ,
    1342         connection&         rev_hes_sparsity  )
     1341        vector_pack&        for_jac_sparsity  ,
     1342        vector_pack&        rev_hes_sparsity  )
    13431343{       
    13441344        // This routine is only for documentaiton, it should not be used
     
    13891389
    13901390\param for_jac_sparsity
    1391 The connections in \a for_jac_sparsity for the
     1391The connections (EDIT THIS) in \a for_jac_sparsity for the
    13921392from node with index \a arg[0] are the forward sparsity pattern for x.
    13931393\n
    13941394\n
    1395 The connections in \a for_jac_sparsity for the
     1395The connections (EDIT THIS) in \a for_jac_sparsity for the
    13961396from node with index \a arg[1] are the forward sparsity pattern for y.
    13971397
    13981398\param rev_hes_sparsity
    1399 The connections in \a rev_hes_sparsity for the
     1399The connections (EDIT THIS) in \a rev_hes_sparsity for the
    14001400from node with index \a i_z are the Hessian sparsity pattern
    14011401for the function G
     
    14031403\n
    14041404\n
    1405 The connections in \a rev_hes_sparsity for the
     1405The connections (EDIT THIS) in \a rev_hes_sparsity for the
    14061406from node wiht index \a arg[0] are the Hessian sparsity pattern
    14071407where one of the partial derivatives is with respect to x.
     
    14101410\n
    14111411\n
    1412 The connections in \a rev_hes_sparsity for the
     1412The connections (EDIT THIS) in \a rev_hes_sparsity for the
    14131413from node wiht index \a arg[1] are the Hessian sparsity pattern
    14141414where one of the partial derivatives is with respect to y.
     
    14241424        const size_t*     arg                ,
    14251425        bool*             jac_reverse        ,
    1426         connection&       for_jac_sparsity   ,
    1427         connection&       rev_hes_sparsity   )
     1426        vector_pack&      for_jac_sparsity   ,
     1427        vector_pack&      rev_hes_sparsity   )
    14281428{       
    14291429        // This routine is only for documentaiton, it should not be used
  • trunk/cppad/local/rev_hes_sweep.hpp

    r1523 r1524  
    8989\b Output: For j = 1 , ... , \a n,
    9090the reverse Hessian sparsity pattern for the independent dependent variable
    91 with index (j-1) is given by the from connections for the node with index j
     91with index (j-1) is given by the from connections (EDIT THIS) for the node with index j
    9292in \a rev_hes_sparse.
    9393The values in the rest of \a rev_hes_sparse are not specified; i.e.,
     
    100100        size_t                numvar,
    101101        player<Base>         *play,
    102         connection&           for_jac_sparse, // should be const
     102        vector_pack&          for_jac_sparse, // should be const
    103103        bool*                 RevJac,
    104         connection&           rev_hes_sparse
     104        vector_pack&          rev_hes_sparse
    105105)
    106106{
     
    118118        // check numvar argument
    119119        CPPAD_ASSERT_UNKNOWN( play->num_rec_var()     == numvar );
    120         CPPAD_ASSERT_UNKNOWN( for_jac_sparse.n_from() == numvar );
    121         CPPAD_ASSERT_UNKNOWN( rev_hes_sparse.n_from() == numvar );
     120        CPPAD_ASSERT_UNKNOWN( for_jac_sparse.n_set() == numvar );
     121        CPPAD_ASSERT_UNKNOWN( rev_hes_sparse.n_set() == numvar );
    122122        CPPAD_ASSERT_UNKNOWN( numvar > 0 );
    123123
    124         // number of to nodes in connections
    125         size_t n_to   = rev_hes_sparse.n_to();
    126         CPPAD_ASSERT_UNKNOWN( rev_hes_sparse.n_to() == n_to );
    127 
    128         // number of packed values per from node
     124        // number of to nodes in (EDIT THIS) connections
     125        size_t limit   = rev_hes_sparse.limit();
     126        CPPAD_ASSERT_UNKNOWN( rev_hes_sparse.limit() == limit );
     127
     128        // check number of sets match
    129129        CPPAD_ASSERT_UNKNOWN(
    130                 for_jac_sparse.n_pack() == rev_hes_sparse.n_pack()
     130                for_jac_sparse.n_set() == rev_hes_sparse.n_set()
    131131        );
    132132
     
    136136        size_t num_vecad_ind   = play->num_rec_vecad_ind();
    137137        size_t num_vecad_vec   = play->num_rec_vecad_vec();
    138         connection       vecad_sparse;
    139         vecad_sparse.resize(num_vecad_vec, n_to);
     138        vector_pack      vecad_sparse;
     139        vecad_sparse.resize(num_vecad_vec, limit);
    140140        size_t* vecad_ind   = CPPAD_NULL;
    141141        bool*   vecad_jac   = CPPAD_NULL;
     
    166166# if CPPAD_REV_HES_SWEEP_TRACE
    167167        std::cout << std::endl;
    168         CppAD::vectorBool zf_value(n_to);
    169         CppAD::vectorBool zh_value(n_to);
     168        CppAD::vectorBool zf_value(limit);
     169        CppAD::vectorBool zh_value(limit);
    170170# endif
    171171        while(i_op > 1)
     
    177177
    178178# if CPPAD_REV_HES_SWEEP_TRACE
    179                 for(j = 0; j < n_to; j++)
     179                for(j = 0; j < limit; j++)
    180180                {       zf_value[j] = for_jac_sparse.get_element(i_var, j);
    181181                        zh_value[j] = rev_hes_sparse.get_element(i_var, j);
  • trunk/cppad/local/rev_jac_sweep.hpp

    r1523 r1524  
    8383        size_t                numvar,
    8484        player<Base>         *play,
    85         connection&           var_sparsity
     85        vector_pack&          var_sparsity
    8686)
    8787{
     
    100100        CPPAD_ASSERT_UNKNOWN( numvar > 0 );
    101101        CPPAD_ASSERT_UNKNOWN( play->num_rec_var()   == numvar );
    102         CPPAD_ASSERT_UNKNOWN( var_sparsity.n_from() == numvar );
     102        CPPAD_ASSERT_UNKNOWN( var_sparsity.n_set() == numvar );
    103103
    104104        // number of to nodes in the connection
    105         size_t n_to = var_sparsity.n_to();
     105        size_t n_to = var_sparsity.limit();
    106106
    107107        // vecad_sparsity contains a sparsity pattern for each VecAD object.
     
    110110        size_t num_vecad_ind   = play->num_rec_vecad_ind();
    111111        size_t num_vecad_vec   = play->num_rec_vecad_vec();
    112         connection       vecad_sparsity;
     112        vector_pack      vecad_sparsity;
    113113        vecad_sparsity.resize(num_vecad_vec, n_to);
    114114        size_t* vecad_ind      = CPPAD_NULL;
  • trunk/cppad/local/rev_sparse_hes.hpp

    r1523 r1524  
    209209
    210210        CPPAD_ASSERT_KNOWN(
    211                 q == for_jac_sparsity_.n_to(),
     211                q == for_jac_sparsity_.limit(),
    212212                "RevSparseHes: q (first argument) is not equal to its value"
    213213                " in the previous call to ForSparseJac with this ADFun object."
     
    224224
    225225        // connection object that will hold packed reverse Hessain values
    226         connection       rev_hes_sparsity;
     226        vector_pack      rev_hes_sparsity;
    227227        rev_hes_sparsity.resize(total_num_var_, q);
    228228
  • trunk/cppad/local/rev_sparse_jac.hpp

    r1523 r1524  
    179179
    180180        // connection object that will hold the results
    181         connection       var_sparsity;
     181        vector_pack      var_sparsity;
    182182        var_sparsity.resize(total_num_var_, p);
    183183
  • trunk/cppad/local/sparse_binary_op.hpp

    r1523 r1524  
    1212Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
    1313-------------------------------------------------------------------------- */
    14 # include <cppad/local/connection.hpp>
    1514CPPAD_BEGIN_NAMESPACE
    1615
     
    7877        size_t            i_z           ,
    7978        const size_t*     arg           ,
    80         connection&       sparsity      )
     79        vector_pack&      sparsity      )
    8180{       
    8281        // check assumptions
     
    129128
    130129\param sparsity
    131 The connections in \a sparsity for the
     130The (EDIT THIS) connections in \a sparsity for the
    132131from node with index \a i_z are the sparsity pattern for z
    133132and corresponding ot the function G.
    134133\n
    135134\n
    136 The connections in \a sparsity for the
     135The (EDIT THIS) connections in \a sparsity for the
    137136from node with index \a arg[0] are the sparsity pattern for x.
    138137On input, they correspond to the function G,
     
    140139\n
    141140\n
    142 The connections in \a sparsity for the
     141The (EDIT THIS) connections in \a sparsity for the
    143142from node with index \a arg[1] are the sparsity pattern for y.
    144143On input, they correspond to the function G,
     
    152151        size_t              i_z           ,
    153152        const size_t*       arg           ,
    154         connection&         sparsity      )
     153        vector_pack&        sparsity      )
    155154{       
    156155        // check assumptions
     
    179178        const size_t*        arg                ,
    180179        bool*                jac_reverse        ,
    181         connection&          for_jac_sparsity   ,
    182         connection&          rev_hes_sparsity   )
     180        vector_pack&         for_jac_sparsity   ,
     181        vector_pack&         rev_hes_sparsity   )
    183182{       
    184183        // check assumptions
     
    210209        const size_t*        arg                ,
    211210        bool*                jac_reverse        ,
    212         connection&          for_jac_sparsity   ,
    213         connection&          rev_hes_sparsity   )
     211        vector_pack&         for_jac_sparsity   ,
     212        vector_pack&         rev_hes_sparsity   )
    214213{       
    215214        // check assumptions
     
    247246        const size_t*        arg                ,
    248247        bool*                jac_reverse        ,
    249         connection&          for_jac_sparsity   ,
    250         connection&          rev_hes_sparsity   )
     248        vector_pack&         for_jac_sparsity   ,
     249        vector_pack&         rev_hes_sparsity   )
    251250{       
    252251        // check assumptions
     
    286285        const size_t*        arg                ,
    287286        bool*                jac_reverse        ,
    288         connection&          for_jac_sparsity   ,
    289         connection&          rev_hes_sparsity   )
     287        vector_pack&         for_jac_sparsity   ,
     288        vector_pack&         rev_hes_sparsity   )
    290289{       
    291290        // check assumptions
  • trunk/cppad/local/sparse_unary_op.hpp

    r1523 r1524  
    1212Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
    1313-------------------------------------------------------------------------- */
    14 # include <cppad/local/connection.hpp>
    1514CPPAD_BEGIN_NAMESPACE
    1615
     
    6766        size_t            i_z           ,
    6867        size_t            i_x           ,
    69         connection&       sparsity      )
     68        vector_pack&      sparsity      )
    7069{       
    7170        // check assumptions
     
    123122        size_t     i_z                     ,
    124123        size_t     i_x                     ,
    125         connection&            sparsity    )
     124        vector_pack&           sparsity    )
    126125{       
    127126        // check assumptions
     
    152151        size_t              i_x               ,
    153152        bool*               rev_jacobian      ,
    154         connection&         for_jac_sparsity  ,
    155         connection&         rev_hes_sparsity  )
     153        vector_pack&        for_jac_sparsity  ,
     154        vector_pack&        rev_hes_sparsity  )
    156155{       
    157156        // check assumptions
     
    184183        size_t              i_x               ,
    185184        bool*               rev_jacobian      ,
    186         connection&         for_jac_sparsity  ,
    187         connection&         rev_hes_sparsity  )
     185        vector_pack&        for_jac_sparsity  ,
     186        vector_pack&        rev_hes_sparsity  )
    188187{       
    189188        // check assumptions
  • trunk/cppad/local/store_op.hpp

    r1523 r1524  
    166166        size_t              num_combined   ,
    167167        const size_t*       combined       ,
    168         connection&         var_sparsity   ,
    169         connection&         vecad_sparsity )
     168        vector_pack&        var_sparsity   ,
     169        vector_pack&        vecad_sparsity )
    170170{
    171171        CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 );
     
    174174        CPPAD_ASSERT_UNKNOWN( arg[0] < num_combined );
    175175        size_t i_v = combined[ arg[0] - 1 ];
    176         CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_from() );
    177         CPPAD_ASSERT_UNKNOWN( arg[2] < var_sparsity.n_from() );
     176        CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_set() );
     177        CPPAD_ASSERT_UNKNOWN( arg[2] < var_sparsity.n_set() );
    178178
    179179        vecad_sparsity.binary_union(i_v, i_v, arg[2], var_sparsity);
     
    185185Reverse mode sparsity operations for StpvOp and StvvOp
    186186
    187 This routine is given the connections corresponding to
     187This routine is given the (EDIT THIS) connections corresponding to
    188188G(v[x], y , w , u ... )
    189189and it uses them to compute the partial derivatives of
     
    199199        size_t             num_combined    ,
    200200        const size_t*      combined        ,
    201         connection&        var_sparsity    ,
    202         connection&        vecad_sparsity  )
     201        vector_pack&       var_sparsity    ,
     202        vector_pack&       vecad_sparsity  )
    203203{
    204204        CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 );
     
    207207        CPPAD_ASSERT_UNKNOWN( arg[0] < num_combined );
    208208        size_t i_v = combined[ arg[0] - 1 ];
    209         CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_from() );
    210         CPPAD_ASSERT_UNKNOWN( arg[2] < var_sparsity.n_from() );
     209        CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_set() );
     210        CPPAD_ASSERT_UNKNOWN( arg[2] < var_sparsity.n_set() );
    211211
    212212        var_sparsity.binary_union(arg[2], arg[2], i_v, vecad_sparsity);
     
    218218Reverse mode sparsity operations for StpvOp and StvvOp
    219219
    220 This routine is given the connections corresponding to
     220This routine is given the (EDIT THIS) connections corresponding to
    221221G(v[x], y , w , u ... )
    222222and it uses them to compute the partial derivatives of
     
    244244        size_t             num_combined ,
    245245        const size_t*      combined     ,
    246         connection&        var_sparsity ,
    247         connection&        vecad_sparsity ,
     246        vector_pack&       var_sparsity ,
     247        vector_pack&       vecad_sparsity ,
    248248        bool*              var_jacobian   ,
    249249        bool*              vecad_jacobian )
     
    254254        CPPAD_ASSERT_UNKNOWN( arg[0] < num_combined );
    255255        size_t i_v = combined[ arg[0] - 1 ];
    256         CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_from() );
    257         CPPAD_ASSERT_UNKNOWN( arg[2] < var_sparsity.n_from() );
     256        CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_set() );
     257        CPPAD_ASSERT_UNKNOWN( arg[2] < var_sparsity.n_set() );
    258258
    259259        var_sparsity.binary_union(arg[2], arg[2], i_v, vecad_sparsity);
  • trunk/cppad/local/vector_set.hpp

    r1523 r1524  
    1 # ifndef CPPAD_CONNECTION_INCLUDED
    2 # define CPPAD_CONNECTION_INCLUDED
     1# ifndef CPPAD_VECTOR_SET_INCLUDED
     2# define CPPAD_VECTOR_SET_INCLUDED
    33CPPAD_BEGIN_NAMESPACE
    44
     
    1515
    1616/*!
    17 \file connection.hpp
    18 Class for encapsulating bit pattern operations in preparation for conversion
    19 to set operations.
     17\file vector_set.hpp
     18Vector of sets of positive integers.
    2019*/
    2120
    2221/*!
    23 Represent the connections from one node to another node of a graph.
    24 
    25 \tparam Pack
    26 is the type used to pack the bit patterns that represent connections in
    27 the current implementation. Up to size_t(Pack) * 8 connections can be
    28 represented by each value of type Pack.
     22Vector of sets of postivie integers, each set stored as a packed boolean array.
    2923*/
    3024
    3125# include <cppad/local/cppad_assert.hpp>
    3226
    33 class connection {
     27class vector_pack {
    3428private:
    3529        /// type used to pack values
     
    3731        /// Number of bits per Pack value
    3832        static const size_t n_bit_ = std::numeric_limits<Pack>::digits;
    39         /// Number of nodes that we are representing connections from
     33        /// Number of sets that we are representing
    4034        /// (set by constructor and resize).
    41         size_t n_from_;
    42         /// Number of nodes that we are representing connections to
     35        size_t n_set_;
     36        /// Possible element values in each set are 0, 1, ..., limit_ - 1
    4337        /// (set by constructor and resize).
    44         size_t n_to_;
    45         /// Number of \a Pack values necessary to represent \c n_to_ bits.
     38        size_t limit_;
     39        /// Number of \c Pack values necessary to represent \c limit_ bits.
    4640        /// (set by constructor and resize).
    4741        size_t n_pack_;
    4842        /// Is the memory pointed to by \c data_ allocated by this object
    4943        /// (set by contructor and resize)
    50         bool   data_allocated_;   
    51         /// Pointer to the first packed value for all the connections.
     44        bool   allocated_;   
     45        /// Pointer to the beginning of data for all the sets.
    5246        Pack*  data_;
    5347public:
    5448        // -----------------------------------------------------------------
    55         /*! Construct a connection object (with no nodes)
    56         */
    57         connection(void) :
    58         n_from_(0)               ,
    59         n_to_(0)                 ,
     49        /*! Default constructor (no sets)
     50        */
     51        vector_pack(void) :
     52        n_set_(0)                ,
     53        limit_(0)                ,
    6054        n_pack_(0)               ,
    61         data_allocated_(false)
    62         {
    63                 CPPAD_ASSERT_UNKNOWN(
    64                         8 == std::numeric_limits<unsigned char>::digits
    65                 );
    66                 data_ = CPPAD_NULL;
    67         }
     55        allocated_(false)        ,
     56        data_(CPPAD_NULL)
     57        { }
    6858        // -----------------------------------------------------------------
    6959        /*! Make use of copy constructor an error
    7060        */
    71         connection(const connection& c)
     61        vector_pack(const vector_pack& v)
    7262        {       // Error:
    73                 // Probably a connection argument has been passed by value
     63                // Probably a vector_pack argument has been passed by value
    7464                CPPAD_ASSERT_UNKNOWN(0);
    7565        }
     
    7767        /*! Destructor
    7868        */
    79         ~connection(void)
    80         {       if( data_allocated_ )
    81                 {       data_allocated_ = false;
     69        ~vector_pack(void)
     70        {       if( allocated_ )
     71                {       allocated_ = false;
    8272                        CPPAD_TRACK_DEL_VEC( data_ );
    8373                }
    8474        }
    8575        // -----------------------------------------------------------------
    86         /*! Change the number of nodes and initialize with no connections
     76        /*! Change number of sets, set limit, and initialize all sets as empty
    8777
    8878        Any memory currently allocated for this object is freed. If both
    89         \a n_from and \a n_to non-zero new memory is allocated, otherwise
     79        \a n_set and \a limit are non-zero new memory is allocated, otherwise
    9080        no new memory is allocated for the object.
    9181
    92         \param n_from
    93         is the number of nodes that we are representing connections from.
    94 
    95         \param n_to
    96         is the number of nodes that we are representing connections to.
    97         */
    98         void resize(size_t n_from, size_t n_to)
     82        \param n_set
     83        is the number of sets in this vector of sets.
     84
     85        \param limit
     86        is the maximum element value plus one (the minimum element value is 0).
     87        */
     88        void resize(size_t n_set, size_t limit)
    9989        {       Pack zero(0);
    100                 if( data_allocated_ )
    101                 {       data_allocated_ = false;
     90                if( allocated_ )
     91                {       allocated_ = false;
    10292                        CPPAD_TRACK_DEL_VEC(data_);
    10393                }
    10494
    105                 n_from_         = n_from;
    106                 n_to_           = n_to;
    107                 n_pack_         = ( 1 + (n_to - 1) / n_bit_ );
    108                 size_t i        = n_from_ * n_pack_;
     95                n_set_          = n_set;
     96                limit_          = limit;
     97                n_pack_         = ( 1 + (limit - 1) / n_bit_ );
     98                size_t i        = n_set_ * n_pack_;
    10999
    110100                if( i > 0 )
    111                 {       data_ = CPPAD_TRACK_NEW_VEC(i, data_);
    112                         data_allocated_ = true;
     101                {       data_      = CPPAD_TRACK_NEW_VEC(i, data_);
     102                        allocated_ = true;
    113103                        while(i--)
    114104                                data_[i] = zero;
     
    116106        }
    117107        // -----------------------------------------------------------------
    118         /*! Set one connection element between a from and to node.
    119 
    120         \param from
    121         is the from node for this connection.
    122 
    123         \param to
    124         is the to node for this connection
    125 
    126         \par Checked Assertions
    127         \li from < n_from_
    128         \li to   < n_to_
    129         */
    130         void set_element(size_t from, size_t to)
     108        /*! Add one element to a set.
     109
     110        \param index
     111        is the index for this set in the vector of sets.
     112
     113        \param value
     114        is the value of this element.
     115
     116        \par Checked Assertions
     117        \li index  < n_set_
     118        \li value  < limit_
     119        */
     120        void set_element(size_t index, size_t value)
    131121        {       static Pack one(1);
    132                 CPPAD_ASSERT_UNKNOWN( from < n_from_ );
    133                 CPPAD_ASSERT_UNKNOWN( to < n_to_ );
    134                 size_t j  = to / n_bit_;
    135                 size_t k  = to - j * n_bit_;
     122                CPPAD_ASSERT_UNKNOWN( index < n_set_ );
     123                CPPAD_ASSERT_UNKNOWN( value < limit_ );
     124                size_t j  = value / n_bit_;
     125                size_t k  = value - j * n_bit_;
    136126                Pack mask = one << k;
    137                 data_[ from * n_pack_ + j] |= mask;
    138         }
    139         // -----------------------------------------------------------------
    140         /*! Is there a connection between a from and to node.
     127                data_[ index * n_pack_ + j] |= mask;
     128        }
     129        // -----------------------------------------------------------------
     130        /*! Does a set have a specific element
    141131       
    142         \param from
    143         is the from node for this connection.
    144 
    145         \param to
    146         is the to node for this connection
    147 
    148         \par Checked Assertions
    149         \li from < n_from_
    150         \li to   < n_to_
    151         */
    152         bool get_element(size_t from, size_t to) const
     132        \param index
     133        is the index for this set in the vector of sets.
     134
     135        \param value
     136        is the value of this element.
     137
     138        \par Checked Assertions
     139        \li index  < n_set_
     140        \li value  < limit_
     141        */
     142        bool get_element(size_t index, size_t value) const
    153143        {       static Pack one(1);
    154                 CPPAD_ASSERT_UNKNOWN( from < n_from_ );
    155                 CPPAD_ASSERT_UNKNOWN( to < n_to_ );
    156                 size_t j  = to / n_bit_;
    157                 size_t k  = to - j * n_bit_;
     144                CPPAD_ASSERT_UNKNOWN( index < n_set_ );
     145                CPPAD_ASSERT_UNKNOWN( value < limit_ );
     146                size_t j  = value / n_bit_;
     147                size_t k  = value - j * n_bit_;
    158148                Pack mask = one << k;
    159                 mask     &= data_[ from * n_pack_ + j];
     149                mask     &= data_[ index * n_pack_ + j];
    160150                return (mask != 0);
    161151        }
    162152
    163153        // -----------------------------------------------------------------
    164         /*! Set connections for one node equal to the empty set.
     154        /*! Assign the empty set to one of the sets.
    165155
    166156        \param target
    167         is the index of the from node for which we are setting the connections.
    168 
    169         \par Checked Assertions
    170         \li target < n_from_
     157        is the index of the set we are setting to the empty set.
     158
     159        \par Checked Assertions
     160        \li target < n_set_
    171161        */
    172162        void clear(size_t target)
    173163        {       // value with all its bits set to false
    174164                static Pack zero(0);
    175                 CPPAD_ASSERT_UNKNOWN( target < n_from_ );
     165                CPPAD_ASSERT_UNKNOWN( target < n_set_ );
    176166                Pack *t  = data_ + target * n_pack_;
    177167
     
    181171        }
    182172        // -----------------------------------------------------------------
    183         /*! Set connections for one node equal those for another.
     173        /*! Assign one set equal to another set.
    184174
    185175        \param this_target
    186         is the index of the from node in this connection object
    187         for which we are setting the connections.
     176        is the index (in this \c vector_pack object) of the set being assinged.
    188177
    189178        \param other_value
    190         is the index of the from node in the other connection object
    191         containing the values that we are assigning to the target node.
     179        is the index (in the other \c vector_pack object) of the
     180        that we are using as the value to assign to the target set.
    192181
    193182        \param other
    194         is the other connection object (which may be the same as this
    195         connection object).
    196 
    197         \par Checked Assertions
    198         \li this_target  < n_from_
    199         \li other_value  < other.n_from_
     183        is the other \c vector_pack object (which may be the same as this
     184        \c vector_pack object).
     185
     186        \par Checked Assertions
     187        \li this_target  < n_set_
     188        \li other_value  < other.n_set_
    200189        \li n_pack_     == other.n_pack_
    201190        */
     
    203192                size_t               this_target  ,
    204193                size_t               other_value  ,
    205                 const connection&    other        )
    206         {       CPPAD_ASSERT_UNKNOWN( this_target  <   n_from_ );
    207                 CPPAD_ASSERT_UNKNOWN( other_value  <   other.n_from_ );
     194                const vector_pack&   other        )
     195        {       CPPAD_ASSERT_UNKNOWN( this_target  <   n_set_        );
     196                CPPAD_ASSERT_UNKNOWN( other_value  <   other.n_set_ );
    208197                CPPAD_ASSERT_UNKNOWN( n_pack_      ==  other.n_pack_ );
    209198                Pack *t  = data_       + this_target * n_pack_;
     
    216205
    217206        // -----------------------------------------------------------------
    218         /*! Set connections for one node equal union of those for two others.
     207        /*! Assing a set equal to the union of two other sets.
    219208
    220209        \param this_target
    221         is the index of the from node in this connection object
    222         for which we are setting the connections.
     210        is the index (in this \c vector_pack object) of the set being assinged.
    223211
    224212        \param this_left
    225         is the index of the from node in this connection object
    226         for the left operand in the union operation.
     213        is the index (in this \c vector_pack object) of the
     214        left operand for the union operation.
    227215        It is OK for \a this_target and \a this_left to be the same value.
    228216
    229217        \param other_right
    230         is the index of the from node in the \a other connection object
    231         for the right operand in the union operation.
     218        is the index (in the other \c vector_pack object) of the
     219        right operand for the union operation.
     220        It is OK for \a this_target and \a other_right to be the same value.
    232221
    233222        \param other
    234         is the other connection object (which may be the same as this
    235         connection object).
    236 
    237         \par Checked Assertions
    238         \li this_target <  n_from_
    239         \li this_left   <  n_from_
    240         \li other_right <  other.n_from_
     223        is the other \c vector_pack object (which may be the same as this
     224        \c vector_pack object).
     225
     226        \par Checked Assertions
     227        \li this_target <  n_set_
     228        \li this_left   <  n_set_
     229        \li other_right <  other.n_set_
    241230        \li n_pack_     == other.n_pack_
    242231        */
     
    245234                size_t                  this_left    ,
    246235                size_t                  other_right  ,
    247                 const connection&       other        )
    248         {       CPPAD_ASSERT_UNKNOWN( this_target < n_from_ );
    249                 CPPAD_ASSERT_UNKNOWN( this_left   < n_from_ );
    250                 CPPAD_ASSERT_UNKNOWN( other_right < other.n_from_ );
    251                 CPPAD_ASSERT_UNKNOWN( n_pack_     ==  other.n_pack_ );
     236                const vector_pack&      other        )
     237        {       CPPAD_ASSERT_UNKNOWN( this_target < n_set_        );
     238                CPPAD_ASSERT_UNKNOWN( this_left   < n_set_        );
     239                CPPAD_ASSERT_UNKNOWN( other_right < other.n_set_  );
     240                CPPAD_ASSERT_UNKNOWN( n_pack_    ==  other.n_pack_ );
    252241
    253242                Pack *t  = data_       + this_target * n_pack_;
     
    260249        }
    261250        // -----------------------------------------------------------------
    262         /*! Amount of memory used by this object
     251        /*! Amount of memory used by this vector of sets
    263252 
    264253        /return
     
    266255        */
    267256        size_t memory(void) const
    268         {       return n_from_ * n_pack_ * sizeof(Pack);
    269         }
    270         // -----------------------------------------------------------------
    271         /*! Fetch n_from for this connection object.
     257        {       return n_set_ * n_pack_ * sizeof(Pack);
     258        }
     259        // -----------------------------------------------------------------
     260        /*! Fetch n_set for vector of sets object.
    272261       
    273262        \return
    274         Number of from nodes for this connection object
    275         */
    276         size_t n_from(void) const
    277         {       return n_from_; }
    278         // -----------------------------------------------------------------
    279         /*! Fetch n_to for this connection object.
     263        Number of from sets for this vector of sets object
     264        */
     265        size_t n_set(void) const
     266        {       return n_set_; }
     267        // -----------------------------------------------------------------
     268        /*! Fetch limit for this vector of sets object.
    280269       
    281270        \return
    282         Number of to nodes for this connection object
    283         */
    284         size_t n_to(void) const
    285         {       return n_to_; }
    286         // -----------------------------------------------------------------
    287         /*! Fetch n_pack for this connection object.
    288 
    289         This is a temporary function for use during refactoring of source.
    290        
    291         \return
    292         Number of Pack values per from node for this connection object
    293         */
    294         size_t n_pack(void) const
    295         {       return n_pack_; }
    296         // -----------------------------------------------------------------
    297         /*! Fetch n_bit for this connection object.
    298        
    299         This is a temporary function for use during refactoring of source.
    300 
    301         \return
    302         Number of bits per Pack values
    303         */
    304         static size_t n_bit(void)
    305         {       return n_bit_; }
    306         // -----------------------------------------------------------------
    307         /*! Fetch data for this connection object.
    308 
    309         This is a temporary function for use during refactoring of source.
    310        
    311         \return
    312         Pointer to the raw data for this connection object.
    313         This return value is not longer valid after the next call to
    314         the resize member function.
    315         */
    316         Pack* data(void)
    317         {       return data_; }
     271        is the maximum element value plus one (the minimum element value is 0).
     272        */
     273        size_t limit(void) const
     274        {       return limit_; }
    318275};
    319276
  • trunk/example/test_one.sh.in

    r1375 r1524  
    11# $Id$
    22# -----------------------------------------------------------------------------
    3 # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-08 Bradley M. Bell
     3# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-09 Bradley M. Bell
    44#
    55# CppAD is distributed under multiple licenses. This distribution is under
     
    1616        echo "file is the *.cpp file name with extension"
    1717        echo "and extra is extra options for g++ command"
     18        exit 1
     19fi
     20if [ ! -e "$1" ]
     21then
     22        echo "Cannot find the file $1"
    1823        exit 1
    1924fi
  • trunk/makefile.am

    r1506 r1524  
    9696        cppad/local/comp_op.hpp \
    9797        cppad/local/cond_op.hpp \
    98         cppad/local/connection.hpp \
    9998        cppad/local/convert.hpp \
    10099        cppad/local/cos_op.hpp \
     
    180179        cppad/local/unary_plus.hpp \
    181180        cppad/local/vec_ad.hpp \
     181        cppad/local/vector_set.hpp \
    182182        cppad/local/undef.hpp \
    183183        cppad/local/value.hpp \
  • trunk/makefile.in

    r1507 r1524  
    329329        cppad/local/comp_op.hpp \
    330330        cppad/local/cond_op.hpp \
    331         cppad/local/connection.hpp \
    332331        cppad/local/convert.hpp \
    333332        cppad/local/cos_op.hpp \
     
    413412        cppad/local/unary_plus.hpp \
    414413        cppad/local/vec_ad.hpp \
     414        cppad/local/vector_set.hpp \
    415415        cppad/local/undef.hpp \
    416416        cppad/local/value.hpp \
  • trunk/test_more/test_one.sh.in

    r1376 r1524  
    1717        echo "file is the *.cpp file name with extension"
    1818        echo "and extra is extra options for g++ command"
     19        exit 1
     20fi
     21if [ ! -e "$1" ]
     22then
     23        echo "Cannot find the file $1"
    1924        exit 1
    2025fi
Note: See TracChangeset for help on using the changeset viewer.