New upstream version 2017.00.00.3
Barak A. Pearlmutter
7 years ago
15 | 15 | CMAKE_MINIMUM_REQUIRED(VERSION 2.8) |
16 | 16 | |
17 | 17 | # cppad_version is used by set_version.sh to get the version number. |
18 | SET(cppad_version "20170000.2" ) | |
18 | SET(cppad_version "20170000.3" ) | |
19 | 19 | SET(cppad_url "http://www.coin-or.org/CppAD" ) |
20 | 20 | SET(cppad_description "Differentiation of C++ Algorithms" ) |
21 | 21 |
0 | 0 | #! /bin/sh |
1 | 1 | # Guess values for system-dependent variables and create Makefiles. |
2 | # Generated by GNU Autoconf 2.69 for cppad 20170000.2. | |
2 | # Generated by GNU Autoconf 2.69 for cppad 20170000.3. | |
3 | 3 | # |
4 | 4 | # Report bugs to <cppad@list.coin-or.org>. |
5 | 5 | # |
579 | 579 | # Identity of this package. |
580 | 580 | PACKAGE_NAME='cppad' |
581 | 581 | PACKAGE_TARNAME='cppad' |
582 | PACKAGE_VERSION='20170000.2' | |
583 | PACKAGE_STRING='cppad 20170000.2' | |
582 | PACKAGE_VERSION='20170000.3' | |
583 | PACKAGE_STRING='cppad 20170000.3' | |
584 | 584 | PACKAGE_BUGREPORT='cppad@list.coin-or.org' |
585 | 585 | PACKAGE_URL='' |
586 | 586 | |
1408 | 1408 | # Omit some internal or obsolete options to make the list less imposing. |
1409 | 1409 | # This message is too long to be a string in the A/UX 3.1 sh. |
1410 | 1410 | cat <<_ACEOF |
1411 | \`configure' configures cppad 20170000.2 to adapt to many kinds of systems. | |
1411 | \`configure' configures cppad 20170000.3 to adapt to many kinds of systems. | |
1412 | 1412 | |
1413 | 1413 | Usage: $0 [OPTION]... [VAR=VALUE]... |
1414 | 1414 | |
1478 | 1478 | |
1479 | 1479 | if test -n "$ac_init_help"; then |
1480 | 1480 | case $ac_init_help in |
1481 | short | recursive ) echo "Configuration of cppad 20170000.2:";; | |
1481 | short | recursive ) echo "Configuration of cppad 20170000.3:";; | |
1482 | 1482 | esac |
1483 | 1483 | cat <<\_ACEOF |
1484 | 1484 | |
1612 | 1612 | test -n "$ac_init_help" && exit $ac_status |
1613 | 1613 | if $ac_init_version; then |
1614 | 1614 | cat <<\_ACEOF |
1615 | cppad configure 20170000.2 | |
1615 | cppad configure 20170000.3 | |
1616 | 1616 | generated by GNU Autoconf 2.69 |
1617 | 1617 | |
1618 | 1618 | Copyright (C) 2012 Free Software Foundation, Inc. |
2241 | 2241 | This file contains any messages produced by compilers while |
2242 | 2242 | running configure, to aid debugging if configure makes a mistake. |
2243 | 2243 | |
2244 | It was created by cppad $as_me 20170000.2, which was | |
2244 | It was created by cppad $as_me 20170000.3, which was | |
2245 | 2245 | generated by GNU Autoconf 2.69. Invocation command line was |
2246 | 2246 | |
2247 | 2247 | $ $0 $@ |
3131 | 3131 | |
3132 | 3132 | # Define the identity of the package. |
3133 | 3133 | PACKAGE='cppad' |
3134 | VERSION='20170000.2' | |
3134 | VERSION='20170000.3' | |
3135 | 3135 | |
3136 | 3136 | |
3137 | 3137 | cat >>confdefs.h <<_ACEOF |
8571 | 8571 | # report actual input values of CONFIG_FILES etc. instead of their |
8572 | 8572 | # values after options handling. |
8573 | 8573 | ac_log=" |
8574 | This file was extended by cppad $as_me 20170000.2, which was | |
8574 | This file was extended by cppad $as_me 20170000.3, which was | |
8575 | 8575 | generated by GNU Autoconf 2.69. Invocation command line was |
8576 | 8576 | |
8577 | 8577 | CONFIG_FILES = $CONFIG_FILES |
8628 | 8628 | cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 |
8629 | 8629 | ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" |
8630 | 8630 | ac_cs_version="\\ |
8631 | cppad config.status 20170000.2 | |
8631 | cppad config.status 20170000.3 | |
8632 | 8632 | configured by $0, generated by GNU Autoconf 2.69, |
8633 | 8633 | with options \\"\$ac_cs_config\\" |
8634 | 8634 |
10 | 10 | dnl |
11 | 11 | dnl Process this file with autoconf to produce a configure script. |
12 | 12 | dnl package version bug-report |
13 | AC_INIT([cppad], [20170000.2], [cppad@list.coin-or.org]) | |
13 | AC_INIT([cppad], [20170000.3], [cppad@list.coin-or.org]) | |
14 | 14 | AM_SILENT_RULES([yes]) |
15 | 15 | |
16 | 16 | dnl By defalut disable maintainer mode when running configure; |
0 | # ifndef CPPAD_LOCAL_OPTIMIZE_CEXP_INFO_HPP | |
1 | # define CPPAD_LOCAL_OPTIMIZE_CEXP_INFO_HPP | |
2 | /* -------------------------------------------------------------------------- | |
3 | CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell | |
4 | ||
5 | CppAD is distributed under multiple licenses. This distribution is under | |
6 | the terms of the | |
7 | GNU General Public License Version 3. | |
8 | ||
9 | A copy of this license is included in the COPYING file of this distribution. | |
10 | Please visit http://www.coin-or.org/CppAD/ for information on other licenses. | |
11 | -------------------------------------------------------------------------- */ | |
12 | # include <cppad/local/declare_ad.hpp> // defines CompareOp | |
13 | # include <cppad/utility/vector.hpp> | |
14 | ||
15 | /*! | |
16 | \file cexp_info.hpp | |
17 | Information about one conditional expression. | |
18 | */ | |
19 | ||
20 | // BEGIN_CPPAD_LOCAL_OPTIMIZE_NAMESPACE | |
21 | namespace CppAD { namespace local { namespace optimize { | |
22 | /*! | |
23 | Information about one conditional expression. | |
24 | */ | |
25 | struct struct_cexp_info { | |
26 | /// The operator index for this conditional expression operation | |
27 | size_t i_op; | |
28 | ||
29 | /// (flag & 1) is true if and only if left is a variable | |
30 | /// (flag & 2) is true if and only if right is a variable | |
31 | size_t flag; | |
32 | ||
33 | /// variable or parameter index for left comparison operand | |
34 | size_t left; | |
35 | ||
36 | /// variable or parameter index for right comparison operand | |
37 | size_t right; | |
38 | ||
39 | /// maximum variable index between left and right (ignoring parameters). | |
40 | size_t max_left_right; | |
41 | ||
42 | /// set of operator that are not used when comparison result is true | |
43 | /// Note that UsrapOp, UsravOp, UsrrpOp, and UsrrvOp, are not in this | |
44 | /// vector and should be skipped when the corresponding UserOp are skipped. | |
45 | CppAD::vector<size_t> skip_op_true; | |
46 | ||
47 | /// set of variables that are not used when comparison result is false | |
48 | /// Note that UsrapOp, UsravOp, UsrrpOp, and UsrrvOp, are not in this | |
49 | /// vector and should be skipped when the corresponding UserOp are skipped. | |
50 | CppAD::vector<size_t> skip_op_false; | |
51 | ||
52 | /// comparision operator for this conditional expression | |
53 | CompareOp cop; | |
54 | }; | |
55 | ||
56 | // Information about the conditional skip in the new operation sequence | |
57 | struct struct_cskip_new { | |
58 | /// new variable or parameter index for left comparison operand | |
59 | size_t left; | |
60 | /// new variable or parameter index for right comparison operand | |
61 | size_t right; | |
62 | /// maximum variable index between left and right (ignoring parameters). | |
63 | size_t max_left_right; | |
64 | /// index where this conditional skips arguments start | |
65 | size_t i_arg; | |
66 | }; | |
67 | ||
68 | } } } // END_CPPAD_LOCAL_OPTIMIZE_NAMESPACE | |
69 | ||
70 | # endif |
0 | // $Id$ | |
1 | # ifndef CPPAD_LOCAL_OPTIMIZE_CSKIP_INFO_HPP | |
2 | # define CPPAD_LOCAL_OPTIMIZE_CSKIP_INFO_HPP | |
3 | /* -------------------------------------------------------------------------- | |
4 | CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell | |
5 | ||
6 | CppAD is distributed under multiple licenses. This distribution is under | |
7 | the terms of the | |
8 | GNU General Public License Version 3. | |
9 | ||
10 | A copy of this license is included in the COPYING file of this distribution. | |
11 | Please visit http://www.coin-or.org/CppAD/ for information on other licenses. | |
12 | -------------------------------------------------------------------------- */ | |
13 | # include <cppad/local/declare_ad.hpp> // defines CompareOp | |
14 | # include <cppad/utility/vector.hpp> | |
15 | ||
16 | /*! | |
17 | \file cskip_info.hpp | |
18 | Information about one conditional expression. | |
19 | */ | |
20 | ||
21 | // BEGIN_CPPAD_LOCAL_OPTIMIZE_NAMESPACE | |
22 | namespace CppAD { namespace local { namespace optimize { | |
23 | /*! | |
24 | Information about one conditional expression. | |
25 | */ | |
26 | struct struct_cskip_info { | |
27 | /// The operator index for this conditional expression operation | |
28 | size_t i_op; | |
29 | ||
30 | /// (flag & 1) is true if and only if left is a variable | |
31 | /// (flag & 2) is true if and only if right is a variable | |
32 | size_t flag; | |
33 | ||
34 | /// variable or parameter index for left comparison operand | |
35 | size_t left; | |
36 | ||
37 | /// variable or parameter index for right comparison operand | |
38 | size_t right; | |
39 | ||
40 | /// maximum variable index between left and right (ignoring parameters). | |
41 | size_t max_left_right; | |
42 | ||
43 | /// set of operator that are not used when comparison result is true | |
44 | /// Note that UsrapOp, UsravOp, UsrrpOp, and UsrrvOp, are not in this | |
45 | /// vector and should be skipped when the corresponding UserOp are skipped. | |
46 | CppAD::vector<size_t> skip_op_true; | |
47 | ||
48 | /// set of variables that are not used when comparison result is false | |
49 | /// Note that UsrapOp, UsravOp, UsrrpOp, and UsrrvOp, are not in this | |
50 | /// vector and should be skipped when the corresponding UserOp are skipped. | |
51 | CppAD::vector<size_t> skip_op_false; | |
52 | ||
53 | /// comparision operator for this conditional expression | |
54 | CompareOp cop; | |
55 | }; | |
56 | ||
57 | // Information about the conditional skip in the new operation sequence | |
58 | struct struct_cskip_new { | |
59 | /// new variable or parameter index for left comparison operand | |
60 | size_t left; | |
61 | /// new variable or parameter index for right comparison operand | |
62 | size_t right; | |
63 | /// maximum variable index between left and right (ignoring parameters). | |
64 | size_t max_left_right; | |
65 | /// index where this conditional skips arguments start | |
66 | size_t i_arg; | |
67 | }; | |
68 | ||
69 | } } } // END_CPPAD_LOCAL_OPTIMIZE_NAMESPACE | |
70 | ||
71 | # endif |
0 | // $Id$ | |
1 | 0 | # ifndef CPPAD_LOCAL_OPTIMIZE_GET_OP_INFO_HPP |
2 | 1 | # define CPPAD_LOCAL_OPTIMIZE_GET_OP_INFO_HPP |
3 | 2 | |
4 | 3 | /* -------------------------------------------------------------------------- |
5 | CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell | |
4 | CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell | |
6 | 5 | |
7 | 6 | CppAD is distributed under multiple licenses. This distribution is under |
8 | 7 | the terms of the |
18 | 17 | |
19 | 18 | # include <cppad/local/optimize/op_info.hpp> |
20 | 19 | # include <cppad/local/optimize/match_op.hpp> |
21 | # include <cppad/local/optimize/cskip_info.hpp> | |
20 | # include <cppad/local/optimize/cexp_info.hpp> | |
22 | 21 | # include <cppad/local/optimize/usage.hpp> |
23 | 22 | |
24 | 23 | // BEGIN_CPPAD_LOCAL_OPTIMIZE_NAMESPACE |
123 | 122 | \a Base. |
124 | 123 | |
125 | 124 | \param conditional_skip |
126 | If conditional_skip this is true, the conditional skip information | |
127 | cskip_info will be calculated. | |
125 | If conditional_skip this is true, the conditional expression information | |
126 | cexp_info will be calculated. | |
128 | 127 | This may be time intensive and may not have much benefit in the optimized |
129 | 128 | recording. |
130 | 129 | |
156 | 155 | If the index i_var corresponds to an auxillary variable, var2op[i_var] |
157 | 156 | is equalt to num_op (which is not a valid operator index). |
158 | 157 | |
159 | \param cskip_info | |
158 | \param cexp_info | |
160 | 159 | The input size of this vector must be zero. |
161 | If conditional_skip is false, cskip_info is not changed. | |
160 | If conditional_skip is false, cexp_info is not changed. | |
162 | 161 | Otherwise, |
163 | upon return cskip_info has size equal to the number of conditional expressions | |
162 | upon return cexp_info has size equal to the number of conditional expressions | |
164 | 163 | in the operation sequence; i.e., the number of CExpOp operators. |
165 | The value cskip_info[j] is the information corresponding to the j-th | |
164 | The value cexp_info[j] is the information corresponding to the j-th | |
166 | 165 | conditional expression in the operation sequence. |
167 | 166 | This vector is in the same order as the operation sequence; i.e. |
168 | if j1 > j2, cskip_info[j1].i_op > cskip_info[j2].i_op. | |
167 | if j1 > j2, cexp_info[j1].i_op > cexp_info[j2].i_op. | |
169 | 168 | |
170 | 169 | \param vecad_used |
171 | 170 | The input size of this vector must be zero. |
191 | 190 | player<Base>* play , |
192 | 191 | const vector<size_t>& dep_taddr , |
193 | 192 | vector<addr_t>& var2op , |
194 | vector<struct_cskip_info>& cskip_info , | |
193 | vector<struct_cexp_info>& cexp_info , | |
195 | 194 | vector<bool>& vecad_used , |
196 | 195 | vector<struct_op_info>& op_info ) |
197 | 196 | { |
198 | 197 | CPPAD_ASSERT_UNKNOWN( var2op.size() == 0 ); |
199 | CPPAD_ASSERT_UNKNOWN( cskip_info.size() == 0 ); | |
198 | CPPAD_ASSERT_UNKNOWN( cexp_info.size() == 0 ); | |
200 | 199 | CPPAD_ASSERT_UNKNOWN( vecad_used.size() == 0 ); |
201 | 200 | CPPAD_ASSERT_UNKNOWN( op_info.size() == 0 ); |
202 | 201 | |
983 | 982 | } |
984 | 983 | } |
985 | 984 | // ---------------------------------------------------------------------- |
986 | // compute cskip_info | |
985 | // compute cexp_info | |
987 | 986 | // ---------------------------------------------------------------------- |
988 | 987 | if( cexp_set.n_set() == 0 ) |
989 | 988 | return; |
990 | 989 | // |
991 | 990 | // initialize information for each conditional expression |
992 | cskip_info.resize(num_cexp_op); | |
991 | cexp_info.resize(num_cexp_op); | |
993 | 992 | for(size_t i = 0; i < num_cexp_op; i++) |
994 | 993 | { CPPAD_ASSERT_UNKNOWN( |
995 | 994 | op_info[i].previous == 0 || op_info[i].usage == yes_usage |
998 | 997 | arg = op_info[i_op].arg; |
999 | 998 | CPPAD_ASSERT_UNKNOWN( op_info[i_op].op == CExpOp ); |
1000 | 999 | // |
1001 | struct_cskip_info info; | |
1000 | struct_cexp_info info; | |
1002 | 1001 | info.i_op = i_op; |
1003 | 1002 | info.cop = CompareOp( arg[0] ); |
1004 | 1003 | info.flag = arg[1]; |
1014 | 1013 | CPPAD_ASSERT_UNKNOWN( index > 0 ); |
1015 | 1014 | info.max_left_right = index; |
1016 | 1015 | // |
1017 | cskip_info[i] = info; | |
1016 | cexp_info[i] = info; | |
1018 | 1017 | }; |
1019 | 1018 | // Determine which operators can be conditionally skipped |
1020 | 1019 | i_op = 0; |
1050 | 1049 | size_t index = element / 2; |
1051 | 1050 | bool compare = bool( element % 2 ); |
1052 | 1051 | if( compare == false ) |
1053 | { cskip_info[index].skip_op_false.push_back(i_op); | |
1052 | { cexp_info[index].skip_op_false.push_back(i_op); | |
1054 | 1053 | if( j_op != i_op ) |
1055 | cskip_info[index].skip_op_false.push_back(j_op); | |
1054 | cexp_info[index].skip_op_false.push_back(j_op); | |
1056 | 1055 | } |
1057 | 1056 | else |
1058 | { cskip_info[index].skip_op_true.push_back(i_op); | |
1057 | { cexp_info[index].skip_op_true.push_back(i_op); | |
1059 | 1058 | if( j_op != i_op ) |
1060 | cskip_info[index].skip_op_true.push_back(j_op); | |
1059 | cexp_info[index].skip_op_true.push_back(j_op); | |
1061 | 1060 | } |
1062 | 1061 | ++itr; |
1063 | 1062 | } |
0 | // $Id$ | |
1 | 0 | |
2 | 1 | # ifndef CPPAD_LOCAL_OPTIMIZE_OPTIMIZE_RUN_HPP |
3 | 2 | # define CPPAD_LOCAL_OPTIMIZE_OPTIMIZE_RUN_HPP |
4 | 3 | |
5 | 4 | /* -------------------------------------------------------------------------- |
6 | CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell | |
5 | CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell | |
7 | 6 | |
8 | 7 | CppAD is distributed under multiple licenses. This distribution is under |
9 | 8 | the terms of the |
21 | 20 | # include <cppad/local/optimize/size_pair.hpp> |
22 | 21 | # include <cppad/local/optimize/csum_variable.hpp> |
23 | 22 | # include <cppad/local/optimize/csum_stacks.hpp> |
24 | # include <cppad/local/optimize/cskip_info.hpp> | |
23 | # include <cppad/local/optimize/cexp_info.hpp> | |
25 | 24 | # include <cppad/local/optimize/match_op.hpp> |
26 | 25 | # include <cppad/local/optimize/record_pv.hpp> |
27 | 26 | # include <cppad/local/optimize/record_vp.hpp> |
130 | 129 | |
131 | 130 | // operator information |
132 | 131 | vector<addr_t> var2op; |
133 | vector<struct_cskip_info> cskip_info; | |
132 | vector<struct_cexp_info> cexp_info; | |
134 | 133 | vector<bool> vecad_used; |
135 | 134 | vector<struct_op_info> op_info; |
136 | 135 | get_op_info( |
140 | 139 | play, |
141 | 140 | dep_taddr, |
142 | 141 | var2op, |
143 | cskip_info, | |
142 | cexp_info, | |
144 | 143 | vecad_used, |
145 | 144 | op_info |
146 | 145 | ); |
157 | 156 | |
158 | 157 | enum_user_state user_state; |
159 | 158 | // ------------------------------------------------------------- |
160 | // conditional skip information | |
159 | // conditional expression information | |
161 | 160 | // |
162 | // size of the conditional cskip information structure | |
163 | // (This is equal to the number of conditional expressions when | |
164 | // conditional_skip is true.) | |
165 | size_t num_cskip = cskip_info.size(); | |
166 | CPPAD_ASSERT_UNKNOWN( conditional_skip || num_cskip == 0 ); | |
167 | ||
168 | // sort the conditional skip information by max_left_right | |
169 | vector<size_t> cskip_info_order(num_cskip); | |
170 | if( num_cskip > 0 ) | |
171 | { CppAD::vector<size_t> keys(num_cskip); | |
172 | for(size_t i = 0; i < num_cskip; i++) | |
173 | keys[i] = cskip_info[i].max_left_right; | |
174 | CppAD::index_sort(keys, cskip_info_order); | |
161 | // Size of the conditional expression information structure. | |
162 | // This is equal to the number of conditional expressions when | |
163 | // conditional_skip is true, otherwise it is zero. | |
164 | size_t num_cexp = cexp_info.size(); | |
165 | CPPAD_ASSERT_UNKNOWN( conditional_skip || num_cexp == 0 ); | |
166 | // | |
167 | // sort the conditional expression information by max_left_right | |
168 | // this is the conditional skip order | |
169 | vector<size_t> cskip_order(num_cexp); | |
170 | if( num_cexp > 0 ) | |
171 | { CppAD::vector<size_t> keys(num_cexp); | |
172 | for(size_t i = 0; i < num_cexp; i++) | |
173 | keys[i] = cexp_info[i].max_left_right; | |
174 | CppAD::index_sort(keys, cskip_order); | |
175 | 175 | } |
176 | ||
177 | // index in sorted order | |
176 | // initial index in conditional skip order | |
178 | 177 | size_t cskip_order_next = 0; |
179 | ||
180 | // index in order during reverse sweep | |
181 | size_t cskip_info_index = num_cskip; | |
182 | vector<struct_cskip_new> cskip_new(num_cskip); | |
183 | // flag used to indicate that this conditional expression is skipped | |
184 | for(size_t i = 0; i < num_cskip; i++) | |
178 | // | |
179 | // initialize index in conditional expression order | |
180 | size_t cexp_next = 0; | |
181 | ||
182 | // mapping from conditional expression index to conditional skip | |
183 | // information on new tape | |
184 | vector<struct_cskip_new> cskip_new(num_cexp); | |
185 | // | |
186 | // flag used to indicate that there is no conditional skip | |
187 | // for this conditional expression | |
188 | for(size_t i = 0; i < num_cexp; i++) | |
185 | 189 | cskip_new[i].i_arg = 0; |
186 | 190 | // ------------------------------------------------------------- |
187 | 191 | |
244 | 248 | // |
245 | 249 | // determine if we should insert a conditional skip here |
246 | 250 | bool skip = conditional_skip; |
247 | skip &= cskip_order_next < num_cskip; | |
251 | skip &= cskip_order_next < num_cexp; | |
248 | 252 | skip &= op != BeginOp; |
249 | 253 | skip &= op != InvOp; |
250 | 254 | skip &= user_state == start_user; |
251 | 255 | if( skip ) |
252 | { size_t j = cskip_info_order[cskip_order_next]; | |
256 | { size_t j = cskip_order[cskip_order_next]; | |
253 | 257 | if( NumRes(op) > 0 ) |
254 | skip &= cskip_info[j].max_left_right < i_var; | |
255 | else | |
256 | skip &= cskip_info[j].max_left_right <= i_var; | |
258 | skip &= cexp_info[j].max_left_right < i_var; | |
259 | else | |
260 | skip &= cexp_info[j].max_left_right <= i_var; | |
257 | 261 | } |
258 | 262 | if( skip ) |
259 | { size_t j = cskip_info_order[cskip_order_next]; | |
263 | { size_t j = cskip_order[cskip_order_next]; | |
260 | 264 | cskip_order_next++; |
261 | struct_cskip_info info = cskip_info[j]; | |
265 | struct_cexp_info info = cexp_info[j]; | |
262 | 266 | size_t n_true = info.skip_op_true.size(); |
263 | 267 | size_t n_false = info.skip_op_false.size(); |
264 | 268 | skip &= n_true > 0 || n_false > 0; |
285 | 289 | } |
286 | 290 | size_t previous; |
287 | 291 | // |
288 | if( op_info[i_op].usage == yes_usage ) switch( op ) | |
292 | if( op_info[i_op].usage != yes_usage ) | |
293 | { if( op == CExpOp ) | |
294 | ++cexp_next; | |
295 | } | |
296 | else switch( op ) | |
289 | 297 | { |
290 | 298 | case BeginOp: |
291 | 299 | CPPAD_ASSERT_NARG_NRES(op, 1, 1); |
557 | 565 | // fill in the arguments for the CSkip operations. This does not |
558 | 566 | // affect max_left_right which is used during this sweep. |
559 | 567 | if( conditional_skip ) |
560 | { CPPAD_ASSERT_UNKNOWN( cskip_info_index > 0 ); | |
561 | cskip_info_index--; | |
562 | cskip_new[ cskip_info_index ].left = new_arg[2]; | |
563 | cskip_new[ cskip_info_index ].right = new_arg[3]; | |
568 | { CPPAD_ASSERT_UNKNOWN( cexp_next < num_cexp ); | |
569 | CPPAD_ASSERT_UNKNOWN( cexp_info[cexp_next].i_op == i_op ); | |
570 | cskip_new[ cexp_next ].left = new_arg[2]; | |
571 | cskip_new[ cexp_next ].right = new_arg[3]; | |
572 | ++cexp_next; | |
564 | 573 | } |
565 | 574 | break; |
566 | 575 | // --------------------------------------------------- |
842 | 851 | # endif |
843 | 852 | // make sure that all the conditional expressions have been |
844 | 853 | // checked to see if they are still present |
845 | CPPAD_ASSERT_UNKNOWN( cskip_order_next == num_cskip ); | |
854 | CPPAD_ASSERT_UNKNOWN( cskip_order_next == num_cexp ); | |
846 | 855 | // fill in the arguments for the CSkip operations |
847 | for(size_t i = 0; i < num_cskip; i++) | |
856 | for(size_t i = 0; i < num_cexp; i++) | |
848 | 857 | { // if cskip_new[i].i_arg == 0, this conditional expression was skipped |
849 | 858 | if( cskip_new[i].i_arg > 0 ) |
850 | { struct_cskip_info info = cskip_info[i]; | |
859 | { struct_cexp_info info = cexp_info[i]; | |
851 | 860 | size_t n_true = info.skip_op_true.size(); |
852 | 861 | size_t n_false = info.skip_op_false.size(); |
853 | 862 | size_t i_arg = cskip_new[i].i_arg; |
863 | size_t left = cskip_new[i].left; | |
864 | size_t right = cskip_new[i].right; | |
854 | 865 | rec->ReplaceArg(i_arg++, info.cop ); |
855 | 866 | rec->ReplaceArg(i_arg++, info.flag ); |
856 | rec->ReplaceArg(i_arg++, info.left ); | |
857 | rec->ReplaceArg(i_arg++, info.right ); | |
867 | rec->ReplaceArg(i_arg++, left ); | |
868 | rec->ReplaceArg(i_arg++, right ); | |
858 | 869 | rec->ReplaceArg(i_arg++, n_true ); |
859 | 870 | rec->ReplaceArg(i_arg++, n_false ); |
860 | 871 | for(size_t j = 0; j < info.skip_op_true.size(); j++) |
861 | { i_op = cskip_info[i].skip_op_true[j]; | |
872 | { i_op = cexp_info[i].skip_op_true[j]; | |
862 | 873 | // op_info[i_op].usage == yes_usage |
863 | 874 | CPPAD_ASSERT_UNKNOWN( old2new[i_op].new_op != 0 ); |
864 | 875 | rec->ReplaceArg(i_arg++, old2new[i_op].new_op ); |
865 | 876 | } |
866 | 877 | for(size_t j = 0; j < info.skip_op_false.size(); j++) |
867 | { i_op = cskip_info[i].skip_op_false[j]; | |
878 | { i_op = cexp_info[i].skip_op_false[j]; | |
868 | 879 | // op_info[i_op].usage == yes_usage |
869 | 880 | CPPAD_ASSERT_UNKNOWN( old2new[i_op].new_op != 0 ); |
870 | 881 | rec->ReplaceArg(i_arg++, old2new[i_op].new_op ); |
0 | // $Id: sparse_list.hpp 3853 2016-12-14 14:40:11Z bradbell $ | |
1 | 0 | # ifndef CPPAD_LOCAL_SPARSE_LIST_HPP |
2 | 1 | # define CPPAD_LOCAL_SPARSE_LIST_HPP |
3 | 2 | |
4 | 3 | /* -------------------------------------------------------------------------- |
5 | CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell | |
4 | CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell | |
6 | 5 | |
7 | 6 | CppAD is distributed under multiple licenses. This distribution is under |
8 | 7 | the terms of the |
484 | 483 | // |
485 | 484 | CPPAD_ASSERT_UNKNOWN( reference_count(index) == 1 ); |
486 | 485 | size_t previous = start_[index]; |
487 | size_t next = data_[start].next; | |
486 | size_t next = data_[previous].next; | |
488 | 487 | size_t value = data_[next].value; |
489 | 488 | CPPAD_ASSERT_UNKNOWN( value < end_ ); |
490 | 489 | while( value < element ) |
63 | 63 | onmouseover='MouseOver(1)' |
64 | 64 | onmouseout='MouseOut(1)' |
65 | 65 | ><img src='_close.gif' name='folder1' align='middle' /> |
66 | <u>cppad-20170000.2: A Package for Differentiation of C++ Algorithms</u></a> | |
66 | <u>cppad-20170000.3: A Package for Differentiation of C++ Algorithms</u></a> | |
67 | 67 | |
68 | 68 | <span id='children1'> |
69 | <br/><a href="cppad.xml" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms</a> | |
69 | <br/><a href="cppad.xml" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms</a> | |
70 | 70 | |
71 | 71 | <br/>    <a href="_contents_xml.htm" target="_top">Table of Contents</a> |
72 | 72 |
171 | 171 | |
172 | 172 | <tr valign="top"><td><a href="http://www.coin-or.org/download/source/CppAD/" target="_top">http://www.coin-or.org/download/source/CppAD/</a></td><td><a href="whats_new_09.xml#06-25" target="_top">whats_new_09#06-25</a></td></tr> |
173 | 173 | |
174 | <tr valign="top"><td><a href="http://www.coin-or.org/download/source/CppAD/cppad-20170000.2.epl.tgz" target="_top">http://www.coin-or.org/download/source/CppAD/cppad-20170000.2.epl.tgz</a></td><td><a href="download.xml#Current Version.Compressed Archives" target="_top">download#Current Version.Compressed Archives</a></td></tr> | |
175 | ||
176 | <tr valign="top"><td><a href="http://www.coin-or.org/download/source/CppAD/cppad-20170000.2.gpl.tgz" target="_top">http://www.coin-or.org/download/source/CppAD/cppad-20170000.2.gpl.tgz</a></td><td><a href="download.xml#Current Version.Compressed Archives" target="_top">download#Current Version.Compressed Archives</a></td></tr> | |
174 | <tr valign="top"><td><a href="http://www.coin-or.org/download/source/CppAD/cppad-20170000.3.epl.tgz" target="_top">http://www.coin-or.org/download/source/CppAD/cppad-20170000.3.epl.tgz</a></td><td><a href="download.xml#Current Version.Compressed Archives" target="_top">download#Current Version.Compressed Archives</a></td></tr> | |
175 | ||
176 | <tr valign="top"><td><a href="http://www.coin-or.org/download/source/CppAD/cppad-20170000.3.gpl.tgz" target="_top">http://www.coin-or.org/download/source/CppAD/cppad-20170000.3.gpl.tgz</a></td><td><a href="download.xml#Current Version.Compressed Archives" target="_top">download#Current Version.Compressed Archives</a></td></tr> | |
177 | 177 | |
178 | 178 | <tr valign="top"><td><a href="http://www.coin-or.org/foundation.html" target="_top">http://www.coin-or.org/foundation.html</a></td><td><a href="cppad.xml#Introduction" target="_top">CppAD#Introduction</a></td></tr> |
179 | 179 |
1182 | 1182 |    <a href="simple_ad_bthread.cpp.xml" target="_top">A Simple Boost Threading AD: Example and Test</a><br/> |
1183 | 1183 |    <a href="simple_ad_openmp.cpp.xml" target="_top">A Simple OpenMP AD: Example and Test</a><br/> |
1184 | 1184 |    <a href="introduction.xml" target="_top">An Introduction by Example to Algorithmic Differentiation</a><br/> |
1185 |    <a href="cppad.xml" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms</a><br/> | |
1185 |    <a href="cppad.xml" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms</a><br/> | |
1186 | 1186 | ADFun <a href="comparechange.xml" target="_top">Comparison Changes During Zero Order Forward Mode</a><br/> |
1187 | 1187 |       <a href="compare_change.xml" target="_top">Comparison Changes Between Taping and Zero Order Forward</a><br/> |
1188 | 1188 |       <a href="dependent.xml" target="_top">Stop Recording and Store Operation Sequence</a><br/> |
1436 | 1436 |           <a href="forsparsehes.xml#Algorithm" target="_top">Hessian Sparsity Pattern: Forward Mode: Algorithm</a><br/> |
1437 | 1437 |           <a href="exp_eps.xml" target="_top">An Epsilon Accurate Exponential Approximation</a><br/> |
1438 | 1438 |           <a href="exp_2.xml" target="_top">Second Order Exponential Approximation</a><br/> |
1439 |           <a href="cppad.xml" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms</a><br/> | |
1439 |           <a href="cppad.xml" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms</a><br/> | |
1440 | 1440 | algorithm<b>:</b> <a href="conj_grad.cpp.xml" target="_top">Differentiate Conjugate Gradient Algorithm: Example and Test</a><br/> |
1441 | 1441 | algorithmic <a href="ad_in_c.cpp.xml" target="_top">Example and Test Linking CppAD to Languages Other than C++</a><br/> |
1442 | 1442 |             <a href="introduction.xml#Preface.Algorithmic Differentiation" target="_top">An Introduction by Example to Algorithmic Differentiation: Preface.Algorithmic Differentiation</a><br/> |
1443 | 1443 |             <a href="introduction.xml" target="_top">An Introduction by Example to Algorithmic Differentiation</a><br/> |
1444 |             <a href="cppad.xml" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms</a><br/> | |
1445 | algorithms <a href="cppad.xml" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms</a><br/> | |
1444 |             <a href="cppad.xml" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms</a><br/> | |
1445 | algorithms <a href="cppad.xml" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms</a><br/> | |
1446 | 1446 | alignment <a href="ta_create_array.xml#Alignment" target="_top">Allocate An Array and Call Default Constructor for its Elements: Alignment</a><br/> |
1447 | 1447 |           <a href="ta_get_memory.xml#Alignment" target="_top">Get At Least A Specified Amount of Memory: Alignment</a><br/> |
1448 | 1448 | all <a href="listallexamples.xml" target="_top">List of All the CppAD Examples</a><br/> |
1693 | 1693 | atomic<b>_</b>user <a href="atomic_ctor.xml#atomic_user" target="_top">Atomic Function Constructor: atomic_user</a><br/> |
1694 | 1694 | auto <a href="auto_tools.xml" target="_top">Auto Tools Unix Test and Installation</a><br/> |
1695 | 1695 | automatic <a href="ad_in_c.cpp.xml" target="_top">Example and Test Linking CppAD to Languages Other than C++</a><br/> |
1696 |           <a href="cppad.xml" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms</a><br/> | |
1696 |           <a href="cppad.xml" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms</a><br/> | |
1697 | 1697 | available <a href="memory_leak.xml#available" target="_top">Memory Leak Detection: available</a><br/> |
1698 | 1698 |           <a href="omp_delete_array.xml" target="_top">Return A Raw Array to The Available Memory for a Thread</a><br/> |
1699 | 1699 |           <a href="omp_available.xml" target="_top">Amount of Memory Available for Quick Use by a Thread</a><br/> |
1840 | 1840 | C <a href="interface2c.cpp.xml" target="_top">Interfacing to C: Example and Test</a><br/> |
1841 | 1841 |   <a href="ad_in_c.cpp.xml" target="_top">Example and Test Linking CppAD to Languages Other than C++</a><br/> |
1842 | 1842 |      compare<b> </b>speed<b> </b>with<b> </b>C<b>++</b> <a href="compare_c.xml" target="_top">Compare Speed of C and C++</a><br/> |
1843 | C<b>++</b> <a href="cppad.xml" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms</a><br/> | |
1843 | C<b>++</b> <a href="cppad.xml" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms</a><br/> | |
1844 | 1844 |      compare<b> </b>speed<b> </b>with<b> </b>C <a href="compare_c.xml" target="_top">Compare Speed of C and C++</a><br/> |
1845 | 1845 | CheckNumericType <a href="checknumerictype.xml" target="_top">Check NumericType Class Concept</a><br/> |
1846 | 1846 | CheckSimpleVector <a href="checksimplevector.xml" target="_top">Check Simple Vector Concept</a><br/> |
1863 | 1863 | CppAD <a href="vector_bool.cpp.xml" target="_top">CppAD::vectorBool Class: Example and Test</a><br/> |
1864 | 1864 |       <a href="cppad_vector.cpp.xml" target="_top">CppAD::vector Template Class: Example and Test</a><br/> |
1865 | 1865 |       <a href="cppad_vector.xml" target="_top">The CppAD::vector Template Class</a><br/> |
1866 |       <a href="cppad.xml" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms</a><br/> | |
1866 |       <a href="cppad.xml" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms</a><br/> | |
1867 | 1867 | CppADTrackDelVec <a href="tracknewdel.xml" target="_top">Routines That Track Use of New and Delete</a><br/> |
1868 | 1868 | CppADTrackExtend <a href="tracknewdel.xml" target="_top">Routines That Track Use of New and Delete</a><br/> |
1869 | 1869 | CppADTrackNewVec <a href="tracknewdel.xml" target="_top">Routines That Track Use of New and Delete</a><br/> |
1878 | 1878 |     <a href="bib.xml#The C++ Programming Language" target="_top">Bibliography: The C++ Programming Language</a><br/> |
1879 | 1879 |     <a href="ad_in_c.cpp.xml" target="_top">Example and Test Linking CppAD to Languages Other than C++</a><br/> |
1880 | 1880 |     <a href="utility.xml#C++ Concepts" target="_top">Some General Purpose Utilities: C++ Concepts</a><br/> |
1881 |     <a href="cppad.xml" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms</a><br/> | |
1881 |     <a href="cppad.xml" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms</a><br/> | |
1882 | 1882 | c<b>++</b>11 <a href="cmake.xml#cppad_cxx_flags.C++11" target="_top">Using CMake to Configure CppAD: cppad_cxx_flags.C++11</a><br/> |
1883 | 1883 | c<b>:</b> <a href="interface2c.cpp.xml" target="_top">Interfacing to C: Example and Test</a><br/> |
1884 | 1884 | calculating <a href="sparse.xml" target="_top">Calculating Sparsity Patterns</a><br/> |
2363 | 2363 |       <a href="cmake.xml" target="_top">Using CMake to Configure CppAD</a><br/> |
2364 | 2364 |       <a href="download.xml" target="_top">Download The CppAD Source Code</a><br/> |
2365 | 2365 |       <a href="install.xml" target="_top">CppAD Download, Test, and Install Instructions</a><br/> |
2366 | cppad<b>-</b>20170000<b>.</b>2<b>:</b> <a href="cppad.xml" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms</a><br/> | |
2367 | cppad<b>.</b>hpp <a href="cppad.xml" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms</a><br/> | |
2366 | cppad<b>-</b>20170000<b>.</b>3<b>:</b> <a href="cppad.xml" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms</a><br/> | |
2367 | cppad<b>.</b>hpp <a href="cppad.xml" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms</a><br/> | |
2368 | 2368 | cppad<b>::</b>numeric<b>_</b>limits <a href="base_limits.xml#CppAD::numeric_limits" target="_top">Base Type Requirements for Numeric Limits: CppAD::numeric_limits</a><br/> |
2369 | 2369 |                       <a href="numeric_limits.xml#CppAD::numeric_limits" target="_top">Numeric Limits For an AD and Base Types: CppAD::numeric_limits</a><br/> |
2370 | 2370 | cppad<b>::</b>vector <a href="test_vector.xml#CppAD::vector" target="_top">Choosing The Vector Testing Template Class: CppAD::vector</a><br/> |
2620 | 2620 |            <a href="exp_2_for2.xml#Operation Sequence.Derivative" target="_top">exp_2: Second Order Forward Mode: Operation Sequence.Derivative</a><br/> |
2621 | 2621 |            <a href="exp_2_for1.xml#Operation Sequence.Derivative" target="_top">exp_2: First Order Forward Mode: Operation Sequence.Derivative</a><br/> |
2622 | 2622 |            <a href="get_started.cpp.xml#Derivative" target="_top">Getting Started Using CppAD to Compute Derivatives: Derivative</a><br/> |
2623 |            <a href="cppad.xml" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms</a><br/> | |
2623 |            <a href="cppad.xml" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms</a><br/> | |
2624 | 2624 | derivative<b>:</b> <a href="revone.xml" target="_top">First Order Derivative: Driver Routine</a><br/> |
2625 | 2625 |             <a href="forone.xml" target="_top">First Order Partial Derivative: Driver Routine</a><br/> |
2626 | 2626 | derivatives <a href="old_usead_2.cpp.xml" target="_top">Using AD to Compute Atomic Function Derivatives</a><br/> |
2736 | 2736 | differentiation <a href="ad_in_c.cpp.xml" target="_top">Example and Test Linking CppAD to Languages Other than C++</a><br/> |
2737 | 2737 |                 <a href="introduction.xml#Preface.Algorithmic Differentiation" target="_top">An Introduction by Example to Algorithmic Differentiation: Preface.Algorithmic Differentiation</a><br/> |
2738 | 2738 |                 <a href="introduction.xml" target="_top">An Introduction by Example to Algorithmic Differentiation</a><br/> |
2739 |                 <a href="cppad.xml" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms</a><br/> | |
2740 |                 <a href="cppad.xml" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms</a><br/> | |
2739 |                 <a href="cppad.xml" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms</a><br/> | |
2740 |                 <a href="cppad.xml" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms</a><br/> | |
2741 | 2741 | dimension <a href="rombergmul.xml" target="_top">Multi-dimensional Romberg Integration</a><br/> |
2742 | 2742 | dimensional <a href="rombergmul.cpp.xml" target="_top">One Dimensional Romberg Integration: Example and Test</a><br/> |
2743 | 2743 |             <a href="rombergmul.xml" target="_top">Multi-dimensional Romberg Integration</a><br/> |
3408 | 3408 |         <a href="colpack_hes.cpp.xml" target="_top">Using ColPack: Example and Test</a><br/> |
3409 | 3409 |         <a href="colpack_jac.cpp.xml" target="_top">Using ColPack: Example and Test</a><br/> |
3410 | 3410 |         <a href="colpack_prefix.xml#Example" target="_top">Including the ColPack Sparsity Calculations: Example</a><br/> |
3411 |         <a href="cppad.xml#Example" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms: Example</a><br/> | |
3411 |         <a href="cppad.xml#Example" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms: Example</a><br/> | |
3412 | 3412 | examples <a href="speed_example.cpp.xml" target="_top">Run the Speed Examples</a><br/> |
3413 | 3413 |          <a href="example.cpp.xml" target="_top">CppAD Examples and Tests</a><br/> |
3414 | 3414 |          <a href="listallexamples.xml" target="_top">List of All the CppAD Examples</a><br/> |
3693 | 3693 |      <a href="check_for_nan.xml#get_check_for_nan.file" target="_top">Check an ADFun Object For Nan Results: get_check_for_nan.file</a><br/> |
3694 | 3694 |      <a href="base_alloc.hpp.xml#Include File" target="_top">Example AD<Base> Where Base Constructor Allocates Memory: Include File</a><br/> |
3695 | 3695 |      <a href="download.xml#Windows File Extraction and Testing" target="_top">Download The CppAD Source Code: Windows File Extraction and Testing</a><br/> |
3696 |      <a href="cppad.xml#Include File" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms: Include File</a><br/> | |
3696 |      <a href="cppad.xml#Include File" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms: Include File</a><br/> | |
3697 | 3697 | file<b>_</b>name <a href="check_for_nan.xml#Error Message.file_name" target="_top">Check an ADFun Object For Nan Results: Error Message.file_name</a><br/> |
3698 | 3698 | files <a href="addon.xml#Library Files" target="_top">CppAD Addons: Library Files</a><br/> |
3699 | 3699 |       <a href="addon.xml#Include Files" target="_top">CppAD Addons: Include Files</a><br/> |
4348 | 4348 |         <a href="exp_eps.xml#include" target="_top">An Epsilon Accurate Exponential Approximation: include</a><br/> |
4349 | 4349 |         <a href="exp_2.xml#include" target="_top">Second Order Exponential Approximation: include</a><br/> |
4350 | 4350 |         <a href="cmake.xml" target="_top">Using CMake to Configure CppAD</a><br/> |
4351 |         <a href="cppad.xml#Include File" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms: Include File</a><br/> | |
4351 |         <a href="cppad.xml#Include File" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms: Include File</a><br/> | |
4352 | 4352 | including <a href="sacado_prefix.xml" target="_top">Including the Sacado Speed Tests</a><br/> |
4353 | 4353 |           <a href="ipopt_prefix.xml" target="_top">Including the cppad_ipopt Library and Tests</a><br/> |
4354 | 4354 |           <a href="fadbad_prefix.xml" target="_top">Including the FADBAD Speed Tests</a><br/> |
4507 | 4507 |              <a href="example.xml#Introduction" target="_top">Examples: Introduction</a><br/> |
4508 | 4508 |              <a href="exp_apx_main.cpp.xml" target="_top">Correctness Tests For Exponential Approximation in Introduction</a><br/> |
4509 | 4509 |              <a href="introduction.xml" target="_top">An Introduction by Example to Algorithmic Differentiation</a><br/> |
4510 |              <a href="cppad.xml#Introduction" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms: Introduction</a><br/> | |
4510 |              <a href="cppad.xml#Introduction" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms: Introduction</a><br/> | |
4511 | 4511 | inuse <a href="memory_leak.xml#inuse" target="_top">Memory Leak Detection: inuse</a><br/> |
4512 | 4512 |       <a href="omp_inuse.xml" target="_top">Amount of Memory a Thread is Currently Using</a><br/> |
4513 | 4513 |       <a href="ta_inuse.xml" target="_top">Amount of Memory a Thread is Currently Using</a><br/> |
5225 | 5225 |           <a href="cppad_ipopt_nlp.xml#cppad_ipopt namespace" target="_top">Nonlinear Programming Using the CppAD Interface to Ipopt: cppad_ipopt namespace</a><br/> |
5226 | 5226 |           <a href="faq.xml#Namespace" target="_top">Frequently Asked Questions and Answers: Namespace</a><br/> |
5227 | 5227 |           <a href="cppad_eigen.hpp.xml#CppAD Namespace" target="_top">Enable Use of Eigen Linear Algebra Package with CppAD: CppAD Namespace</a><br/> |
5228 |           <a href="cppad.xml#Namespace" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms: Namespace</a><br/> | |
5228 |           <a href="cppad.xml#Namespace" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms: Namespace</a><br/> | |
5229 | 5229 | nan <a href="zdouble.xml#Syntax.Nan" target="_top">zdouble: An AD Base Type With Absolute Zero: Syntax.Nan</a><br/> |
5230 | 5230 |     <a href="ode_err_control.cpp.xml#Nan" target="_top">OdeErrControl: Example and Test: Nan</a><br/> |
5231 | 5231 |     <a href="odeerrcontrol.xml#Method.Nan" target="_top">An Error Controller for ODE Solvers: Method.Nan</a><br/> |
5751 | 5751 |         <a href="speed.xml" target="_top">Speed Test an Operator Overloading AD Package</a><br/> |
5752 | 5752 |         <a href="cppad_eigen.hpp.xml" target="_top">Enable Use of Eigen Linear Algebra Package with CppAD</a><br/> |
5753 | 5753 |         <a href="cmake.xml" target="_top">Using CMake to Configure CppAD</a><br/> |
5754 |         <a href="cppad.xml" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms</a><br/> | |
5754 |         <a href="cppad.xml" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms</a><br/> | |
5755 | 5755 | package<b>_</b>prefix <a href="cmake.xml#package_prefix" target="_top">Using CMake to Configure CppAD: package_prefix</a><br/> |
5756 | 5756 | parallel <a href="old_atomic.xml#afun.Parallel Mode" target="_top">User Defined Atomic AD Functions: afun.Parallel Mode</a><br/> |
5757 | 5757 |          <a href="omp_in_parallel.xml" target="_top">Is The Current Execution in OpenMP Parallel Mode</a><br/> |
5889 | 5889 | preprocessor <a href="addon.xml#Preprocessor Symbols" target="_top">CppAD Addons: Preprocessor Symbols</a><br/> |
5890 | 5890 |              <a href="faq.xml#Namespace.Test Vector Preprocessor Symbol" target="_top">Frequently Asked Questions and Answers: Namespace.Test Vector Preprocessor Symbol</a><br/> |
5891 | 5891 |              <a href="preprocessor.xml" target="_top">CppAD API Preprocessor Symbols</a><br/> |
5892 |              <a href="cppad.xml#Preprocessor Symbols" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms: Preprocessor Symbols</a><br/> | |
5892 |              <a href="cppad.xml#Preprocessor Symbols" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms: Preprocessor Symbols</a><br/> | |
5893 | 5893 | previous <a href="whats_new.xml#Previous Years" target="_top">Changes and Additions to CppAD: Previous Years</a><br/> |
5894 | 5894 | previously <a href="tracknewdel.xml#TrackCount.Previously Deprecated" target="_top">Routines That Track Use of New and Delete: TrackCount.Previously Deprecated</a><br/> |
5895 | 5895 |            <a href="tracknewdel.xml#TrackExtend.Previously Deprecated" target="_top">Routines That Track Use of New and Delete: TrackExtend.Previously Deprecated</a><br/> |
7365 | 7365 | symbol <a href="faq.xml#Namespace.Test Vector Preprocessor Symbol" target="_top">Frequently Asked Questions and Answers: Namespace.Test Vector Preprocessor Symbol</a><br/> |
7366 | 7366 | symbols <a href="addon.xml#Preprocessor Symbols" target="_top">CppAD Addons: Preprocessor Symbols</a><br/> |
7367 | 7367 |         <a href="preprocessor.xml" target="_top">CppAD API Preprocessor Symbols</a><br/> |
7368 |         <a href="cppad.xml#Preprocessor Symbols" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms: Preprocessor Symbols</a><br/> | |
7368 |         <a href="cppad.xml#Preprocessor Symbols" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms: Preprocessor Symbols</a><br/> | |
7369 | 7369 | syntax <a href="luratio.xml#Syntax" target="_top">LU Factorization of A Square Matrix and Stability Calculation: Syntax</a><br/> |
7370 | 7370 |        <a href="opt_val_hes.xml#Syntax" target="_top">Jacobian and Hessian of Optimal Values: Syntax</a><br/> |
7371 | 7371 |        <a href="benderquad.xml#Syntax" target="_top">Computing Jacobian and Hessian of Bender's Reduced Objective: Syntax</a><br/> |
7570 | 7570 |        <a href="get_eigen.sh.xml#Syntax" target="_top">Download and Install Eigen in Build Directory: Syntax</a><br/> |
7571 | 7571 |        <a href="get_colpack.sh.xml#Syntax" target="_top">Download and Install ColPack in Build Directory: Syntax</a><br/> |
7572 | 7572 |        <a href="get_adolc.sh.xml#Syntax" target="_top">Download and Install Adolc in Build Directory: Syntax</a><br/> |
7573 |        <a href="cppad.xml#Syntax" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms: Syntax</a><br/> | |
7573 |        <a href="cppad.xml#Syntax" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms: Syntax</a><br/> | |
7574 | 7574 | systems <a href="elapsed_seconds.xml#Microsoft Systems" target="_top">Returns Elapsed Number of Seconds: Microsoft Systems</a><br/> |
7575 | 7575 | |
7576 | 7576 | <b><big><a name="T">T</a></big></b> |
8634 | 8634 |         <a href="atomic_afun.xml" target="_top">Using AD Version of Atomic Function</a><br/> |
8635 | 8635 |         <a href="discrete.xml#Create AD Version" target="_top">Discrete AD Functions: Create AD Version</a><br/> |
8636 | 8636 |         <a href="download.xml#Current Version" target="_top">Download The CppAD Source Code: Current Version</a><br/> |
8637 |         <a href="cppad.xml" target="_top">cppad-20170000.2: A Package for Differentiation of C++ Algorithms</a><br/> | |
8637 |         <a href="cppad.xml" target="_top">cppad-20170000.3: A Package for Differentiation of C++ Algorithms</a><br/> | |
8638 | 8638 | version<b>)</b> <a href="double_mat_mul.cpp.xml" target="_top">CppAD Speed: Matrix Multiplication (Double Version)</a><br/> |
8639 | 8639 | versions <a href="download.xml#Daily Versions" target="_top">Download The CppAD Source Code: Daily Versions</a><br/> |
8640 | 8640 |          <a href="download.xml#Monthly Versions" target="_top">Download The CppAD Source Code: Monthly Versions</a><br/> |
244 | 244 | <a href="cos.cpp.xml" target="_top">cos.cpp</a><br/> </td><td> The AD cos Function: Example and Test </td></tr><tr valign="top"><td> |
245 | 245 | <a href="cosh.xml" target="_top">cosh</a><br/> </td><td> The Hyperbolic Cosine Function: cosh </td></tr><tr valign="top"><td> |
246 | 246 | <a href="cosh.cpp.xml" target="_top">cosh.cpp</a><br/> </td><td> The AD cosh Function: Example and Test </td></tr><tr valign="top"><td> |
247 | <a href="cppad.xml" target="_top">CppAD</a><br/> </td><td> cppad-20170000.2: A Package for Differentiation of C++ Algorithms </td></tr><tr valign="top"><td> | |
247 | <a href="cppad.xml" target="_top">CppAD</a><br/> </td><td> cppad-20170000.3: A Package for Differentiation of C++ Algorithms </td></tr><tr valign="top"><td> | |
248 | 248 | <a href="cppad_assert.xml" target="_top">cppad_assert</a><br/> </td><td> CppAD Assertions During Execution </td></tr><tr valign="top"><td> |
249 | 249 | <a href="cppad_det_lu.cpp.xml" target="_top">cppad_det_lu.cpp</a><br/> </td><td> CppAD Speed: Gradient of Determinant Using Lu Factorization </td></tr><tr valign="top"><td> |
250 | 250 | <a href="cppad_det_minor.cpp.xml" target="_top">cppad_det_minor.cpp</a><br/> </td><td> CppAD Speed: Gradient of Determinant by Minor Expansion </td></tr><tr valign="top"><td> |
2 | 2 | // ------------------------------------------------------------ |
3 | 3 | Keyword = |
4 | 4 | [ |
5 | 'CppAD cppad-20170000.2: A Package for Differentiation of C++ Algorithms ',' algorithmic automatic derivative version cppad.hpp syntax introduction example include file preprocessor symbols namespace ', | |
5 | 'CppAD cppad-20170000.3: A Package for Differentiation of C++ Algorithms ',' algorithmic automatic derivative version cppad.hpp syntax introduction example include file preprocessor symbols namespace ', | |
6 | 6 | 'Install CppAD Download, Test, and Install Instructions ',' step 1: 2: cmake 3: check 4: installation ', |
7 | 7 | 'download Download The CppAD Source Code ',' purpose distribution directory compressed archives current version subversion git release versions coin github monthly daily windows file extraction testing install instructions no documentation building ', |
8 | 8 | 'cmake Using CMake to Configure CppAD ',' makefile install prefix postfix include directories lib datadir documentation package compile flags profile maximum number threads sparsity internal structure vector sets memory usage tape implicit explicit the program command build directory check cmake_verbose_makefile generator cppad_prefix cppad_postfix cmake_install_includedirs cmake_install_libdirs cmake_install_datadir cmake_install_docdir package_prefix cppad_cxx_flags c++11 cppad_profile_flag eigen fadbad cppad_testvector cppad_max_num_threads cppad_tape_id_type cstdint cppad_tape_addr_type cppad_deprecated ', |
2 | 2 | xmlns:math='http://www.w3.org/1998/Math/MathML' |
3 | 3 | > |
4 | 4 | <head> |
5 | <title>cppad-20170000.2: A Package for Differentiation of C++ Algorithms</title> | |
5 | <title>cppad-20170000.3: A Package for Differentiation of C++ Algorithms</title> | |
6 | 6 | <meta http-equiv='Content-Type' content='text/html' charset='utf-8'/> |
7 | <meta name="description" id="description" content="cppad-20170000.2: A Package for Differentiation of C++ Algorithms"/> | |
8 | <meta name="keywords" id="keywords" content=" cppad-20170000.2: package differentiation c++ algorithms Ad algorithmic automatic C++ algorithm derivative Cppad version cppad.hpp syntax introduction example include file preprocessor symbols namespace "/> | |
7 | <meta name="description" id="description" content="cppad-20170000.3: A Package for Differentiation of C++ Algorithms"/> | |
8 | <meta name="keywords" id="keywords" content=" cppad-20170000.3: package differentiation c++ algorithms Ad algorithmic automatic C++ algorithm derivative Cppad version cppad.hpp syntax introduction example include file preprocessor symbols namespace "/> | |
9 | 9 | <style type='text/css'> |
10 | 10 | body { color : black } |
11 | 11 | body { background-color : white } |
70 | 70 | , |
71 | 71 | |
72 | 72 | |
73 | <center><b><big><big>cppad-20170000.2: A Package for Differentiation of C++ Algorithms</big></big></b></center> | |
73 | <center><b><big><big>cppad-20170000.3: A Package for Differentiation of C++ Algorithms</big></big></b></center> | |
74 | 74 | <br/> |
75 | 75 | <b><big><a name="Syntax" id="Syntax">Syntax</a></big></b> |
76 | 76 |
168 | 168 | |
169 | 169 | current </td><td align='left' valign='top'> |
170 | 170 | EPL </td><td align='left' valign='top'> |
171 | <a href="http://www.coin-or.org/download/source/CppAD/cppad-20170000.2.epl.tgz" target="_top"><span style='white-space: nowrap'>cppad-20170000.2.epl.tgz</span></a> | |
171 | <a href="http://www.coin-or.org/download/source/CppAD/cppad-20170000.3.epl.tgz" target="_top"><span style='white-space: nowrap'>cppad-20170000.3.epl.tgz</span></a> | |
172 | 172 | |
173 | 173 | </td></tr><tr><td align='left' valign='top'> |
174 | 174 | |
175 | 175 | current </td><td align='left' valign='top'> |
176 | 176 | GPL </td><td align='left' valign='top'> |
177 | <a href="http://www.coin-or.org/download/source/CppAD/cppad-20170000.2.gpl.tgz" target="_top"><span style='white-space: nowrap'>cppad-20170000.2.gpl.tgz</span></a> | |
177 | <a href="http://www.coin-or.org/download/source/CppAD/cppad-20170000.3.gpl.tgz" target="_top"><span style='white-space: nowrap'>cppad-20170000.3.gpl.tgz</span></a> | |
178 | 178 | |
179 | 179 | </td></tr> |
180 | 180 | </table> |
89 | 89 | |
90 | 90 | $comment bin/version assumes that : follows cppad version number here$$ |
91 | 91 | $section |
92 | cppad-20170000.2: A Package for Differentiation of C++ Algorithms | |
92 | cppad-20170000.3: A Package for Differentiation of C++ Algorithms | |
93 | 93 | $$ |
94 | 94 | $mindex AD algorithmic differentiation automatic C++ algorithm derivative CppAD version cppad.hpp$$ |
95 | 95 |
0 | # $Id: makefile.am 3854 2016-12-14 17:36:26Z bradbell $ | |
1 | 0 | # ----------------------------------------------------------------------------- |
2 | # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell | |
1 | # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell | |
3 | 2 | # |
4 | 3 | # CppAD is distributed under multiple licenses. This distribution is under |
5 | 4 | # the terms of the |
238 | 237 | cppad/local/op_code.hpp \ |
239 | 238 | cppad/local/op.hpp \ |
240 | 239 | cppad/local/optimize/match_op.hpp \ |
241 | cppad/local/optimize/cskip_info.hpp \ | |
240 | cppad/local/optimize/cexp_info.hpp \ | |
242 | 241 | cppad/local/optimize/csum_stacks.hpp \ |
243 | 242 | cppad/local/optimize/csum_variable.hpp \ |
244 | 243 | cppad/local/optimize/get_op_info.hpp \ |
407 | 407 | top_builddir = @top_builddir@ |
408 | 408 | top_srcdir = @top_srcdir@ |
409 | 409 | |
410 | # $Id: makefile.in 3867 2017-01-19 13:02:09Z bradbell $ | |
411 | 410 | # ----------------------------------------------------------------------------- |
412 | # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell | |
411 | # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell | |
413 | 412 | # |
414 | 413 | # CppAD is distributed under multiple licenses. This distribution is under |
415 | 414 | # the terms of the |
632 | 631 | cppad/local/op_code.hpp \ |
633 | 632 | cppad/local/op.hpp \ |
634 | 633 | cppad/local/optimize/match_op.hpp \ |
635 | cppad/local/optimize/cskip_info.hpp \ | |
634 | cppad/local/optimize/cexp_info.hpp \ | |
636 | 635 | cppad/local/optimize/csum_stacks.hpp \ |
637 | 636 | cppad/local/optimize/csum_variable.hpp \ |
638 | 637 | cppad/local/optimize/get_op_info.hpp \ |
94 | 94 | $bold version$$ $pre $$ $cnext $bold license$$ $pre $$ $cnext $bold link$$ |
95 | 95 | $rnext |
96 | 96 | current $cnext EPL $cnext $href% |
97 | http://www.coin-or.org/download/source/CppAD/cppad-20170000.2.epl.tgz% | |
98 | cppad-20170000.2.epl.tgz%$$ | |
97 | http://www.coin-or.org/download/source/CppAD/cppad-20170000.3.epl.tgz% | |
98 | cppad-20170000.3.epl.tgz%$$ | |
99 | 99 | $rnext |
100 | 100 | current $cnext GPL $cnext $href% |
101 | http://www.coin-or.org/download/source/CppAD/cppad-20170000.2.gpl.tgz% | |
102 | cppad-20170000.2.gpl.tgz%$$ | |
101 | http://www.coin-or.org/download/source/CppAD/cppad-20170000.3.gpl.tgz% | |
102 | cppad-20170000.3.gpl.tgz%$$ | |
103 | 103 | $tend |
104 | 104 | |
105 | 105 | $subhead Subversion$$ |
0 | // $Id: optimize.cpp 3856 2016-12-21 05:51:22Z bradbell $ | |
1 | 0 | /* -------------------------------------------------------------------------- |
2 | CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell | |
1 | CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell | |
3 | 2 | |
4 | 3 | CppAD is distributed under multiple licenses. This distribution is under |
5 | 4 | the terms of the |
423 | 422 | |
424 | 423 | // unary operator where operand is arg[0] |
425 | 424 | // (note that sin corresponds to two tape variables) |
426 | not_used = CppAD::abs(x[0]); | |
425 | not_used = fabs(x[0]); | |
427 | 426 | y[0] = sin(x[0]); |
428 | 427 | original += 3; |
429 | 428 | opt += 2; |
986 | 985 | ); |
987 | 986 | Y[0] = X[0]; |
988 | 987 | for(j = 0; j < n_operations; j++) |
989 | Y[0] = abs(Y[0]); | |
988 | Y[0] = fabs(Y[0]); | |
990 | 989 | |
991 | 990 | // create f: X -> Y and stop tape recording |
992 | 991 | CppAD::ADFun<double> F; |
1874 | 1873 | ok &= NearEqual(y[0], x[0] + x[1], eps10, eps10); |
1875 | 1874 | ok &= NearEqual(y[1], x[0] - x[1], eps10, eps10); |
1876 | 1875 | ok &= NearEqual(y[2], exp(x[0]), eps10, eps10); |
1876 | ||
1877 | return ok; | |
1878 | } | |
1879 | ||
1880 | // Test case where a variable is removed during optimization | |
1881 | // (bug fixed 2017-03-04) | |
1882 | bool cond_exp_skip_remove_var(void) | |
1883 | { bool ok = true; | |
1884 | using CppAD::vector; | |
1885 | using CppAD::AD; | |
1886 | using CppAD::NearEqual; | |
1887 | double eps10 = 10.0 * std::numeric_limits<double>::epsilon(); | |
1888 | ||
1889 | vector< AD<double> > ax(2), ay(2); | |
1890 | ax[0] = 1.0; | |
1891 | ax[1] = 2.0; | |
1892 | Independent(ax); | |
1893 | // | |
1894 | AD<double> var_1 = ax[0] + ax[1]; | |
1895 | AD<double> var_2 = ax[0] + ax[1]; // gets removed during optimization | |
1896 | AD<double> var_3 = ax[0] + ax[1]; // gets removed during optimization | |
1897 | AD<double> var_4 = ax[0] - ax[1]; | |
1898 | AD<double> par_1 = 1.0; | |
1899 | // | |
1900 | // first conditional expression depends on var_1 | |
1901 | // 6 * x_0 if x_0 + x_1 >= 1.0, 7 * x_1 otherwise | |
1902 | ay[0] = CppAD::CondExpGe(var_1, par_1, 6.0 * ax[0], 7.0 * ax[1]); | |
1903 | // | |
1904 | // second conditional expression depends on var_4 | |
1905 | // 8 * x_0 if x_0 - x_1 >= x_0 + x_1, 9 * x_1 otherwise | |
1906 | ay[1] = CppAD::CondExpGe(var_4, par_1, 8.0 * ax[0], 9.0 * ax[1]); | |
1907 | CppAD::ADFun<double> f(ax, ay); | |
1908 | // | |
1909 | if( conditional_skip_ ) | |
1910 | f.optimize(); | |
1911 | else | |
1912 | f.optimize("no_conditional_skip"); | |
1913 | ||
1914 | // check case where x[0] = 2, x[1] = 4 | |
1915 | vector<double> x(2), y(2); | |
1916 | x[0] = 2.0; | |
1917 | x[1] = 4.0; | |
1918 | y = f.Forward(0, x); | |
1919 | ok &= NearEqual(y[0], 6.0 * x[0], eps10, eps10); | |
1920 | ok &= NearEqual(y[1], 9.0 * x[1], eps10, eps10); | |
1877 | 1921 | |
1878 | 1922 | return ok; |
1879 | 1923 | } |
1949 | 1993 | // check reverse mode conditional skipping |
1950 | 1994 | ok &= cond_exp_reverse(); |
1951 | 1995 | // check case where an expresion needed by both true and false case |
1952 | ok &= cond_exp_both_true_and_false(); | |
1996 | ok &= cond_exp_both_true_and_false(); | |
1997 | // check case were a variable in left or right expressions | |
1998 | // is removed during the optimization | |
1999 | ok &= cond_exp_skip_remove_var(); | |
1953 | 2000 | } |
1954 | 2001 | // |
1955 | 2002 | CppAD::user_atomic<double>::clear(); |