source: trunk/ADOL-C/include/adolc/param.h @ 762

Last change on this file since 762 was 762, checked in by mbanovic, 5 months ago

Merged branch "medipacksupport" from "git" into "svn"

The following commits were merged:

commit 0d1b5eec2cca8afdeea3cdffa196efb6cfd60a53
Merge: 72d114b 33bfdb5
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Nov 5 10:03:04 2018 +0000

Merge branch 'medipackSupport' into 'medipacksupport'

Medipack support

See merge request adol-c/adol-c!26

commit 33bfdb5a006c782489bfef1b651ca3bdbceefaf2
Merge: ac55eab cf82982
Author: Max Sagebaum <max.sagebaum@…>
Date: Tue Oct 30 11:19:31 2018 +0100

Merge branch 'medipackSupport' into temp

commit ac55eab9dd8cb8c84926ee56456076392a047c1a
Merge: 72d114b caaac60
Author: Max Sagebaum <max.sagebaum@…>
Date: Tue Oct 30 11:14:09 2018 +0100

Merge remote-tracking branch 'origin/master' into temp

commit cf82982421aaa7d83405ffa3d0c9b6ef88251d0c
Merge: 6aeca20 caaac60
Author: Max Sagebaum <max.sagebaum@…>
Date: Tue Oct 30 11:13:25 2018 +0100

Merge remote-tracking branch 'origin/master' into medipackSupport

commit 6aeca205c2448b4bbc915eb76153ebde19448573
Author: Max Sagebaum <max.sagebaum@…>
Date: Tue Oct 23 22:30:28 2018 +0200

Added suport for ZOS, FOS, FOV forward and reverse.

commit caaac60da4c61b370d106c68064d38c42a7cb6e3
Merge: cc2e0b3 70fc288
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Oct 8 08:53:40 2018 +0000

Merge branch 'fix_adtl_hov_refcntr' into 'master'

Fix undefined reference to adtl_hov::refcounter::refcnt

See merge request adol-c/adol-c!24

commit 70fc288b9ab95b16d3179fcf239ee2208ae1a2c4
Author: Jean-Paul Pelteret <jppelteret@…>
Date: Mon Oct 1 20:53:03 2018 +0200

Fix undefined reference to adtl_hov::refcounter::refcnt

commit cc2e0b3154fb6e62580def4501c4cf3f3d8e32ef
Merge: d7400f5 7c7f24b
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Oct 1 12:26:39 2018 +0000

Merge branch 'docu' into 'master'

Refactor tapeless to traceless

See merge request adol-c/adol-c!23

commit ca397962cde23bde80e03924893e09c84d8728bf
Merge: 9cbc432 d7400f5
Author: Max Sagebaum <max.sagebaum@…>
Date: Fri Sep 28 10:07:41 2018 +0200

Merge remote-tracking branch 'origin/master' into medipackSupport

commit 9cbc4324e0d3e19f97ba5c5474121f0189e60f83
Author: Max Sagebaum <max.sagebaum@…>
Date: Thu Sep 27 14:38:30 2018 +0200

Missing MeDiPack? initialization on trace_on.

commit 76c30290365830d2370a354af949f3bf42df3885
Author: Max Sagebaum <max.sagebaum@…>
Date: Thu Sep 27 09:55:42 2018 +0200

Null pointer fix for initialization.

commit 7c7f24b25479870d58ff19d78a6e394ca28ddb58
Author: mflehmig <martin.schroschk@…>
Date: Thu Sep 20 13:16:06 2018 +0200

Refactor tapeless to traceless

As far as I can see, the official wording is traceless forward mode.
Additonally, the latex label and refs changed to 'traceless'.

commit 72d114b7ac42b8ac493030cedd1df8c9746ba5d4
Author: Max Sagebaum <max.sagebaum@…>
Date: Thu Oct 19 09:25:19 2017 +0200

Added support for MeDiPack? library.

Enable it with the configure options:
--enable-medipack --with-medipack=<path to MeDiPack?>

Tutorial on a how to use will follow.

commit b4ca76279d28407f29901d40953d02a0c5c9140e
Author: Max Sagebaum <max.sagebaum@…>
Date: Mon May 7 14:45:13 2018 +0200

Added support for cbrt function.

commit bc7b8ca61865058fac097410fd94a44fba281131
Author: Max Sagebaum <max.sagebaum@…>
Date: Thu Mar 1 10:31:18 2018 +0100

Changes for new interface.

commit cd1e82778c8540221b24559d5097bf6d00597e19
Author: Max Sagebaum <max.sagebaum@…>
Date: Thu Nov 16 14:31:07 2017 +0100

Changes to new MeDiPack? interface for adjoint values.

commit 55bcb0ffd5a9496817bffac0bd2c9489ed8ce992
Author: Max Sagebaum <max.sagebaum@…>
Date: Thu Oct 19 09:25:19 2017 +0200

Added support for MeDiPack? library.

Enable it with the configure options:
--enable-medipack --with-medipack=<path to MeDiPack?>

Tutorial on a how to use will follow.

File size: 7.9 KB
Line 
1/*----------------------------------------------------------------------------
2 ADOL-C -- Automatic Differentiation by Overloading in C++
3 File:     param.h
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#if !defined(ADOLC_PARAM_H)
16#define ADOLC_PARAM_H 1
17#if defined(__cplusplus)
18
19#include <cstdio>
20#include <stdexcept>
21
22using std::logic_error;
23
24class pdouble;
25
26ADOLC_DLL_EXPORT pdouble mkparam(double pval);
27ADOLC_DLL_EXPORT pdouble getparam(locint index);
28ADOLC_DLL_EXPORT locint mkparam_idx(double pval);
29
30class ADOLC_DLL_EXPORT pdouble {
31    friend ADOLC_DLL_EXPORT class badouble;
32    friend ADOLC_DLL_EXPORT class adub;
33    friend ADOLC_DLL_EXPORT class adouble;
34    friend ADOLC_DLL_EXPORT class adubref;
35protected:
36    double _val;
37    locint _idx;
38    pdouble(const pdouble&) {
39        fprintf(DIAG_OUT,"ADOL-C error: illegal copy construction of pdouble"
40                " variable\n          ... pdouble objects must never be copied\n");
41        throw logic_error("illegal constructor call, errorcode=-2");
42    }
43    pdouble(void) {
44        fprintf(DIAG_OUT,"ADOL-C error: illegal default construction of pdouble"
45                " variable\n");
46        throw logic_error("illegal constructor call, errorcode=-2");
47    }
48    pdouble(double pval);
49    pdouble(locint index);
50public:
51    friend pdouble mkparam(double pval);
52    friend pdouble getparam(locint index);
53    friend locint mkparam_idx(double pval);
54    operator adub() const;
55
56#define _IN_CLASS_ 1
57#define _IN_PDOUBLE_ 1
58#include <adolc/internal/paramfunc.h>
59#undef _IN_PDOUBLE_
60#undef _IN_CLASS_
61
62    ~pdouble() {}
63};
64
65#ifdef ADOLC_ADVANCED_BRANCHING
66inline adub operator != ( const pdouble& a, const badouble& b)
67{ return (b != a); }
68inline adub operator == ( const pdouble& a, const badouble& b)
69{ return (b == a); }
70inline adub operator <= ( const pdouble& a, const badouble& b)
71{ return (b >= a); }
72inline adub operator >= ( const pdouble& a, const badouble& b)
73{ return (b <= a); }
74inline adub operator >  ( const pdouble& a, const badouble& b)
75{ return (b < a); }
76inline adub operator <  ( const pdouble& a, const badouble& b)
77{ return (b > a); }
78#else
79inline int operator != ( const badouble& a, const pdouble& b) 
80{ return ((a - b) != 0); }
81inline int operator == ( const badouble& a, const pdouble& b) 
82{ return ((a - b) == 0); }
83inline int operator <= ( const badouble& a, const pdouble& b)
84{ return ((a - b) <= 0); }
85inline int operator >= ( const badouble& a, const pdouble& b)
86{ return ((a - b) >= 0); }
87inline int operator >  ( const badouble& a, const pdouble& b)
88{ return ((a - b) > 0); }
89inline int operator <  ( const badouble& a, const pdouble& b)
90{ return ((a - b) < 0); }
91inline int operator != ( const pdouble& a, const badouble& b)
92{ return (b != a); }
93inline int operator == ( const pdouble& a, const badouble& b)
94{ return (b == a); }
95inline int operator <= ( const pdouble& a, const badouble& b)
96{ return (b >= a); }
97inline int operator >= ( const pdouble& a, const badouble& b)
98{ return (b <= a); }
99inline int operator >  ( const pdouble& a, const badouble& b)
100{ return (b < a); }
101inline int operator <  ( const pdouble& a, const badouble& b)
102{ return (b > a); }
103#endif
104
105inline adub operator + ( const pdouble& a, const badouble& b)
106{ return (b + a); }
107
108inline adub operator + ( const pdouble& a, double b)
109{ return (b + adub(a)); }
110
111inline adub operator + ( double a, const pdouble& b)
112{ return (a + adub(b)); }
113
114inline adub operator - ( const pdouble& a, const badouble& b)
115{ return ((-b) + a); }
116
117inline adub operator - ( const pdouble& a, double b)
118{ return (adub(a) - b); }
119
120inline adub operator - ( double a, const pdouble& b)
121{ return (a + (-b)); }
122
123inline adub operator * ( const pdouble& a, const badouble& b)
124{ return (b*a); }
125
126inline adub operator * ( const pdouble& a, double b)
127{ return (b * adub(a)); }
128
129inline adub operator * ( double a, const pdouble& b)
130{ return (a * adub(b)); }
131
132inline adub operator / ( const badouble& a, const pdouble& b)
133{ return (a*recipr(b)); }
134
135inline adub operator / ( double a, const pdouble& b)
136{ return (a*recipr(b)); }
137
138inline adub operator / ( const pdouble& a, double b)
139{ return (adub(a)/b); }
140
141inline adub fmax ( const badouble& y, const pdouble& d ) {
142    return (-fmin(-d,-y));
143}
144
145inline adub fmax ( const pdouble& a, const badouble& b)
146{ return fmax(b,a); }
147
148inline adub fmin ( const pdouble& a, const badouble& b)
149{ return fmin(b,a); }
150
151inline adub fmin( const badouble& a, const pdouble& b)
152{ return fmin(a,adub(b)); }
153
154/* unary operators (friends) */
155inline adub exp  ( const pdouble& p)  { return exp(adub(p));   }
156inline adub log  ( const pdouble& p)  { return log(adub(p));   }
157inline adub sqrt ( const pdouble& p)  { return sqrt(adub(p));  }
158inline adub cbrt ( const pdouble& p)  { return cbrt(adub(p));  }
159inline adub sin  ( const pdouble& p)  { return sin(adub(p));   }
160inline adub cos  ( const pdouble& p)  { return cos(adub(p));   }
161inline adub tan  ( const pdouble& p)  { return tan(adub(p));   }
162inline adub asin ( const pdouble& p)  { return asin(adub(p));  }
163inline adub acos ( const pdouble& p)  { return acos(adub(p));  }
164inline adub atan ( const pdouble& p)  { return atan(adub(p));  }
165
166/*--------------------------------------------------------------------------*/
167/* special operators (friends) */
168/* no internal use of condassign: */
169inline adub    pow   ( const pdouble& p, double q) { return pow(adub(p),q); }
170inline adub    log10 ( const pdouble& p) { return log10(adub(p)); }
171
172/* Additional ANSI C standard Math functions Added by DWJ on 8/6/90 */
173inline adub sinh  ( const pdouble& p) { return sinh(adub(p)); }
174inline adub cosh  ( const pdouble& p) { return cosh(adub(p)); }
175inline adub tanh  ( const pdouble& p) { return tanh(adub(p)); }
176#if defined(ATRIG_ERF)
177inline adub asinh ( const pdouble& p) { return asinh(adub(p)); }
178inline adub acosh ( const pdouble& p) { return acosh(adub(p)); }
179inline adub atanh ( const pdouble& p) { return atanh(adub(p)); }
180inline adub erf   ( const pdouble& p) { return erf(adub(p));   }
181#endif
182
183inline adub fabs  ( const pdouble& p) { return fabs(adub(p));  }
184inline adub ceil  ( const pdouble& p) { return ceil(adub(p));  }
185inline adub floor ( const pdouble& p) { return floor(adub(p)); }
186
187inline adub fmax ( const pdouble& p, const pdouble& q) 
188{ return fmax(adub(p),adub(q)); }
189inline adub fmax ( double p, const pdouble& q)
190{ return fmax(p,adub(q)); }
191inline adub fmax ( const pdouble& p, double q)
192{ return fmax(adub(p),q); }
193inline adub fmin ( const pdouble& p, const pdouble& q)
194{ return fmin(adub(p),adub(q)); }
195inline adub fmin ( double p, const pdouble& q)
196{ return fmin(p,adub(q)); }
197inline adub fmin ( const pdouble& p, double q)
198{ return fmin(adub(p),q); }
199
200inline adub ldexp ( const pdouble& p, int n)
201{ return ldexp(adub(p),n); }
202inline adub frexp ( const pdouble& p, int* n)
203{ return frexp(adub(p),n); }
204
205/*--------------------------------------------------------------------------*/
206#endif
207
208BEGIN_C_DECLS
209
210/****************************************************************************/
211/* Returns the number of parameters recorded on tape                        */
212/****************************************************************************/
213ADOLC_DLL_EXPORT size_t get_num_param(short tag);
214
215/****************************************************************************/
216/* Overrides the parameters for the next evaluations. This will invalidate  */
217/* the taylor stack, so next reverse call will fail, if not preceeded by a  */
218/* forward call after setting the parameters.                               */
219/****************************************************************************/
220ADOLC_DLL_EXPORT void set_param_vec(short tag, size_t numparam, revreal* paramvec);
221
222END_C_DECLS
223#endif
Note: See TracBrowser for help on using the repository browser.