source: branches/cache/cppad/local/print_op.hpp @ 3324

Last change on this file since 3324 was 3324, checked in by bradbell, 6 years ago

merge trunk changes into cache

  • Property svn:keywords set to Id
File size: 3.7 KB
Line 
1/* $Id: print_op.hpp 3324 2014-09-12 12:14:53Z bradbell $ */
2# ifndef CPPAD_PRINT_OP_INCLUDED
3# define CPPAD_PRINT_OP_INCLUDED
4
5/* --------------------------------------------------------------------------
6CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell
7
8CppAD is distributed under multiple licenses. This distribution is under
9the terms of the
10                    Eclipse Public License Version 1.0.
11
12A copy of this license is included in the COPYING file of this distribution.
13Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
14-------------------------------------------------------------------------- */
15
16
17namespace CppAD { // BEGIN_CPPAD_NAMESPACE
18/*!
19Print operation for parameters; i.e., op = PriOp.
20
21The C++ source code corresponding to this operation is
22\verbatim
23        f.Forward(0, x)
24        PrintFor(before, var)
25        PrintFor(pos, before, var, after)
26\endverbatim
27The PrintFor call puts the print operation on the tape
28and the print occurs during the zero order forward mode computation.
29
30\tparam Base
31base type for the operator; i.e., this operation was recorded
32using AD< \a Base > and computations by this routine are done using type
33\a Base .
34
35\param s_out
36the results are printed on this output stream.
37
38\param arg
39\a arg[0] & 1
40\n
41If this is zero, \a pos is a parameter. Otherwise it is a variable.
42\n
43\a arg[0] & 2
44\n
45If this is zero, \a var is a parameter. Otherwise it is a variable.
46\n
47\n
48\a arg[1]
49\n
50If \a pos is a parameter, <code>parameter[arg[1]]</code> is its value.
51Othwise <code>taylor[ arg[1] * cap_order + 0 ]</code> is the zero
52order Taylor coefficient for \a pos.
53\n
54\n
55\a arg[2]
56\n
57index of the text to be printed before \a var
58if \a pos is not a positive value.
59\n
60\n
61\a arg[3]
62\n
63If \a var is a parameter, <code>parameter[arg[3]]</code> is its value.
64Othwise <code>taylor[ arg[3] * cap_order + 0 ]</code> is the zero
65order Taylor coefficient for \a var.
66\n
67\n
68\a arg[4]
69\n
70index of the text to be printed after \a var
71if \a pos is not a positive value.
72
73\param num_text
74is the total number of text characters on the tape
75(only used for error checking).
76
77\param text
78\b Input: <code>text[arg[1]]</code> is the first character of the text
79that will be printed. All the characters from there to (but not including)
80the first '\\0' are printed.
81
82\param num_par
83is the total number of values in the \a parameter vector
84
85\param parameter
86Contains the value of parameters.
87
88\param cap_order
89number of colums in the matrix containing all the Taylor coefficients.
90
91\param taylor
92Contains the value of variables.
93
94\par Checked Assertions:
95\li NumArg(PriOp)  == 5
96\li NumRes(PriOp)  == 0
97\li text          !=  CPPAD_NULL
98\li arg[1]         <  num_text
99\li if \a pos is a parameter, arg[1] < num_par
100\li if \a var is a parameter, arg[3] < num_par
101*/
102template <class Base>
103inline void forward_pri_0(
104        std::ostream& s_out       ,
105        const addr_t* arg         ,
106        size_t        num_text    ,
107        const char*   text        ,
108        size_t        num_par     ,
109        const Base*   parameter   ,
110        size_t        cap_order   ,
111        const Base*   taylor      )
112{       Base pos, var;
113        const char* before;
114        const char* after;
115        CPPAD_ASSERT_NARG_NRES(PriOp, 5, 0);
116
117        // pos
118        if( arg[0] & 1 )
119        {       pos = taylor[ arg[1] * cap_order + 0 ];
120        }
121        else
122        {       CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < num_par );
123                pos = parameter[ arg[1] ];
124        }
125
126        // before
127        CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < num_text );
128        before = text + arg[2];
129
130        // var
131        if( arg[0] & 2 )
132        {       var = taylor[ arg[3] * cap_order + 0 ];
133        }
134        else
135        {       CPPAD_ASSERT_UNKNOWN( size_t(arg[3]) < num_par );
136                var = parameter[ arg[3] ];
137        }
138
139        // after
140        CPPAD_ASSERT_UNKNOWN( size_t(arg[4]) < num_text );
141        after = text + arg[4];
142
143        if( ! GreaterThanZero( pos ) )
144                s_out << before << var << after;
145}
146
147} // END_CPPAD_NAMESPACE
148# endif
Note: See TracBrowser for help on using the repository browser.