source: trunk/ADOL-C/src/param.cpp @ 708

Last change on this file since 708 was 708, checked in by kulshres, 2 years ago

Merge branch 'master' of 'gitclone' into 'svn'

The following changes have been merged:

commit e2291bde44a282a133894b0db350aeb0b92a87db
Author: Mladen Banovic <mladenbanovic2705@…>
Date: Fri Jul 8 10:15:51 2016 +0200

Add methods getNumLiveVar and getNumDir in adtl.h, change counter type in FOR_I_EQ_0_LT_NUMDIR macro to size_t (instead of int). Update chunk size of BOOST pool in adouble_tl.cpp according to adouble::numDir.

commit 2ffb294465b973bfd4bf1f73d84478f8233c0d2f
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Jun 23 12:32:14 2016 +0200

implement missing ref_eq_mult_p und ref_eq_min_p in ho_rev.c

somehow these were left out when parameters were being implemented.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 8cf0e5c1bd36f1dcf3be72cd67de631b2e1d0ee6
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Jun 23 12:31:04 2016 +0200

make sure the result is the last locint written in trace for each operation

since we're trying to generate ascii traces in the future, we'll need this
convention that the last location is the result, and previous locations
are arguments. This has been the case for almost all operations anyway
except for a few new one's that I wrote without keeping this in mind.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 9ae0ff220f37463f2ed85cafc8a626c24e472f2f
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Tue Jun 21 14:16:27 2016 +0200

on some compilers newer boost interferes with AC_FUNC_MALLOC test

so do AC_FUNC_MALLOC and AC_FUNC_REALLOC as usual and check for boost
library later.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit b746f620772cc8cce53e8f350adc6281279caf72
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Jun 20 15:32:22 2016 +0200

make Klaus Röbenack's name UTF-8 instead of ISO-8859-1

These are the only places where we're not simple ASCII or UTF-8 already

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 1171aa3961b5eb46a5d2ee64751c02a393a8a6f5
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Jun 17 10:42:39 2016 +0200

correct short_ref document about include file

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 2c6b2aac2ef04431ece2c6ff80e574aa2e58814b
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Jun 17 10:40:34 2016 +0200

correct error message to new semantics

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 506cde73451740bf0a15eff7d4abb158ee719ab0
Author: mflehmig <martin.flehmig@…>
Date: Fri Jun 17 10:14:26 2016 +0200

Fixed include of ADOL-C header.

ADOL-C header was included in old fashion (without adolc directory) for this example.

commit 2a023d3281d3d6d9824bad724a5768e3ee2fff94
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Jun 16 13:50:39 2016 +0200

Try to use boost::pool for allocating advals in traceless vector mode

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 80f1e2019ac1faab96fe06f3e9da47efcc1bcd23
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon May 23 15:13:22 2016 +0200

correct a reference in doc and rebuild

commit d7ab5283afe58bacb2e8739d72ede4e17f4c8081
Author: Mladen Banovic <mladenbanovic2705@…>
Date: Fri May 20 16:42:13 2016 +0200

Update section 7 of adolc-manual related to the Traceless forward differentiation.

commit bedb8e36f959c5272e4610fe504acc83208e5e9d
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Tue May 17 16:09:36 2016 +0200

macro name correction

commit 92ff596a0331776901df7f172ca347572e3daafd
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Tue May 17 15:56:17 2016 +0200

Add a warning about using static build of ADOL-C

static build of ADOL-C does not call constructors
for internal global objects, thereby causing
segmentation faults.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

File size: 17.3 KB
Line 
1/*----------------------------------------------------------------------------
2 ADOL-C -- Automatic Differentiation by Overloading in C++
3 File:     param.cpp
4 Revision: $Id$
5 Contents: class for parameter dependent functions
6 
7 Copyright (c) Kshitij Kulshreshtha
8
9 This file is part of ADOL-C. This software is provided as open source.
10 Any use, reproduction, or distribution of the software constitutes
11 recipient's acceptance of the terms of the accompanying license file.
12
13----------------------------------------------------------------------------*/
14
15
16#include "oplate.h"
17#include "taping_p.h"
18#include "dvlparms.h"
19#include <adolc/adouble.h>
20
21#include <limits>
22
23pdouble::pdouble(double pval) {
24    ADOLC_OPENMP_THREAD_NUMBER;
25    ADOLC_OPENMP_GET_THREAD_NUMBER;
26
27    _val = pval;
28    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
29        _idx = ADOLC_GLOBAL_TAPE_VARS.paramStoreMgrPtr->next_loc();
30        ADOLC_GLOBAL_TAPE_VARS.pStore[_idx] = _val;
31    } else {
32        _idx = std::numeric_limits<locint>::max();
33    }
34}
35
36pdouble::pdouble(locint idx) {
37    ADOLC_OPENMP_THREAD_NUMBER;
38    ADOLC_OPENMP_GET_THREAD_NUMBER;
39   
40    if (idx < ADOLC_GLOBAL_TAPE_VARS.numparam) {
41        _val = ADOLC_GLOBAL_TAPE_VARS.pStore[idx];
42        _idx = idx;
43    } else {
44        fprintf(DIAG_OUT, "ADOL-C error: Parameter index %d out of bounds, "
45                "# existing parameters = %zu\n", idx, 
46                ADOLC_GLOBAL_TAPE_VARS.numparam);
47        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
48    }
49}
50
51pdouble mkparam(double pval) {
52    locint _idx;
53    ADOLC_OPENMP_THREAD_NUMBER;
54    ADOLC_OPENMP_GET_THREAD_NUMBER;
55
56    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
57        _idx = ADOLC_GLOBAL_TAPE_VARS.paramStoreMgrPtr->next_loc();
58        ADOLC_GLOBAL_TAPE_VARS.pStore[_idx] = pval;
59    } else {
60        return pval;
61    }
62    return _idx;
63}
64
65pdouble getparam(locint index) {
66    return index;
67}
68
69locint mkparam_idx(double pval) {
70    locint _idx;
71    ADOLC_OPENMP_THREAD_NUMBER;
72    ADOLC_OPENMP_GET_THREAD_NUMBER;
73    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
74        _idx = ADOLC_GLOBAL_TAPE_VARS.paramStoreMgrPtr->next_loc();
75        ADOLC_GLOBAL_TAPE_VARS.pStore[_idx] = pval;
76    } else {
77        fprintf(DIAG_OUT, "ADOL-C error: cannot define indexed parameter "
78                "while tracing is turned off!\n");
79        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
80    }
81    return _idx;
82}
83
84pdouble::operator adub() const {
85    locint location;
86    ADOLC_OPENMP_THREAD_NUMBER;
87    ADOLC_OPENMP_GET_THREAD_NUMBER;
88
89    location = next_loc();
90    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
91        put_op(assign_p);
92        ADOLC_PUT_LOCINT(_idx);
93        ADOLC_PUT_LOCINT(location);
94
95        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
96        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
97            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[location]);
98    }
99    ADOLC_GLOBAL_TAPE_VARS.store[location] = _val;
100    return location;
101}
102
103badouble& badouble::operator = (const pdouble& p) {
104    locint loc;
105    ADOLC_OPENMP_THREAD_NUMBER;
106    ADOLC_OPENMP_GET_THREAD_NUMBER;
107
108    loc = this->loc();
109    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
110        put_op(assign_p);
111        ADOLC_PUT_LOCINT(loc);
112        ADOLC_PUT_LOCINT(p._idx);
113
114        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
115        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
116            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[loc]);
117    }
118    ADOLC_GLOBAL_TAPE_VARS.store[loc] = p._val;
119    return *this;
120}
121
122adouble& adouble::operator = (const pdouble& p) {
123    this->loc();
124    (*this).badouble::operator=(p);
125    return (*this);
126}
127
128adubref& adubref::operator = (const pdouble& p) {
129    ADOLC_OPENMP_THREAD_NUMBER;
130    ADOLC_OPENMP_GET_THREAD_NUMBER;
131    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
132        put_op(ref_assign_p);
133        ADOLC_PUT_LOCINT(location);
134        ADOLC_PUT_LOCINT(p._idx);
135       
136        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
137        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
138            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[refloc]);
139    }
140    ADOLC_GLOBAL_TAPE_VARS.store[refloc] = p._val;
141    return *this;
142}
143
144badouble& badouble::operator += (const pdouble& p) {
145    locint loc;
146    ADOLC_OPENMP_THREAD_NUMBER;
147    ADOLC_OPENMP_GET_THREAD_NUMBER;
148
149    loc = this->loc();
150    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
151        put_op(eq_plus_p);
152        ADOLC_PUT_LOCINT(p._idx);
153        ADOLC_PUT_LOCINT(loc);
154       
155        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
156        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
157            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[loc]);
158    }
159
160    ADOLC_GLOBAL_TAPE_VARS.store[loc] += p._val;
161    return *this;   
162}
163
164adubref& adubref::operator += (const pdouble& p) {
165    ADOLC_OPENMP_THREAD_NUMBER;
166    ADOLC_OPENMP_GET_THREAD_NUMBER;
167
168    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
169        put_op(ref_eq_plus_p);
170        ADOLC_PUT_LOCINT(p._idx);
171        ADOLC_PUT_LOCINT(location);
172
173        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
174        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
175            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[refloc]);
176    }
177
178    ADOLC_GLOBAL_TAPE_VARS.store[refloc] += p._val;
179    return *this;
180}
181
182badouble& badouble::operator -= (const pdouble& p) {
183    ADOLC_OPENMP_THREAD_NUMBER;
184    ADOLC_OPENMP_GET_THREAD_NUMBER;
185    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) { // old: write_d_same_arg(eq_min_d,loc(),coval);
186        put_op(eq_min_p);
187        ADOLC_PUT_LOCINT(p._idx);
188        ADOLC_PUT_LOCINT(loc());
189
190        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
191        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
192            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[loc()]);
193    }
194
195    ADOLC_GLOBAL_TAPE_VARS.store[loc()] -= p._val;
196    return *this;
197}
198
199adubref& adubref::operator -= (const pdouble& p) {
200    ADOLC_OPENMP_THREAD_NUMBER;
201    ADOLC_OPENMP_GET_THREAD_NUMBER;
202    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) { // old: write_d_same_arg(eq_min_d,location,coval);
203        put_op(ref_eq_min_p);
204        ADOLC_PUT_LOCINT(p._idx);
205        ADOLC_PUT_LOCINT(location);
206
207        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
208        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
209            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[refloc]);
210    }
211
212    ADOLC_GLOBAL_TAPE_VARS.store[refloc] -= p._val;
213    return *this;
214}
215
216badouble& badouble::operator *= (const pdouble& p) {
217    ADOLC_OPENMP_THREAD_NUMBER;
218    ADOLC_OPENMP_GET_THREAD_NUMBER;
219    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) { // old: write_d_same_arg(eq_mult_d,loc(),coval);
220        put_op(eq_mult_p);
221        ADOLC_PUT_LOCINT(p._idx);       // = coval
222        ADOLC_PUT_LOCINT(loc()); // = res
223
224        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
225        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
226            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[loc()]);
227    }
228
229    ADOLC_GLOBAL_TAPE_VARS.store[loc()] *= p._val;
230    return *this;
231}
232
233adubref& adubref::operator *= (const pdouble& p) {
234    ADOLC_OPENMP_THREAD_NUMBER;
235    ADOLC_OPENMP_GET_THREAD_NUMBER;
236    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) { // old: write_d_same_arg(eq_mult_d,location,coval);
237        put_op(ref_eq_mult_p);
238        ADOLC_PUT_LOCINT(p._idx);
239        ADOLC_PUT_LOCINT(location);
240
241        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
242        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
243            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[refloc]);
244    }
245
246    ADOLC_GLOBAL_TAPE_VARS.store[refloc] *= p._val;
247    return *this;
248}
249
250adub operator + (const badouble& a, const pdouble& p) {
251    ADOLC_OPENMP_THREAD_NUMBER;
252    ADOLC_OPENMP_GET_THREAD_NUMBER;
253    locint locat = next_loc();
254
255    /* olvo 980708 test coval to be zero */
256    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) { // old: write_args_d_a(plus_d_a,locat,coval,y.loc());
257        put_op(plus_a_p);
258        ADOLC_PUT_LOCINT(a.loc());
259        ADOLC_PUT_LOCINT(locat);
260        ADOLC_PUT_LOCINT(p._idx);
261
262        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
263        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
264            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
265    }
266   
267    ADOLC_GLOBAL_TAPE_VARS.store[locat] = ADOLC_GLOBAL_TAPE_VARS.store[a.loc()] + p._val;
268    return locat;
269}
270
271adub operator - (const badouble& a, const pdouble& p) {
272    ADOLC_OPENMP_THREAD_NUMBER;
273    ADOLC_OPENMP_GET_THREAD_NUMBER;
274    locint locat = next_loc();
275
276    /* olvo 980708 test coval to be zero */
277    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) { // old: write_args_d_a(plus_d_a,locat,coval,y.loc());
278        put_op(min_a_p);
279        ADOLC_PUT_LOCINT(a.loc());
280        ADOLC_PUT_LOCINT(p._idx);
281        ADOLC_PUT_LOCINT(locat);
282
283        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
284        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
285            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
286    }
287   
288    ADOLC_GLOBAL_TAPE_VARS.store[locat] = ADOLC_GLOBAL_TAPE_VARS.store[a.loc()] - p._val;
289    return locat;
290}
291
292adub operator * (const badouble& a, const pdouble& p) {
293    ADOLC_OPENMP_THREAD_NUMBER;
294    ADOLC_OPENMP_GET_THREAD_NUMBER;
295    locint locat = next_loc();
296
297    /* olvo 980708 test coval to be zero */
298    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) { // old: write_args_d_a(plus_d_a,locat,coval,y.loc());
299        put_op(mult_a_p);
300        ADOLC_PUT_LOCINT(a.loc());
301        ADOLC_PUT_LOCINT(p._idx);
302        ADOLC_PUT_LOCINT(locat);
303
304        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
305        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
306            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
307    }
308   
309    ADOLC_GLOBAL_TAPE_VARS.store[locat] = ADOLC_GLOBAL_TAPE_VARS.store[a.loc()] * p._val;
310    return locat;
311}
312
313adub operator / (const pdouble& p, const badouble& a) {
314    ADOLC_OPENMP_THREAD_NUMBER;
315    ADOLC_OPENMP_GET_THREAD_NUMBER;
316    locint locat = next_loc();
317
318    /* olvo 980708 test coval to be zero */
319    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) { // old: write_args_d_a(plus_d_a,locat,coval,y.loc());
320        put_op(div_p_a);
321        ADOLC_PUT_LOCINT(a.loc());
322        ADOLC_PUT_LOCINT(p._idx);
323        ADOLC_PUT_LOCINT(locat);
324
325        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
326        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
327            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
328    }
329   
330    ADOLC_GLOBAL_TAPE_VARS.store[locat] = p._val/ADOLC_GLOBAL_TAPE_VARS.store[a.loc()];
331    return locat;   
332}
333
334adub pow( const badouble& x, const pdouble& p) {
335    ADOLC_OPENMP_THREAD_NUMBER;
336    ADOLC_OPENMP_GET_THREAD_NUMBER;
337    locint locat = next_loc();
338
339    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) { // old: write_args_d_a(pow_op,locat,cocval,x.loc());
340        put_op(pow_op_p);
341        ADOLC_PUT_LOCINT(x.loc()); // = arg
342        ADOLC_PUT_LOCINT(p._idx);         // = coval
343        ADOLC_PUT_LOCINT(locat);      // = res
344
345        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
346        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
347            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
348    }
349
350    ADOLC_GLOBAL_TAPE_VARS.store[locat] =
351        ADOLC_MATH_NSP::pow(ADOLC_GLOBAL_TAPE_VARS.store[x.loc()],p._val);
352    ADOLC_OPENMP_RESTORE_THREAD_NUMBER;
353    return locat;
354}
355adub recipr( const pdouble& p) {
356    locint location;
357    ADOLC_OPENMP_THREAD_NUMBER;
358    ADOLC_OPENMP_GET_THREAD_NUMBER;
359
360    location = next_loc();
361    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
362        put_op(recipr_p);
363        ADOLC_PUT_LOCINT(location);
364        ADOLC_PUT_LOCINT(p._idx);
365
366        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
367        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
368            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[location]);
369    }
370    ADOLC_GLOBAL_TAPE_VARS.store[location] = 1.0/p._val;
371    return location;
372}
373
374adub operator - (const pdouble& p) {
375    locint location;
376    ADOLC_OPENMP_THREAD_NUMBER;
377    ADOLC_OPENMP_GET_THREAD_NUMBER;
378
379    location = next_loc();
380    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
381        put_op(neg_sign_p);
382        ADOLC_PUT_LOCINT(location);
383        ADOLC_PUT_LOCINT(p._idx);
384
385        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
386        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
387            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[location]);
388    }
389    ADOLC_GLOBAL_TAPE_VARS.store[location] = -p._val;
390    return location;
391}
392
393adouble pow( const pdouble& p, const badouble& y) {
394    adouble a1, a2, ret;
395    double vx = p._val;
396    double vy = y.getValue();
397    if (!(vx > 0)) { 
398        if (vx < 0 || vy >= 0)
399            fprintf(DIAG_OUT,"\nADOL-C message: exponent of zero/negative basis deactivated\n");
400        else
401            fprintf(DIAG_OUT,"\nADOL-C message: negative exponent and zero basis deactivated\n");
402    }
403    condassign(a1, -y, (adouble) ADOLC_MATH_NSP::pow(vx,vy), pow(p,vy));
404    condassign(a2, fabs(adub(p)), pow(p, vy), a1);
405    condassign(ret, p, exp(y*log(adub(p))),a2);
406
407    return ret;
408}
409
410#if defined(ADOLC_ADVANCED_BRANCHING)
411adub operator != (const badouble& x, const pdouble& y) {
412    ADOLC_OPENMP_THREAD_NUMBER;
413    ADOLC_OPENMP_GET_THREAD_NUMBER;
414    double xval = ADOLC_GLOBAL_TAPE_VARS.store[x.loc()];
415    double yval = y._val;
416    double res = (double)(xval != yval);
417    locint locat = next_loc();
418    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
419        put_op(neq_a_p);
420        ADOLC_PUT_LOCINT(x.loc()); // arg
421        ADOLC_PUT_LOCINT(y._idx); // arg1
422        ADOLC_PUT_VAL(res);           // check for branch switch
423        ADOLC_PUT_LOCINT(locat);      // res
424
425        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
426        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
427            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
428    }
429    ADOLC_GLOBAL_TAPE_VARS.store[locat] = res;
430    return locat;
431}
432/*--------------------------------------------------------------------------*/
433adub operator == (const badouble& x, const pdouble& y) {
434    ADOLC_OPENMP_THREAD_NUMBER;
435    ADOLC_OPENMP_GET_THREAD_NUMBER;
436    double xval = ADOLC_GLOBAL_TAPE_VARS.store[x.loc()];
437    double yval = y._val;
438    double res = (double)(xval == yval);
439    locint locat = next_loc();
440    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
441        put_op(eq_a_p);
442        ADOLC_PUT_LOCINT(x.loc()); // arg
443        ADOLC_PUT_LOCINT(y._idx); // arg1
444        ADOLC_PUT_VAL(res);           // check for branch switch
445        ADOLC_PUT_LOCINT(locat);      // res
446
447        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
448        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
449            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
450    }
451    ADOLC_GLOBAL_TAPE_VARS.store[locat] = res;
452    return locat;
453}
454/*--------------------------------------------------------------------------*/
455adub operator <= (const badouble& x, const pdouble& y) {
456    ADOLC_OPENMP_THREAD_NUMBER;
457    ADOLC_OPENMP_GET_THREAD_NUMBER;
458    double xval = ADOLC_GLOBAL_TAPE_VARS.store[x.loc()];
459    double yval = y._val;
460    double res = (double)(xval <= yval);
461    locint locat = next_loc();
462    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
463        put_op(le_a_p);
464        ADOLC_PUT_LOCINT(x.loc()); // arg
465        ADOLC_PUT_LOCINT(y._idx); // arg1
466        ADOLC_PUT_VAL(res);           // check for branch switch
467        ADOLC_PUT_LOCINT(locat);      // res
468
469        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
470        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
471            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
472    }
473    ADOLC_GLOBAL_TAPE_VARS.store[locat] = res;
474    return locat;
475}
476/*--------------------------------------------------------------------------*/
477adub operator >= (const badouble& x, const pdouble& y) {
478    ADOLC_OPENMP_THREAD_NUMBER;
479    ADOLC_OPENMP_GET_THREAD_NUMBER;
480    double xval = ADOLC_GLOBAL_TAPE_VARS.store[x.loc()];
481    double yval = y._val;
482    double res = (double)(xval >= yval);
483    locint locat = next_loc();
484    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
485        put_op(ge_a_p);
486        ADOLC_PUT_LOCINT(x.loc()); // arg
487        ADOLC_PUT_LOCINT(y._idx); // arg1
488        ADOLC_PUT_VAL(res);           // check for branch switch
489        ADOLC_PUT_LOCINT(locat);      // res
490
491        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
492        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
493            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
494    }
495    ADOLC_GLOBAL_TAPE_VARS.store[locat] = res;
496    return locat;
497}
498/*--------------------------------------------------------------------------*/
499adub operator > (const badouble& x, const pdouble& y) {
500    ADOLC_OPENMP_THREAD_NUMBER;
501    ADOLC_OPENMP_GET_THREAD_NUMBER;
502    double xval = ADOLC_GLOBAL_TAPE_VARS.store[x.loc()];
503    double yval = y._val;
504    double res = (double)(xval > yval);
505    locint locat = next_loc();
506    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
507        put_op(gt_a_p);
508        ADOLC_PUT_LOCINT(x.loc()); // arg
509        ADOLC_PUT_LOCINT(y._idx); // arg1
510        ADOLC_PUT_VAL(res);           // check for branch switch
511        ADOLC_PUT_LOCINT(locat);      // res
512
513        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
514        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
515            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
516    }
517    ADOLC_GLOBAL_TAPE_VARS.store[locat] = res;
518    return locat;
519}
520/*--------------------------------------------------------------------------*/
521adub operator < (const badouble& x, const pdouble& y) {
522    ADOLC_OPENMP_THREAD_NUMBER;
523    ADOLC_OPENMP_GET_THREAD_NUMBER;
524    double xval = ADOLC_GLOBAL_TAPE_VARS.store[x.loc()];
525    double yval = y._val;
526    double res = (double)(xval < yval);
527    locint locat = next_loc();
528    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
529        put_op(lt_a_p);
530        ADOLC_PUT_LOCINT(x.loc()); // arg
531        ADOLC_PUT_LOCINT(y._idx); // arg1
532        ADOLC_PUT_VAL(res);           // check for branch switch
533        ADOLC_PUT_LOCINT(locat);      // res
534
535        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
536        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors)
537            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
538    }
539    ADOLC_GLOBAL_TAPE_VARS.store[locat] = res;
540    return locat;
541}
542#endif
Note: See TracBrowser for help on using the repository browser.