Changeset 2903


Ignore:
Timestamp:
Sep 19, 2013 11:53:13 AM (7 years ago)
Author:
bradbell
Message:

Add lines from atomic_base documentation to corresponding examples.

package.sh: ignore the bug/build directory.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/package.sh

    r2770 r2903  
    114114        \( -name '*.txt' \) | sed \
    115115                -e '/\.\/build\//d' \
     116                -e '/bug\/build\//d' \
    116117                -e '/\/junk.sh$/d' \
    117118                -e '/\/temp.sh$/d' \
  • trunk/cppad/example/matrix_mul.hpp

    r2861 r2903  
    2424$index matrix, multiply atomic operation$$
    2525
    26 $code
    27 $verbatim%cppad/example/matrix_mul.hpp%0%// BEGIN C++%// END C++%1%$$
    28 $$
    29 
    30 $end
    31 */
    32 // BEGIN C++
     26$nospell
     27
     28$head Start Class Definition$$
     29$codep */
    3330# include <cppad/cppad.hpp>
    34 
    3531namespace { // Begin empty namespace
    3632using CppAD::vector;
     
    5349// matrix result = left * right
    5450class matrix_mul : public CppAD::atomic_base<double> {
    55 private:
     51/* $$
     52$head Constructor$$
     53$codep */
     54        private:
    5655        // number of rows in left operand and in the result
    5756        const size_t nr_result_;
     
    6463        // dimension of the range space
    6564        const size_t m_;
    66 public:
     65        public:
    6766        // ---------------------------------------------------------------------
    6867        // constructor
     
    7574        m_( n_middle * nc_result )
    7675        { }
    77 private:
    78         // left matrix index in the taylor coefficient vector tx.
     76        private:
     77/* $$
     78$head Left Operand Element Index$$
     79$codep */
     80        // left matrix element index in the taylor coefficient vector tx.
    7981        size_t left(
    8082                size_t i  , // left matrix row index
     
    8688                return (i * n_middle_ + j) * nk + k;
    8789        }
    88         // right matrix index in the taylor coefficient vector tx.
     90/* $$
     91$head Right Operand Element Index$$
     92$codep */
     93        // right matrix element index in the taylor coefficient vector tx.
    8994        size_t right(
    9095                size_t i  , // right matrix row index
     
    97102                return (offset + i * nc_result_ + j) * nk + k;
    98103        }
    99         // result matrix index in the taylor coefficient vector ty.
     104/* $$
     105$head Result Element Index$$
     106$codep */
     107        // result matrix element index in the taylor coefficient vector ty.
    100108        size_t result(
    101109                size_t i  , // result matrix row index
     
    107115                return (i * nc_result_ + j) * nk + k;
    108116        }
     117/* $$
     118$head Forward Matrix Multipliy$$
     119$codep */
    109120        // Forward mode multiply Taylor coefficients in tx and sum into ty
    110121        // (for one pair of left and right orders)
     
    133144                }
    134145        }
     146/* $$
     147$head Reverse Matrix Multipliy$$
     148$codep */
    135149        // Reverse mode partials of Taylor coefficients and sum into px
    136150        // (for one pair of left and right orders)
     
    164178                return;
    165179        }
    166         // ----------------------------------------------------------------------
     180/* $$
     181$head forward$$
     182$codep */
    167183        // forward mode routine called by CppAD
    168184        bool forward(
     
    220236                return true;
    221237        }
    222         // ----------------------------------------------------------------------
     238/* $$
     239$head reverse$$
     240$codep */
    223241        // reverse mode routine called by CppAD
    224242        virtual bool reverse(
     
    250268                return true;
    251269        }
    252         // ----------------------------------------------------------------------
     270/* $$
     271$head for_sparse_jac$$
     272$codep */
    253273        // forward Jacobian sparsity routine called by CppAD
    254274        virtual bool for_sparse_jac(
     
    305325                return true;
    306326        }
    307         // ----------------------------------------------------------------------
     327/* $$
     328$head rev_sparse_jac$$
     329$codep */
    308330        // reverse Jacobian sparsity routine called by CppAD
    309331        virtual bool rev_sparse_jac(
     
    367389                }
    368390                return true;
    369 
    370         }
    371         // ----------------------------------------------------------------------
     391        }
     392/* $$
     393$head rev_sparse_hes$$
     394$codep */
    372395        // reverse Hessian sparsity routine called by CppAD
    373396        virtual bool rev_sparse_hes(
     
    490513                return true;
    491514        }
    492 };
    493 
    494 } // End empty namespace
    495 // END C++
     515
     516/* $$
     517$head End Class Definition$$
     518$codep */
     519}; // End of matrix_mul class
     520}  // End empty namespace
     521/* $$
     522$$ $comment end nospell$$
     523$end
     524*/
     525
    496526
    497527# endif
  • trunk/cppad/local/atomic_base.hpp

    r2902 r2903  
    9090        ctor
    9191        const
     92        matrix_mul.hpp
    9293$$
    9394
     
    153154The suggested value for $icode name$$ is $icode afun$$ or $icode atomic_user$$,
    154155i.e., the name of the corresponding atomic object or class.
     156
     157$head Examples$$
     158The following files contain example user atomic function constructors:
     159$cref%get_started.cpp%atomic_get_started.cpp%Constructor%$$,
     160$cref%reciprocal.cpp%atomic_reciprocal.cpp%Constructor%$$,
     161$cref%tangent.cpp%atomic_tangent.cpp%Constructor%$$,
     162$cref%matrix_mul.hpp%atomic_matrix_mul.hpp%Constructor%$$.
     163
    155164
    156165$end
     
    498507$begin atomic_forward$$
    499508$spell
     509        mul.hpp
    500510        hes
    501511        afun
     
    644654Otherwise, it should be false.
    645655
    646 $head Example$$
     656$head Discussion$$
    647657For example, suppose that $icode%p% == 2%$$,
    648658and you know how to compute the function $latex f(x)$$,
     
    673683        ty [ i * (p + 1) + k ] = y_i^k
    674684\] $$
     685
     686$head Examples$$
     687The following files contain example atomic $code forward$$ functions:
     688$cref%get_started.cpp%atomic_get_started.cpp%forward%$$,
     689$cref%reciprocal.cpp%atomic_reciprocal.cpp%forward%$$,
     690$cref%tangent.cpp%atomic_tangent.cpp%forward%$$,
     691$cref%matrix_mul.hpp%atomic_matrix_mul.hpp%forward%$$.
     692
    675693 
    676694$end
     
    712730$begin atomic_reverse$$
    713731$spell
     732        mul.hpp
    714733        afun
    715734        ty
     
    875894otherwise it failed.
    876895
     896$head Examples$$
     897The following files contain example atomic $code reverse$$ functions:
     898$cref%reciprocal.cpp%atomic_reciprocal.cpp%reverse%$$,
     899$cref%tangent.cpp%atomic_tangent.cpp%reverse%$$,
     900$cref%matrix_mul.hpp%atomic_matrix_mul.hpp%reverse%$$.
     901
     902
    877903$end
    878904-----------------------------------------------------------------------------
     
    909935$begin atomic_for_sparse_jac$$
    910936$spell
     937        mul.hpp
    911938        afun
    912939        Jacobian
     
    9781005If it is $code true$$, the corresponding evaluation succeeded,
    9791006otherwise it failed.
     1007
     1008$head Examples$$
     1009The following files contain example atomic $code for_sparse_jac$$ functions:
     1010$cref%reciprocal.cpp%atomic_reciprocal.cpp%for_sparse_jac%$$,
     1011$cref%tangent.cpp%atomic_tangent.cpp%for_sparse_jac%$$,
     1012$cref%matrix_mul.hpp%atomic_matrix_mul.hpp%for_sparse_jac%$$.
    9801013
    9811014$end
     
    10081041$begin atomic_rev_sparse_jac$$
    10091042$spell
     1043        mul.hpp
    10101044        rt
    10111045        afun
     
    10791113If it is $code true$$, the corresponding evaluation succeeded,
    10801114otherwise it failed.
     1115
     1116$head Examples$$
     1117The following files contain example atomic $code rev_sparse_jac$$ functions:
     1118$cref%reciprocal.cpp%atomic_reciprocal.cpp%rev_sparse_jac%$$,
     1119$cref%tangent.cpp%atomic_tangent.cpp%rev_sparse_jac%$$,
     1120$cref%matrix_mul.hpp%atomic_matrix_mul.hpp%rev_sparse_jac%$$.
    10811121
    10821122$end
     
    11091149$begin atomic_rev_sparse_hes$$
    11101150$spell
     1151        mul.hpp
    11111152        vx
    11121153        afun
     
    12561297\end{array}
    12571298\] $$
     1299
     1300$head Examples$$
     1301The following files contain example atomic $code rev_sparse_hes$$ functions:
     1302$cref%reciprocal.cpp%atomic_reciprocal.cpp%rev_sparse_hes%$$,
     1303$cref%tangent.cpp%atomic_tangent.cpp%rev_sparse_hes%$$,
     1304$cref%matrix_mul.hpp%atomic_matrix_mul.hpp%rev_sparse_hes%$$.
    12581305
    12591306$end
  • trunk/example/atomic/get_started.cpp

    r2902 r2903  
    2323necessary for a $cref atomic_base$$ operation.
    2424
    25 $code
    26 $verbatim%example/atomic/get_started.cpp%0%// BEGIN C++%// END C++%1%$$
    27 $$
     25$nospell
    2826
    29 $end
    30 */
    31 // BEGIN C++
     27$head Start Class Definition$$
     28$codep */
    3229# include <cppad/cppad.hpp>
     30namespace {          // isolate items below to this file
     31using CppAD::vector; // abbreviate as vector
     32class atomic_get_started : public CppAD::atomic_base<double> {
     33/* $$
    3334
    34 namespace { // Begin empty namespace
    35 // ----------------------------------------------------------------------
    36 using CppAD::vector;
    37 
    38 //
    39 class atomic_get_started : public CppAD::atomic_base<double> {
    40 public:
    41         // ----------------------------------------------------------------------
    42         // constructor (example use of const std::string& instead of const char*)
     35$head Constructor$$
     36$codep */
     37        public:
     38        // constructor (could use const char* for name)
    4339        atomic_get_started(const std::string& name) :
    4440        CppAD::atomic_base<double>(name)
    4541        { }
    46 private:
    47         // ----------------------------------------------------------------------
     42        private:
     43/* $$
     44$head forward$$
     45$codep */
    4846        // forward mode routine called by CppAD
    4947        virtual bool forward(
     
    7876                return ok;
    7977        }
     78/* $$
     79$head End Class Definition$$
     80$codep */
    8081}; // End of atomic_get_started class
    8182}  // End empty namespace
    8283
     84/* $$
     85$head Use Atomic Function$$
     86$codep */
    8387bool get_started(void)
    8488{       bool ok = true;
     
    134138        return ok;
    135139}
    136 // END C++
     140/* $$
     141$$ $comment end nospell$$
     142$end
     143*/
  • trunk/example/atomic/mat_mul.cpp

    r2858 r2903  
    1717$$
    1818
    19 $section Matrix Multiply as a User Atomic Operation: Example and Test$$
     19$section User Atomic Matrix Multiply: Example and Test$$
    2020$index atomic, matrix multiply example$$
    2121$index matrix, atomic multiply example$$
     
    2525        cppad/example/matrix_mul.hpp
    2626%$$
    27 $head Include File$$
    28 This routine uses the include file $cref atomic_matrix_mul.hpp$$.
    29 
     27
     28$head Class Definition$$
     29This example uses the file $cref atomic_matrix_mul.hpp$$
     30which defines matrix multiply as a $cref atomic_base$$ operation.
     31
     32$head Use Atomic Function$$
    3033$code
    3134$verbatim%example/atomic/mat_mul.cpp%0%// BEGIN C++%// END C++%1%$$
  • trunk/example/atomic/reciprocal.cpp

    r2899 r2903  
    2626$latex n = 1$$, $latex m = 1$$, and $latex f(x) = 1 / x$$.
    2727
    28 $code
    29 $verbatim%example/atomic/reciprocal.cpp%0%// BEGIN C++%// END C++%1%$$
    30 $$
    31 
    32 $end
    33 */
    34 // BEGIN C++
     28$nospell
     29
     30$head Start Class Definition$$
     31$codep */
    3532# include <cppad/cppad.hpp>
    36 
    37 namespace { // Begin empty namespace
    38 // ----------------------------------------------------------------------
    39 using CppAD::vector;
    40 
     33namespace {           // isolate items below to this file
     34using CppAD::vector;  // abbreviate as vector
     35//
    4136// a utility to compute the union of two sets.
    4237void my_union(
     
    5651//
    5752class atomic_reciprocal : public CppAD::atomic_base<double> {
    58 public:
    59         // ----------------------------------------------------------------------
    60         // constructor (example use of const std::string& instead of const char*)
     53/* $$
     54$head Constructor $$
     55$codep */
     56        public:
     57        // constructor (could use const char* for name)
    6158        atomic_reciprocal(const std::string& name) :
    6259        CppAD::atomic_base<double>(name)
    6360        { }
    64 private:
    65         // ----------------------------------------------------------------------
     61        private:
     62/* $$
     63$head forward$$
     64$codep */
    6665        // forward mode routine called by CppAD
    6766        virtual bool forward(
     
    119118                return ok;
    120119        }
    121         // ----------------------------------------------------------------------
     120/* $$
     121$head reverse$$
     122$codep */
    122123        // reverse mode routine called by CppAD
    123124        virtual bool reverse(
     
    184185                return ok;
    185186        }
    186         // ----------------------------------------------------------------------
     187/* $$
     188$head for_sparse_jac$$
     189$codep */
    187190        // forward Jacobian bool sparsity routine called by CppAD
    188191        virtual bool for_sparse_jac(
     
    220223                return true;
    221224        }
    222         // ----------------------------------------------------------------------
     225/* $$
     226$head rev_sparse_jac$$
     227$codep */
    223228        // reverse Jacobian bool sparsity routine called by CppAD
    224229        virtual bool rev_sparse_jac(
     
    256261                return true;
    257262        }
    258         // ----------------------------------------------------------------------
     263/* $$
     264$head rev_sparse_hes$$
     265$codep */
    259266        // reverse Hessian bool sparsity routine called by CppAD
    260267        virtual bool rev_sparse_hes(
     
    340347                return true;
    341348        }
     349/* $$
     350$head End Class Definition$$
     351$codep */
    342352}; // End of atomic_reciprocal class
    343353}  // End empty namespace
    344354
     355/* $$
     356$head Use Atomic Function$$
     357$codep */
    345358bool reciprocal(void)
    346359{       bool ok = true;
     
    471484        return ok;
    472485}
    473 // END C++
     486/* $$
     487$$ $comment end nospell$$
     488$end
     489*/
  • trunk/example/atomic/tangent.cpp

    r2861 r2903  
    2727functions as user atomic operations.
    2828
    29 $code
    30 $verbatim%example/atomic/tangent.cpp%0%// BEGIN C++%// END C++%1%$$
    31 $$
    32 
    33 $end
    34 */
    35 // BEGIN C++
     29$nospell
     30
     31$head Start Class Definition$$
     32$codep */
    3633# include <cppad/cppad.hpp>
    37 
    3834namespace { // Begin empty namespace
    3935using CppAD::vector;
    40 
     36//
    4137// a utility to compute the union of two sets.
    4238void my_union(
     
    5652//
    5753class atomic_tangent : public CppAD::atomic_base<float> {
    58 private:
     54/* $$
     55$head Constructor $$
     56$codep */
     57        private:
    5958        const bool hyperbolic_; // is this hyperbolic tangent
    60 public:
    61         // ----------------------------------------------------------------------
     59        public:
    6260        // constructor
    6361        atomic_tangent(const char* name, bool hyperbolic)
     
    6563        hyperbolic_(hyperbolic)
    6664        { }
    67 private:
    68         // ----------------------------------------------------------------------
     65        private:
     66/* $$
     67$head forward$$
     68$codep */
    6969        // forward mode routine called by CppAD
    7070        bool forward(
     
    121121                return true;
    122122        }
    123         // ----------------------------------------------------------------------
     123/* $$
     124$head reverse$$
     125$codep */
    124126        // reverse mode routine called by CppAD
    125127        virtual bool reverse(
     
    175177                return true;
    176178        }
    177         // ----------------------------------------------------------------------
     179/* $$
     180$head for_sparse_jac$$
     181$codep */
    178182        // forward Jacobian sparsity routine called by CppAD
    179183        virtual bool for_sparse_jac(
     
    210214                return true;
    211215        }
    212         // ----------------------------------------------------------------------
     216/* $$
     217$head rev_sparse_jac$$
     218$codep */
    213219        // reverse Jacobian sparsity routine called by CppAD
    214220        virtual bool rev_sparse_jac(
     
    241247                return true;
    242248        }
    243         // ----------------------------------------------------------------------
     249/* $$
     250$head rev_sparse_hes$$
     251$codep */
    244252        // reverse Hessian sparsity routine called by CppAD
    245253        virtual bool rev_sparse_hes(
     
    323331                return true;
    324332        }
     333/* $$
     334$head End Class Definition$$
     335$codep */
    325336}; // End of atomic_tangent class
    326337}  // End empty namespace
    327338
     339/* $$
     340$head Use Atomic Function$$
     341$codep */
    328342bool tangent(void)
    329343{       bool ok = true;
     
    481495        return ok;
    482496}
    483 // END C++
     497/* $$
     498$$ $comment end nospell$$
     499$end
     500*/
  • trunk/omh/whats_new/whats_new_13.omh

    r2901 r2903  
    5353assist you in learning about changes between various versions of CppAD.
    5454
     55$head 09-19$$
     56Add links from the $cref atomic_base$$ functions documentation
     57to the corresponding examples.
     58This required adding headings in the examples that
     59correspond to the function documentation sections.
     60For example; see
     61$cref/atomic forward examples/atomic_forward/Examples/$$.
     62
    5563$head 09-18$$
    5664$list number$$
Note: See TracChangeset for help on using the changeset viewer.