source: trunk/cppad/local/fun_construct.hpp @ 3607

Last change on this file since 3607 was 3607, checked in by bradbell, 5 years ago

merge to branch: trunk
from repository: https://github.com/coin-or/CppAD
start hash code: f4baab0ea7c2679ba9351b0439b6efebfa77ba04
end hash code: 894d554a00ceec8a3545f05eca62708a7b5cb43d

commit 894d554a00ceec8a3545f05eca62708a7b5cb43d
Author: Brad Bell <bradbell@…>
Date: Tue Jan 20 09:06:10 2015 -0700

Fix copyright end date.


whats_new_15.omh: Add comment about date of deprecation.

commit 611e982000168db91aba22b763c14bb78d57da47
Author: Brad Bell <bradbell@…>
Date: Tue Jan 20 08:53:00 2015 -0700

Squashed commit from old/compare_op to master:


In addition, fix copyright end date for some files, and add note about
deprecated date in whats_new_15.omh.


commit 6e46df5c850ecd58d7a886db4043bc3f2d4579d1
Author: Brad Bell <bradbell@…>
Date: Tue Jan 20 08:16:57 2015 -0700


Always return f.compare_change_op_index() == 0 after f.optimize().


checkpoint.hpp: ignore comparison operators.
fun_construct.hpp: remove double initilaization of values.
compare_change.cpp: demonstrate more features of new interface.
whats_new_15.omh: prepare for merging this branch into master.
wish_list.omh: update wish list item to new compare_change interface.


commit 45315907c70e5b383d984fb9498b54a474001af0
Author: Brad Bell <bradbell@…>
Date: Tue Jan 20 05:04:37 2015 -0700


Use the new f.compare_change_count(0) option in speed tests.


commit bb6e72befd6d01f1fb62c43b9b19471ffaa7cc2c
Author: Brad Bell <bradbell@…>
Date: Tue Jan 20 04:51:16 2015 -0700


Move CompareChange? -> deprecated and plan -> compare_change.


forward0sweep.hpp: skip comparison operator when count is zero.
forward1sweep.hpp: skip comparison operator when count is zero.
compare_change.cpp: demonstrate count == 0 case.


commit 622a13c568c612d9dfe9ccd1a01f4ac5f74ba824
Author: Brad Bell <bradbell@…>
Date: Mon Jan 19 23:17:42 2015 -0700


Add example and test of new compare change user API.


ad_fun.hpp: fix f.compare_change_op_index.
compare_change.cpp: Change example to use new API.
compare_change.cpp: Move old example here (just test now).


commit ec4c1613eae8df56fbf31e7b8711ce69cc41df83
Author: Brad Bell <bradbell@…>
Date: Mon Jan 19 21:12:11 2015 -0700


Implement the compare change plan, still needs an example and test.
Also have the change from 'plan' to just plain documentation.


commit a81a46f27011bee08ba072551044dc9f4a99a906
Author: Brad Bell <bradbell@…>
Date: Mon Jan 19 17:49:05 2015 -0700


Change name of compare_change functions and partially implement this new plan.


commit 146faad48a700a56362e74f9c3a3c39144a79738
Author: Brad Bell <bradbell@…>
Date: Mon Jan 19 14:22:40 2015 -0700


Branch: compare_op
plan.omh: change name of count function.


commit 35d91d126765d1a0ab4bfe9e2b006bbf535cd648
Author: Brad Bell <bradbell@…>
Date: Mon Jan 19 13:19:07 2015 -0700


Add deprecation date for some more cases.


commit 5bb65a8c48fae4263b66fcd04520e10e66febc11
Author: Brad Bell <bradbell@…>
Date: Mon Jan 19 13:13:51 2015 -0700


Add date of deprecation for some more cases.


commit e95ee6b209601cd9a075d2e37c602e73c32fb6ab
Author: Brad Bell <bradbell@…>
Date: Mon Jan 19 12:58:44 2015 -0700


Add date of deprecation for some more cases.


commit 0ea84ccd87383edc62a6ae1711da104b12e8c444
Author: Brad Bell <bradbell@…>
Date: Mon Jan 19 12:47:01 2015 -0700


Add date of deprecation for some cases.


commit 17755e609ea8e03472b08dcc2fb5ad347eb723cb
Author: Brad Bell <bradbell@…>
Date: Mon Jan 19 08:20:45 2015 -0700


plan.omh: changs some names.


commit 29f369c06d4d0ee284c4c668d52d8461613066dc
Author: Brad Bell <bradbell@…>
Date: Fri Jan 16 06:39:45 2015 -0700


Document the plan for compare_change user API.


compare_change.omh: fix minor typo.
plan.txt: change to the omhelp file plan.omh.


commit a3a2f4dedd202a722812b6eb2714851b40726e6e
Author: Brad Bell <bradbell@…>
Date: Thu Jan 15 21:03:44 2015 -0700


new_branch.sh: remove unused variable.
push_git2svn.py: move repository from github/bradbell to coin-or/bradbell.


commit 3751a197ab2897e76616f9d9b0915148bd855356
Author: Brad Bell <bradbell@…>
Date: Thu Jan 15 20:56:17 2015 -0700


plan.txt: plan for this branches API will go here.


commit 76013ec2ad7baacdeab5e761812d542867910174
Author: Brad Bell <bradbell@…>
Date: Thu Jan 15 18:04:33 2015 -0700


Store the operator index for the first comparision change in the ADFun object.


commit 9caf25014079a60df5de17bcac76775daf8ee201
Author: Brad Bell <bradbell@…>
Date: Thu Jan 15 12:45:56 2015 -0700


Make compare_change a parameter (so will be easy to add compare_first).


commit 2246d22fe82b8909d432f82ab0d783ce3351a02f
Author: Brad Bell <bradbell@…>
Date: Thu Jan 15 09:12:40 2015 -0700


speed_branch.sh: fix directory (before cd).


commit b3910de86558a97749741bfb728e45c5a86d1c73
Author: Brad Bell <bradbell@…>
Date: Thu Jan 15 05:14:01 2015 -0700


search.sh: use git to get list of source files.
ad_fun.hpp: imporve doxygen doc for compare_change_.
ad_tape.hpp: remove RecordCompare? (no longer used).
atomic_base.hpp: minor edit to user documentation.


commit dd74f331386cadc9cc272c264296e575691aa3f8
Author: Brad Bell <bradbell@…>
Date: Thu Jan 15 04:12:34 2015 -0700


Change Leq..Op -> Le..Op and leq.._op -> le.._op.


commit ae729296323eb7f4f4a7c0e90a303a8d7f4ed42a
Author: Brad Bell <bradbell@…>
Date: Wed Jan 14 21:19:55 2015 -0700


comp_op.hpp: Add doxygen documentaiton for compare operators.
compare.hpp: avoid an extra branch.


commit b064d59a5ad01dff5c708cc8c02f628f58c863ec
Author: Brad Bell <bradbell@…>
Date: Wed Jan 14 16:11:25 2015 -0700


Remove ComOp?, replaced by specific cases Eq..Op, Ne..Op, Leq..Op, Lt..Op,
which should run faster.


forward0sweep.hpp: Remove out-dated comment about CompOp?.
forward1sweep.hpp: Remove out-dated comment about CompOp?.


commit 5bb0a70d1151e9086b88024050cea6cf11e83aa7
Author: Brad Bell <bradbell@…>
Date: Wed Jan 14 09:02:17 2015 -0700


Use Eq..Op, Ne..Op to implement == and !=.


commit 0ebeec61bc040a00c50db41ca5da31fb87194f93
Author: Brad Bell <bradbell@…>
Date: Wed Jan 14 07:19:26 2015 -0700


compare.hpp: Finish folding < <= > >= into Lt..Op and Leq..Op.


commit c949e5b72158b98cbab61c8aea98e76008e9c2f4
Author: Brad Bell <bradbell@…>
Date: Wed Jan 14 06:28:41 2015 -0700


  1. Change plan to fold all compare operations into Leq..Op and Lt..Op cases.
  2. Fix alphabetical order between Ld and Leq.


commit 6ffee88b68b682359d62bc75a8c2ba3e28d012ac
Author: Brad Bell <bradbell@…>
Date: Tue Jan 13 22:40:18 2015 -0700


Splite parameter <= variable and parameter > variable as separate compare
operators.


commit 0841014db4ead690d1c2358f5e09494030ae1e5f
Author: Brad Bell <bradbell@…>
Date: Tue Jan 13 21:12:57 2015 -0700


Attempting to recording and playback of compare operators faster:
Split variable <= variable and variable > variable out as separate cases.


compare.hpp: remove white space at end of lines.


commit cfd3afceebd4b3383b3042cbca98caf82ff77670
Author: Brad Bell <bradbell@…>
Date: Tue Jan 13 08:39:12 2015 -0700


speed_branch.sh: compare speed_cppad between two git branches.
speed_new.sh: correct list of options, remove unused variable.
wish_list.omh: correct discussion of effect of keeping compare operators.


commit 9ed03e1ee2c258ca38561ad083067e235d032e14
Author: Brad Bell <bradbell@…>
Date: Tue Jan 13 05:54:30 2015 -0700


Change test so it corresponds to optimization keeping compare operators.


commit 5c418d477d58984b094bba027ebb0794e759e557
Author: Brad Bell <bradbell@…>
Date: Tue Jan 13 05:12:50 2015 -0700


Include example and test of using CompareChange? with optimized tape.


commit c1b48edfa56ca096ce8c2db1dbadb2658cb13fe3
Author: Brad Bell <bradbell@…>
Date: Tue Jan 13 04:24:54 2015 -0700


Fix optimization so variables used in compare opertions are alwasy available.


commit 6fe607ca30db07b356fd3a9fe9779fa2dfd382d8
Author: Brad Bell <bradbell@…>
Date: Mon Jan 12 07:56:41 2015 -0700


Keep CompareChange? in optimized versions of tape and when NDEBUG is defined.

commit b4c0e51489cc0878499a331b4af4875b2781d8d8
Author: Brad Bell <bradbell@…>
Date: Sun Jan 11 17:01:59 2015 -0700

new_branch.sh: final procedure (only hand tested).

  • Property svn:keywords set to Id
File size: 13.8 KB
Line 
1/* $Id: fun_construct.hpp 3607 2015-01-20 16:20:41Z bradbell $ */
2# ifndef CPPAD_FUN_CONSTRUCT_INCLUDED
3# define CPPAD_FUN_CONSTRUCT_INCLUDED
4
5/* --------------------------------------------------------------------------
6CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 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$begin FunConstruct$$
17$spell
18        alloc
19        num
20        Jac
21        bool
22        taylor
23        var
24        ADvector
25        const
26        Jacobian
27$$
28
29$spell
30$$
31
32$section Construct an ADFun Object and Stop Recording$$
33
34$index ADFun, construct$$
35$index construct, ADFun$$
36$index tape, stop recording$$
37$index recording, stop tape$$
38
39$head Syntax$$
40$codei%ADFun<%Base%> %f%, %g%
41%$$
42$codei%ADFun<%Base%> %f%(%x%, %y%)
43%$$
44$icode%g% = %f%
45%$$
46
47
48$head Purpose$$
49The $codei%AD<%Base%>%$$ object $icode f$$ can
50store an AD of $icode Base$$
51$cref/operation sequence/glossary/Operation/Sequence/$$.
52It can then be used to calculate derivatives of the corresponding
53$cref/AD function/glossary/AD Function/$$
54$latex \[
55        F : B^n \rightarrow B^m
56\] $$
57where $latex B$$ is the space corresponding to objects of type $icode Base$$.
58
59$head x$$
60If the argument $icode x$$ is present, it has prototype
61$codei%
62        const %VectorAD% &%x%
63%$$
64It must be the vector argument in the previous call to
65$cref Independent$$.
66Neither its size, or any of its values, are allowed to change
67between calling
68$codei%
69        Independent(%x%)
70%$$
71and
72$codei%
73        ADFun<%Base%> %f%(%x%, %y%)
74%$$
75
76$head y$$
77If the argument $icode y$$ is present, it has prototype
78$codei%
79        const %VectorAD% &%y%
80%$$
81The sequence of operations that map $icode x$$
82to $icode y$$ are stored in the ADFun object $icode f$$.
83
84$head VectorAD$$
85The type $icode VectorAD$$ must be a $cref SimpleVector$$ class with
86$cref/elements of type/SimpleVector/Elements of Specified Type/$$
87$codei%AD<%Base%>%$$.
88The routine $cref CheckSimpleVector$$ will generate an error message
89if this is not the case.
90
91$head Default Constructor$$
92$index default, ADFun constructor$$
93$index ADFun, default constructor$$
94$index constructor, ADFun constructor$$
95The default constructor
96$codei%
97        ADFun<%Base%> %f%
98%$$
99creates an
100$codei%AD<%Base%>%$$ object with no corresponding operation sequence; i.e.,
101$codei%
102        %f%.size_var()
103%$$
104returns the value zero (see $cref/size_var/seq_property/size_var/$$).
105
106$head Sequence Constructor$$
107$index sequence, ADFun constructor$$
108$index ADFun, sequence constructor$$
109$index constructor, ADFun sequence$$
110The sequence constructor
111$codei%
112        ADFun<%Base%> %f%(%x%, %y%)
113%$$
114creates the $codei%AD<%Base%>%$$ object $icode f$$,
115stops the recording of AD of $icode Base$$ operations
116corresponding to the call
117$codei%
118        Independent(%x%)
119%$$
120and stores the corresponding operation sequence in the object $icode f$$.
121It then stores the zero order Taylor coefficients
122(corresponding to the value of $icode x$$) in $icode f$$.
123This is equivalent to the following steps using the default constructor:
124
125$list number$$
126Create $icode f$$ with the default constructor
127$codei%
128        ADFun<%Base%> %f%;
129%$$
130$lnext
131Stop the tape and storing the operation sequence using
132$codei%
133        %f%.Dependent(%x%, %y%);
134%$$
135(see $cref Dependent$$).
136$lnext
137Calculate the zero order Taylor coefficients for all
138the variables in the operation sequence using
139$codei%
140        %f%.Forward(%p%, %x_p%)
141%$$
142with $icode p$$ equal to zero and the elements of $icode x_p$$
143equal to the corresponding elements of $icode x$$
144(see $cref Forward$$).
145$lend
146
147$head Copy Constructor$$
148$index copy, ADFun constructor$$
149$index ADFun, copy constructor$$
150$index constructor, ADFun copy$$
151It is an error to attempt to use the $codei%ADFun<%Base%>%$$ copy constructor;
152i.e., the following syntax is not allowed:
153$codei%
154        ADFun<%Base%> %g%(%f%)
155%$$
156where $icode f$$ is an $codei%ADFun<%Base%>%$$ object.
157Use its $cref/default constructor/FunConstruct/Default Constructor/$$ instead
158and its assignment operator.
159
160$head Assignment Operator$$
161$index ADFun, assignment operator$$
162$index assignment, ADFun operator$$
163$index operator, ADFun assignment$$
164The $codei%ADFun<%Base%>%$$ assignment operation
165$codei%
166        %g% = %f%
167%$$
168makes a copy of the operation sequence currently stored in $icode f$$
169in the object $icode g$$.
170The object $icode f$$ is not affected by this operation and
171can be $code const$$.
172All of information (state) stored in $icode f$$ is copied to $icode g$$
173and any information originally in $icode g$$ is lost.
174
175$subhead Taylor Coefficients$$
176The Taylor coefficient information currently stored in $icode f$$
177(computed by $cref/f.Forward/Forward/$$) is
178copied to $icode g$$.
179Hence, directly after this operation
180$codei%
181        %g%.size_order() == %f%.size_order()
182%$$
183
184$subhead Sparsity Patterns$$
185The forward Jacobian sparsity pattern currently stored in $icode f$$
186(computed by $cref/f.ForSparseJac/ForSparseJac/$$) is
187copied to $icode g$$.
188Hence, directly after this operation
189$codei%
190        %g%.size_forward_bool() == %f%.size_forward_bool()
191        %g%.size_forward_set()  == %f%.size_forward_set()
192%$$
193
194$head Parallel Mode$$
195$index parallel, ADFun$$
196$index ADFun, parallel$$
197The call to $code Independent$$,
198and the corresponding call to
199$codei%
200        ADFun<%Base%> %f%( %x%, %y%)
201%$$
202or
203$codei%
204        %f%.Dependent( %x%, %y%)
205%$$
206or $cref abort_recording$$,
207must be preformed by the same thread; i.e.,
208$cref/thread_alloc::thread_num/ta_thread_num/$$ must be the same.
209
210$head Example$$
211
212$subhead Sequence Constructor$$
213The file
214$cref independent.cpp$$
215contains an example and test of the sequence constructor.
216It returns true if it succeeds and false otherwise.
217
218$subhead Default Constructor$$
219The files
220$cref fun_check.cpp$$
221and
222$cref hes_lagrangian.cpp$$
223contain an examples and tests using the default constructor.
224They return true if they succeed and false otherwise.
225
226$children%
227        example/fun_assign.cpp
228%$$
229$subhead Assignment Operator$$
230The file
231$cref fun_assign.cpp$$
232contains an example and test of the $codei%ADFun<%Base%>%$$
233assignment operator.
234It returns true if it succeeds and false otherwise.
235
236$end
237----------------------------------------------------------------------------
238*/
239
240namespace CppAD { // BEGIN_CPPAD_NAMESPACE
241/*!
242\file fun_construct.hpp
243ADFun function constructors and assignment operator.
244*/
245
246/*!
247ADFun default constructor
248
249The C++ syntax for this operation is
250\verbatim
251        ADFun<Base> f
252\endverbatim
253An empty ADFun object is created.
254The Dependent member function,
255or the ADFun<Base> assingment operator,
256can then be used to put an operation sequence in this ADFun object.
257
258\tparam Base
259is the base for the recording that can be stored in this ADFun object;
260i.e., operation sequences that were recorded using the type \c AD<Base>.
261*/
262template <typename Base>
263ADFun<Base>::ADFun(void) : 
264has_been_optimized_(false),
265check_for_nan_(true) ,
266compare_change_count_(1),
267compare_change_number_(0),
268compare_change_op_index_(0),
269num_var_tape_(0) 
270{ }
271
272/*!
273ADFun assignment operator
274
275The C++ syntax for this operation is
276\verbatim
277        g = f
278\endverbatim
279where \c g and \c f are ADFun<Base> ADFun objects.
280A copy of the the operation sequence currently stored in \c f
281is placed in this ADFun object (called \c g above).
282Any information currently stored in this ADFun object is lost.
283
284\tparam Base
285is the base for the recording that can be stored in this ADFun object;
286i.e., operation sequences that were recorded using the type \c AD<Base>.
287
288\param f
289ADFun object containing the operation sequence to be copied.
290*/
291template <typename Base>
292void ADFun<Base>::operator=(const ADFun<Base>& f)
293{       size_t m = f.Range();
294        size_t n = f.Domain();
295        size_t i;
296
297        // go through member variables in ad_fun.hpp order
298        //
299        // size_t objects
300        has_been_optimized_        = f.has_been_optimized_;
301        check_for_nan_             = f.check_for_nan_;
302        compare_change_count_      = f.compare_change_count_;
303        compare_change_number_     = f.compare_change_number_;
304        compare_change_op_index_   = f.compare_change_op_index_;
305        num_order_taylor_          = f.num_order_taylor_;
306        cap_order_taylor_          = f.cap_order_taylor_;
307        num_direction_taylor_      = f.num_direction_taylor_;
308        num_var_tape_              = f.num_var_tape_;
309        //
310        // CppAD::vector objects
311        ind_taddr_.resize(n);
312        ind_taddr_                 = f.ind_taddr_;
313        dep_taddr_.resize(m);
314        dep_taddr_                 = f.dep_taddr_;
315        dep_parameter_.resize(m);
316        dep_parameter_             = f.dep_parameter_;
317        //
318        // pod_vector objects
319        taylor_                    = f.taylor_;
320        cskip_op_                  = f.cskip_op_;
321        load_op_                   = f.load_op_;
322        //
323        // player
324        play_                      = f.play_;
325        //
326        // sparse_pack
327        for_jac_sparse_pack_.resize(0, 0);
328        size_t n_set = f.for_jac_sparse_pack_.n_set();
329        size_t end   = f.for_jac_sparse_pack_.end();
330        if( n_set > 0 )
331        {       CPPAD_ASSERT_UNKNOWN( n_set == num_var_tape_  );
332                CPPAD_ASSERT_UNKNOWN( f.for_jac_sparse_set_.n_set() == 0 );
333                for_jac_sparse_pack_.resize(n_set, end);
334                for(i = 0; i < num_var_tape_  ; i++)
335                {       for_jac_sparse_pack_.assignment(
336                                i                       ,
337                                i                       ,
338                                f.for_jac_sparse_pack_
339                        );
340                }
341        }
342        //
343        // sparse_set
344        for_jac_sparse_set_.resize(0, 0);
345        n_set = f.for_jac_sparse_set_.n_set();
346        end   = f.for_jac_sparse_set_.end();
347        if( n_set > 0 )
348        {       CPPAD_ASSERT_UNKNOWN( n_set == num_var_tape_  );
349                CPPAD_ASSERT_UNKNOWN( f.for_jac_sparse_pack_.n_set() == 0 );
350                for_jac_sparse_set_.resize(n_set, end);
351                for(i = 0; i < num_var_tape_; i++)
352                {       for_jac_sparse_set_.assignment(
353                                i                       ,
354                                i                       ,
355                                f.for_jac_sparse_set_
356                        );
357                }
358        }
359}
360
361/*!
362ADFun constructor from an operation sequence.
363
364The C++ syntax for this operation is
365\verbatim
366        ADFun<Base> f(x, y)
367\endverbatim
368The operation sequence that started with the previous call
369\c Independent(x), and that ends with this operation, is stored
370in this \c ADFun<Base> object \c f.
371
372\tparam Base
373is the base for the recording that will be stored in the object \c f;
374i.e., the operations were recorded using the type \c AD<Base>.
375
376\tparam VectorAD
377is a simple vector class with elements of typea \c AD<Base>.
378
379\param x
380is the independent variable vector for this ADFun object.
381The domain dimension of this object will be the size of \a x.
382
383\param y
384is the dependent variable vector for this ADFun object.
385The range dimension of this object will be the size of \a y.
386
387\par Taylor Coefficients
388A zero order forward mode sweep is done,
389and if NDEBUG is not defined the resulting values for the
390depenedent variables are checked against the values in \a y.
391Thus, the zero order Taylor coefficients
392corresponding to the value of the \a x vector
393are stored in this ADFun object.
394*/
395template <typename Base>
396template <typename VectorAD>
397ADFun<Base>::ADFun(const VectorAD &x, const VectorAD &y)
398{
399        CPPAD_ASSERT_KNOWN(
400                x.size() > 0,
401                "ADFun<Base>: independent variable vector has size zero."
402        );
403        CPPAD_ASSERT_KNOWN(
404                Variable(x[0]),
405                "ADFun<Base>: independent variable vector has been changed."
406        );
407        ADTape<Base>* tape = AD<Base>::tape_ptr(x[0].tape_id_);
408        CPPAD_ASSERT_KNOWN(
409                tape->size_independent_ == size_t ( x.size() ),
410                "ADFun<Base>: independent variable vector has been changed."
411        );
412        size_t j, n = x.size();
413# ifndef NDEBUG
414        size_t i, m = y.size();
415        for(j = 0; j < n; j++)
416        {       CPPAD_ASSERT_KNOWN(
417                size_t(x[j].taddr_) == (j+1),
418                "ADFun<Base>: independent variable vector has been changed."
419                );
420                CPPAD_ASSERT_KNOWN(
421                x[j].tape_id_ == x[0].tape_id_,
422                "ADFun<Base>: independent variable vector has been changed."
423                );
424        }
425        for(i = 0; i < m; i++)
426        {       CPPAD_ASSERT_KNOWN(
427                CppAD::Parameter( y[i] ) | (y[i].tape_id_ == x[0].tape_id_) ,
428                "ADFun<Base>: dependent vector contains variables for"
429                "\na different tape than the independent variables."
430                );
431        }
432# endif
433
434        // stop the tape and store the operation sequence
435        Dependent(tape, y);
436
437
438        // ad_fun.hpp member values not set by dependent
439        check_for_nan_ = true;
440
441        // allocate memory for one zero order taylor_ coefficient
442        CPPAD_ASSERT_UNKNOWN( num_order_taylor_ == 0 );
443        CPPAD_ASSERT_UNKNOWN( num_direction_taylor_ == 0 );
444        size_t c = 1;
445        size_t r = 1;
446        capacity_order(c, r);
447        CPPAD_ASSERT_UNKNOWN( cap_order_taylor_     == c );
448        CPPAD_ASSERT_UNKNOWN( num_direction_taylor_ == r );
449
450        // set zero order coefficients corresponding to indpendent variables
451        CPPAD_ASSERT_UNKNOWN( n == ind_taddr_.size() );
452        for(j = 0; j < n; j++)
453        {       CPPAD_ASSERT_UNKNOWN( ind_taddr_[j] == (j+1) );
454                CPPAD_ASSERT_UNKNOWN( size_t(x[j].taddr_) == (j+1) );
455                taylor_[ ind_taddr_[j] ]  = x[j].value_;
456        }
457
458        // use independent variable values to fill in values for others
459        CPPAD_ASSERT_UNKNOWN( cskip_op_.size() == play_.num_op_rec() );
460        CPPAD_ASSERT_UNKNOWN( load_op_.size()  == play_.num_load_op_rec() );
461        forward0sweep(std::cout, false,
462                n, num_var_tape_, &play_, cap_order_taylor_, taylor_.data(),
463                cskip_op_.data(), load_op_,
464                compare_change_count_,
465                compare_change_number_,
466                compare_change_op_index_
467        );
468        CPPAD_ASSERT_UNKNOWN( compare_change_count_    == 1 );
469        CPPAD_ASSERT_UNKNOWN( compare_change_number_   == 0 );
470        CPPAD_ASSERT_UNKNOWN( compare_change_op_index_ == 0 );
471
472        // now set the number of orders stored
473        num_order_taylor_ = 1;
474
475# ifndef NDEBUG
476        // on MS Visual Studio 2012, CppAD required in front of isnan ?
477        for(i = 0; i < m; i++) 
478        if( taylor_[dep_taddr_[i]] != y[i].value_ || CppAD::isnan( y[i].value_ ) )
479        {       using std::endl;
480                std::ostringstream buf;
481                buf << "A dependent variable value is not equal to "
482                    << "its tape evaluation value," << endl
483                    << "perhaps it is nan." << endl
484                    << "Dependent variable value = " 
485                    <<  y[i].value_ << endl
486                    << "Tape evaluation value    = " 
487                    <<  taylor_[dep_taddr_[i]]  << endl
488                    << "Difference               = " 
489                    <<  y[i].value_ -  taylor_[dep_taddr_[i]]  << endl
490                ;
491                CPPAD_ASSERT_KNOWN(
492                        0,
493                        buf.str().c_str()
494                );
495        }
496# endif
497}
498
499} // END_CPPAD_NAMESPACE
500# endif
Note: See TracBrowser for help on using the repository browser.