Stokhos Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
src
sacado
kokkos
vector
Sacado_MP_Vector_SFS_ops.hpp
Go to the documentation of this file.
1
// @HEADER
2
// ***********************************************************************
3
//
4
// Stokhos Package
5
// Copyright (2009) Sandia Corporation
6
//
7
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8
// license for use of this work by or on behalf of the U.S. Government.
9
//
10
// Redistribution and use in source and binary forms, with or without
11
// modification, are permitted provided that the following conditions are
12
// met:
13
//
14
// 1. Redistributions of source code must retain the above copyright
15
// notice, this list of conditions and the following disclaimer.
16
//
17
// 2. Redistributions in binary form must reproduce the above copyright
18
// notice, this list of conditions and the following disclaimer in the
19
// documentation and/or other materials provided with the distribution.
20
//
21
// 3. Neither the name of the Corporation nor the names of the
22
// contributors may be used to endorse or promote products derived from
23
// this software without specific prior written permission.
24
//
25
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
//
37
// Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
38
//
39
// ***********************************************************************
40
// @HEADER
41
42
#include "Sacado_cmath.hpp"
43
#include <ostream>
// for std::ostream
44
45
#ifdef __CUDACC__
46
#include <cuda_runtime_api.h>
47
// including math functions via math_functions.h is deprecated in cuda version >= 10.0
48
// the deprecation warning indicates to use cuda_runtime_api.h instead
49
#if CUDART_VERSION < 10000
50
#include <math_functions.h>
51
#endif
52
#endif
53
54
#define OPNAME operator+
55
#define OPER +
56
#include "
Sacado_MP_Vector_SFS_unary_op_tmpl.hpp
"
57
#undef OPNAME
58
#undef OPER
59
60
#define OPNAME operator-
61
#define OPER -
62
#include "
Sacado_MP_Vector_SFS_unary_op_tmpl.hpp
"
63
#undef OPNAME
64
#undef OPER
65
66
#define OPNAME exp
67
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
68
#undef OPNAME
69
70
#define OPNAME log
71
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
72
#undef OPNAME
73
74
#define OPNAME log10
75
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
76
#undef OPNAME
77
78
#define OPNAME sqrt
79
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
80
#undef OPNAME
81
82
#define OPNAME cbrt
83
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
84
#undef OPNAME
85
86
#define OPNAME cos
87
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
88
#undef OPNAME
89
90
#define OPNAME sin
91
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
92
#undef OPNAME
93
94
#define OPNAME tan
95
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
96
#undef OPNAME
97
98
#define OPNAME acos
99
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
100
#undef OPNAME
101
102
#define OPNAME asin
103
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
104
#undef OPNAME
105
106
#define OPNAME atan
107
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
108
#undef OPNAME
109
110
#define OPNAME cosh
111
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
112
#undef OPNAME
113
114
#define OPNAME sinh
115
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
116
#undef OPNAME
117
118
#define OPNAME tanh
119
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
120
#undef OPNAME
121
122
#define OPNAME acosh
123
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
124
#undef OPNAME
125
126
#define OPNAME asinh
127
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
128
#undef OPNAME
129
130
#define OPNAME atanh
131
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
132
#undef OPNAME
133
134
#define OPNAME abs
135
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
136
#undef OPNAME
137
138
#define OPNAME fabs
139
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
140
#undef OPNAME
141
142
#define OPNAME ceil
143
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
144
#undef OPNAME
145
146
#define OPNAME operator+
147
#define OPER +
148
#include "
Sacado_MP_Vector_SFS_binary_op_tmpl.hpp
"
149
#undef OPNAME
150
#undef OPER
151
152
#define OPNAME operator-
153
#define OPER -
154
#include "
Sacado_MP_Vector_SFS_binary_op_tmpl.hpp
"
155
#undef OPNAME
156
#undef OPER
157
158
#define OPNAME operator*
159
#define OPER *
160
#include "
Sacado_MP_Vector_SFS_binary_op_tmpl.hpp
"
161
#undef OPNAME
162
#undef OPER
163
164
#define OPNAME operator/
165
#define OPER /
166
#include "
Sacado_MP_Vector_SFS_binary_op_tmpl.hpp
"
167
#undef OPNAME
168
#undef OPER
169
170
#define OPNAME atan2
171
#include "
Sacado_MP_Vector_SFS_binary_func_tmpl.hpp
"
172
#undef OPNAME
173
174
#define OPNAME pow
175
#include "
Sacado_MP_Vector_SFS_binary_func_tmpl.hpp
"
176
#undef OPNAME
177
178
#define OPNAME max
179
#include "
Sacado_MP_Vector_SFS_binary_func_tmpl.hpp
"
180
#undef OPNAME
181
182
#define OPNAME min
183
#include "
Sacado_MP_Vector_SFS_binary_func_tmpl.hpp
"
184
#undef OPNAME
185
186
//#ifdef __CUDACC__
187
//MP_BINARYOP_MACRO(max, ::max)
188
//MP_BINARYOP_MACRO(min, ::min)
189
//#else
190
//MP_BINARYOP_MACRO(max, std::max)
191
//MP_BINARYOP_MACRO(min, std::min)
192
//#endif
193
194
//-------------------------- Relational Operators -----------------------
195
196
#define MP_RELOP_MACRO(OP) \
197
namespace Sacado { \
198
namespace MP { \
199
\
200
template <typename O, typename T, int N, typename D> \
201
KOKKOS_INLINE_FUNCTION \
202
bool \
203
operator OP (const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >& a, \
204
const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >& b) \
205
{ \
206
return a.val() OP b.val(); \
207
} \
208
\
209
template <typename O, typename T, int N, typename D> \
210
KOKKOS_INLINE_FUNCTION \
211
bool \
212
operator OP (const typename Vector< Stokhos::StaticFixedStorage<O,T,N,D> >::value_type& a, \
213
const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >& b) \
214
{ \
215
return a OP b.val(); \
216
} \
217
\
218
template <typename O, typename T, int N, typename D> \
219
KOKKOS_INLINE_FUNCTION \
220
bool \
221
operator OP (const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >& a, \
222
const typename Vector< Stokhos::StaticFixedStorage<O,T,N,D> >::value_type& b) \
223
{ \
224
return a.val() OP b; \
225
} \
226
} \
227
}
228
229
MP_RELOP_MACRO
(==)
230
MP_RELOP_MACRO
(!=)
231
MP_RELOP_MACRO
(<)
232
MP_RELOP_MACRO
(>)
233
MP_RELOP_MACRO
(<=)
234
MP_RELOP_MACRO
(>=)
235
MP_RELOP_MACRO
(<<=)
236
MP_RELOP_MACRO
(>>=)
237
MP_RELOP_MACRO
(&)
238
MP_RELOP_MACRO
(|)
239
240
#undef MP_RELOP_MACRO
241
242
namespace
Sacado
{
243
244
namespace
MP {
245
246
template
<
typename
O,
typename
T,
int
N,
typename
D>
247
KOKKOS_INLINE_FUNCTION
248
bool
operator !
(
const
Vector
<
Stokhos::StaticFixedStorage<O,T,N,D>
>& a)
249
{
250
return
! a.val();
251
}
252
253
}
// namespace MP
254
255
}
// namespace Sacado
256
257
258
//-------------------------- Boolean Operators -----------------------
259
namespace
Sacado
{
260
261
namespace
MP
{
262
263
template
<
typename
O,
typename
T,
int
N,
typename
D>
264
KOKKOS_INLINE_FUNCTION
265
bool
toBool
(
const
Vector
<
Stokhos::StaticFixedStorage<O,T,N,D>
>& x) {
266
bool
is_zero =
true
;
267
for
(
int
i=0; i<x.size(); i++)
268
is_zero = is_zero && (x.coeff(i) == 0.0);
269
return
!is_zero;
270
}
271
272
}
// namespace MP
273
274
}
// namespace Sacado
275
276
#define PCE_BOOL_MACRO(OP) \
277
namespace Sacado { \
278
namespace MP { \
279
\
280
template <typename O, typename T, int N, typename D> \
281
KOKKOS_INLINE_FUNCTION \
282
bool \
283
operator OP (const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >& a, \
284
const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >& b) \
285
{ \
286
return toBool(a) OP toBool(b); \
287
} \
288
\
289
template <typename O, typename T, int N, typename D> \
290
KOKKOS_INLINE_FUNCTION \
291
bool \
292
operator OP (const typename Vector< Stokhos::StaticFixedStorage<O,T,N,D> >::value_type& a, \
293
const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >& b) \
294
{ \
295
return a OP toBool(b); \
296
} \
297
\
298
template <typename O, typename T, int N, typename D> \
299
KOKKOS_INLINE_FUNCTION \
300
bool \
301
operator OP (const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >& a, \
302
const typename Vector< Stokhos::StaticFixedStorage<O,T,N,D> >::value_type& b) \
303
{ \
304
return toBool(a) OP b; \
305
} \
306
} \
307
}
308
309
PCE_BOOL_MACRO
(&&)
310
PCE_BOOL_MACRO
(||)
311
312
#undef PCE_BOOL_MACRO
Sacado_MP_Vector_SFS_binary_func_tmpl.hpp
Sacado_MP_Vector_SFS_binary_op_tmpl.hpp
PCE_BOOL_MACRO
#define PCE_BOOL_MACRO(OP)
Definition
Sacado_MP_Vector_SFS_ops.hpp:276
MP_RELOP_MACRO
#define MP_RELOP_MACRO(OP)
Definition
Sacado_MP_Vector_SFS_ops.hpp:196
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
Sacado_MP_Vector_SFS_unary_op_tmpl.hpp
PCE_BOOL_MACRO
#define PCE_BOOL_MACRO(OP)
Definition
Sacado_MP_Vector_ops.hpp:863
Sacado::MP::Vector
Definition
Belos_SolverManager_MP_Vector.hpp:48
Stokhos::StaticFixedStorage
Statically allocated storage class.
Definition
Stokhos_StaticFixedStorage.hpp:69
Sacado::MP
Definition
Belos_SolverManager_MP_Vector.hpp:47
Sacado::MP::operator!
KOKKOS_INLINE_FUNCTION bool operator!(const Expr< T > &expr)
Definition
Sacado_MP_Vector_ops.hpp:833
Sacado::MP::toBool
KOKKOS_INLINE_FUNCTION bool toBool(const Expr< T > &xx)
Definition
Sacado_MP_Vector_ops.hpp:850
Sacado
Definition
Kokkos_View_UQ_PCE_Fwd.hpp:62
Generated by
1.17.0