Sacado Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
test
performance
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
32
using
std::sin;
33
34
template
<
typename
T>
35
void
ExprFuncs::mult<T,1>::operator()
(
const
T
x[],
T
& y)
const
{
36
y =
37
x[0]*x[1];
38
}
39
40
template
<
typename
T>
41
void
ExprFuncs::mult<T,2>::operator()
(
const
T
x[],
T
& y)
const
{
42
y =
43
x[0]*x[1]*x[2];
44
}
45
46
template
<
typename
T>
47
void
ExprFuncs::mult<T,3>::operator()
(
const
T
x[],
T
& y)
const
{
48
y =
49
x[0]*x[1]*x[2]*x[3];
50
}
51
52
template
<
typename
T>
53
void
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
58
template
<
typename
T>
59
void
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
64
template
<
typename
T>
65
void
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
71
template
<
typename
T>
72
void
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
78
template
<
typename
T>
79
void
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
86
template
<
typename
T>
87
void
ExprFuncs::nest<T,1>::operator()
(
const
T
x[],
T
& y)
const
{
88
y =
sin
(x[0]);
89
}
90
91
template
<
typename
T>
92
void
ExprFuncs::nest<T,2>::operator()
(
const
T
x[],
T
& y)
const
{
93
y =
sin
(
sin
(x[0]));
94
}
95
96
template
<
typename
T>
97
void
ExprFuncs::nest<T,3>::operator()
(
const
T
x[],
T
& y)
const
{
98
y =
sin
(
sin
(
sin
(x[0])));
99
}
100
101
template
<
typename
T>
102
void
ExprFuncs::nest<T,4>::operator()
(
const
T
x[],
T
& y)
const
{
103
y =
sin
(
sin
(
sin
(
sin
(x[0]))));
104
}
105
106
template
<
typename
T>
107
void
ExprFuncs::nest<T,5>::operator()
(
const
T
x[],
T
& y)
const
{
108
y =
sin
(
sin
(
sin
(
sin
(
sin
(x[0])))));
109
}
110
111
template
<
typename
T>
112
void
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
117
template
<
typename
T>
118
void
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
124
template
<
typename
T>
125
void
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
132
template
<
typename
T>
133
void
ExprFuncs::add<T,1>::operator()
(
const
T
x[],
T
& y)
const
{
134
y =
135
x[0]+x[1];
136
}
137
138
template
<
typename
T>
139
void
ExprFuncs::add<T,2>::operator()
(
const
T
x[],
T
& y)
const
{
140
y =
141
x[0]+x[1]+x[2];
142
}
143
144
template
<
typename
T>
145
void
ExprFuncs::add<T,3>::operator()
(
const
T
x[],
T
& y)
const
{
146
y =
147
x[0]+x[1]+x[2]+x[3];
148
}
149
150
template
<
typename
T>
151
void
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
156
template
<
typename
T>
157
void
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
162
template
<
typename
T>
163
void
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
169
template
<
typename
T>
170
void
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
176
template
<
typename
T>
177
void
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
184
const
char
*
ExprFuncs::mult_names
[
ExprFuncs::nfunc
] = {
185
"mult1"
,
186
"mult2"
,
187
"mult3"
,
188
"mult4"
,
189
"mult5"
,
190
"mult10"
,
191
"mult15"
,
192
"mult20"
193
};
194
195
const
char
*
ExprFuncs::nest_names
[
ExprFuncs::nfunc
] = {
196
"nest1"
,
197
"nest2"
,
198
"nest3"
,
199
"nest4"
,
200
"nest5"
,
201
"nest10"
,
202
"nest15"
,
203
"nest20"
204
};
205
206
const
char
*
ExprFuncs::add_names
[
ExprFuncs::nfunc
] = {
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
245
INSTANTIATE_FUNCS
(
double
)
246
INSTANTIATE_FUNCS
(
Sacado::Fad::DFad<double>
)
247
INSTANTIATE_FUNCS
(
Sacado::ELRFad::DFad<double>
)
248
INSTANTIATE_FUNCS
(
Sacado::CacheFad::DFad<double>
)
249
INSTANTIATE_FUNCS
(
Sacado::ELRCacheFad::DFad<double>
)
250
INSTANTIATE_FUNCS
(
Sacado::Fad::SimpleFad<double>
)
251
#ifdef HAVE_ADOLC
252
INSTANTIATE_FUNCS
(adouble)
253
#endif
254
255
#undef INSTANTIATE_FUNCS
sin
sin(expr.val())
T
#define T
Definition
Sacado_rad.hpp:573
Sacado::CacheFad::DFad
Definition
Sacado_CacheFad_DFadTraits.hpp:57
Sacado::ELRCacheFad::DFad
Definition
Sacado_ELRCacheFad_DFadTraits.hpp:57
Sacado::ELRFad::DFad
Definition
Sacado_ELRFad_DFadTraits.hpp:57
Sacado::Fad::DFad
Definition
Sacado_Fad_DFadTraits.hpp:65
Sacado::Fad::SimpleFad
Forward-mode AD class using dynamic memory allocation but no expression templates.
Definition
Sacado_Fad_SimpleFad.hpp:52
INSTANTIATE_FUNCS
#define INSTANTIATE_FUNCS(TYPE)
Definition
fad_expr_funcs.cpp:217
fad_expr_funcs.hpp
ExprFuncs::add
Definition
fad_expr_funcs.hpp:77
ExprFuncs::mult
Definition
fad_expr_funcs.hpp:74
ExprFuncs::nest
Definition
fad_expr_funcs.hpp:80
ExprFuncs::nfunc
static const int nfunc
Definition
fad_expr_funcs.hpp:68
ExprFuncs::nest_names
static const char * nest_names[nfunc]
Definition
fad_expr_funcs.hpp:195
ExprFuncs::add_names
static const char * add_names[nfunc]
Definition
fad_expr_funcs.hpp:206
ExprFuncs::mult_names
static const char * mult_names[nfunc]
Definition
fad_expr_funcs.hpp:184
Generated by
1.17.0