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

Last change on this file since 744 was 744, checked in by kulshres, 17 months ago

correct order of arguments on the location tape for parameters

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(p._idx);
112        ADOLC_PUT_LOCINT(loc);
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(p._idx);
134        ADOLC_PUT_LOCINT(location);
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(p._idx);
260        ADOLC_PUT_LOCINT(locat);
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(p._idx);
364        ADOLC_PUT_LOCINT(location);
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(p._idx);
383        ADOLC_PUT_LOCINT(location);
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.