Sacado Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
fad_expr_funcs.cpp
Go to the documentation of this file.
1// @HEADER
2// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3//
4// Sacado Package
5// Copyright (2006) Sandia Corporation
6//
7// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8// the U.S. Government retains certain rights in this software.
9//
10// This library is free software]; you can redistribute it and/or modify
11// it under the terms of the GNU Lesser General Public License as
12// published by the Free Software Foundation]; either version 2.1 of the
13// License, or (at your option) any later version.
14//
15// This library is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY]; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18// Lesser General Public License for more details.
19//
20// You should have received a copy of the GNU Lesser General Public
21// License along with this library]; if not, write to the Free Software
22// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23// USA
24// Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
25// (etphipp@sandia.gov).
26//
27// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
28// @HEADER
29
30#include "fad_expr_funcs.hpp"
31
32using std::sin;
33
34template <typename T>
35void ExprFuncs::mult<T,1>::operator()(const T x[], T& y) const {
36 y =
37 x[0]*x[1];
38}
39
40template <typename T>
41void ExprFuncs::mult<T,2>::operator()(const T x[], T& y) const {
42 y =
43 x[0]*x[1]*x[2];
44}
45
46template <typename T>
47void ExprFuncs::mult<T,3>::operator()(const T x[], T& y) const {
48 y =
49 x[0]*x[1]*x[2]*x[3];
50}
51
52template <typename T>
53void ExprFuncs::mult<T,4>::operator()(const T x[], T& y) const {
54 y =
55 x[0]*x[1]*x[2]*x[3]*x[4];
56}
57
58template <typename T>
59void ExprFuncs::mult<T,5>::operator()(const T x[], T& y) const {
60 y =
61 x[0]*x[1]*x[2]*x[3]*x[4]*x[5];
62}
63
64template <typename T>
65void ExprFuncs::mult<T,10>::operator()(const T x[], T& y) const {
66 y =
67 x[0]*x[1]*x[2]*x[3]*x[4]*x[5]*x[6]*x[7]*
68 x[8]*x[9]*x[10];
69}
70
71template <typename T>
72void ExprFuncs::mult<T,15>::operator()(const T x[], T& y) const {
73 y =
74 x[0]*x[1]*x[2]*x[3]*x[4]*x[5]*x[6]*x[7]*
75 x[8]*x[9]*x[10]*x[11]*x[12]*x[13]*x[14]*x[15];
76}
77
78template <typename T>
79void ExprFuncs::mult<T,20>::operator()(const T x[], T& y) const {
80 y =
81 x[0]*x[1]*x[2]*x[3]*x[4]*x[5]*x[6]*x[7]*
82 x[8]*x[9]*x[10]*x[11]*x[12]*x[13]*x[14]*x[15]*
83 x[16]*x[17]*x[18]*x[19]* x[20];
84}
85
86template <typename T>
87void ExprFuncs::nest<T,1>::operator()(const T x[], T& y) const {
88 y = sin(x[0]);
89}
90
91template <typename T>
92void ExprFuncs::nest<T,2>::operator()(const T x[], T& y) const {
93 y = sin(sin(x[0]));
94}
95
96template <typename T>
97void ExprFuncs::nest<T,3>::operator()(const T x[], T& y) const {
98 y = sin(sin(sin(x[0])));
99}
100
101template <typename T>
102void ExprFuncs::nest<T,4>::operator()(const T x[], T& y) const {
103 y = sin(sin(sin(sin(x[0]))));
104}
105
106template <typename T>
107void ExprFuncs::nest<T,5>::operator()(const T x[], T& y) const {
108 y = sin(sin(sin(sin(sin(x[0])))));
109}
110
111template <typename T>
112void ExprFuncs::nest<T,10>::operator()(const T x[], T& y) const {
113 y = sin(sin(sin(sin(sin(
114 sin(sin(sin(sin(sin(x[0]))))))))));
115}
116
117template <typename T>
118void ExprFuncs::nest<T,15>::operator()(const T x[], T& y) const {
119 y = sin(sin(sin(sin(sin(
120 sin(sin(sin(sin(sin(
121 sin(sin(sin(sin(sin(x[0])))))))))))))));
122}
123
124template <typename T>
125void ExprFuncs::nest<T,20>::operator()(const T x[], T& y) const {
126 y = sin(sin(sin(sin(sin(
127 sin(sin(sin(sin(sin(
128 sin(sin(sin(sin(sin(
129 sin(sin(sin(sin(sin(x[0]))))))))))))))))))));
130}
131
132template <typename T>
133void ExprFuncs::add<T,1>::operator()(const T x[], T& y) const {
134 y =
135 x[0]+x[1];
136}
137
138template <typename T>
139void ExprFuncs::add<T,2>::operator()(const T x[], T& y) const {
140 y =
141 x[0]+x[1]+x[2];
142}
143
144template <typename T>
145void ExprFuncs::add<T,3>::operator()(const T x[], T& y) const {
146 y =
147 x[0]+x[1]+x[2]+x[3];
148}
149
150template <typename T>
151void ExprFuncs::add<T,4>::operator()(const T x[], T& y) const {
152 y =
153 x[0]+x[1]+x[2]+x[3]+x[4];
154}
155
156template <typename T>
157void ExprFuncs::add<T,5>::operator()(const T x[], T& y) const {
158 y =
159 x[0]+x[1]+x[2]+x[3]+x[4]+x[5];
160}
161
162template <typename T>
163void ExprFuncs::add<T,10>::operator()(const T x[], T& y) const {
164 y =
165 x[0]+x[1]+x[2]+x[3]+x[4]+x[5]+x[6]+x[7]+
166 x[8]+x[9]+x[10];
167}
168
169template <typename T>
170void ExprFuncs::add<T,15>::operator()(const T x[], T& y) const {
171 y =
172 x[0]+x[1]+x[2]+x[3]+x[4]+x[5]+x[6]+x[7]+
173 x[8]+x[9]+x[10]+x[11]+x[12]+x[13]+x[14]+x[15];
174}
175
176template <typename T>
177void ExprFuncs::add<T,20>::operator()(const T x[], T& y) const {
178 y =
179 x[0]+x[1]+x[2]+x[3]+x[4]+x[5]+x[6]+x[7]+
180 x[8]+x[9]+x[10]+x[11]+x[12]+x[13]+x[14]+x[15]+
181 x[16]+x[17]+x[18]+x[19]+x[20];
182}
183
185 "mult1",
186 "mult2",
187 "mult3",
188 "mult4",
189 "mult5",
190 "mult10",
191 "mult15",
192 "mult20"
193};
194
196 "nest1",
197 "nest2",
198 "nest3",
199 "nest4",
200 "nest5",
201 "nest10",
202 "nest15",
203 "nest20"
204};
205
207 "add1",
208 "add2",
209 "add3",
210 "add4",
211 "add5",
212 "add10",
213 "add15",
214 "add20"
215};
216
217#define INSTANTIATE_FUNCS(TYPE) \
218 template struct ExprFuncs::mult< TYPE,1>; \
219 template struct ExprFuncs::mult< TYPE,2>; \
220 template struct ExprFuncs::mult< TYPE,3>; \
221 template struct ExprFuncs::mult< TYPE,4>; \
222 template struct ExprFuncs::mult< TYPE,5>; \
223 template struct ExprFuncs::mult< TYPE,10>; \
224 template struct ExprFuncs::mult< TYPE,15>; \
225 template struct ExprFuncs::mult< TYPE,20>; \
226 \
227 template struct ExprFuncs::nest< TYPE,1>; \
228 template struct ExprFuncs::nest< TYPE,2>; \
229 template struct ExprFuncs::nest< TYPE,3>; \
230 template struct ExprFuncs::nest< TYPE,4>; \
231 template struct ExprFuncs::nest< TYPE,5>; \
232 template struct ExprFuncs::nest< TYPE,10>; \
233 template struct ExprFuncs::nest< TYPE,15>; \
234 template struct ExprFuncs::nest< TYPE,20>; \
235 \
236 template struct ExprFuncs::add< TYPE,1>; \
237 template struct ExprFuncs::add< TYPE,2>; \
238 template struct ExprFuncs::add< TYPE,3>; \
239 template struct ExprFuncs::add< TYPE,4>; \
240 template struct ExprFuncs::add< TYPE,5>; \
241 template struct ExprFuncs::add< TYPE,10>; \
242 template struct ExprFuncs::add< TYPE,15>; \
243 template struct ExprFuncs::add< TYPE,20>;
244
245INSTANTIATE_FUNCS(double)
251#ifdef HAVE_ADOLC
252INSTANTIATE_FUNCS(adouble)
253#endif
254
255#undef INSTANTIATE_FUNCS
sin(expr.val())
#define T
Definition: Sacado_rad.hpp:573
Forward-mode AD class using dynamic memory allocation but no expression templates.
#define INSTANTIATE_FUNCS(TYPE)
const double y
static const int nfunc
static const char * nest_names[nfunc]
static const char * add_names[nfunc]
static const char * mult_names[nfunc]