Stokhos Package Browser (Single Doxygen Collection)
Version of the Day
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 <math_functions.h>
47
#endif
48
49
#define OPNAME operator+
50
#define OPER +
51
#include "
Sacado_MP_Vector_SFS_unary_op_tmpl.hpp
"
52
#undef OPNAME
53
#undef OPER
54
55
#define OPNAME operator-
56
#define OPER -
57
#include "
Sacado_MP_Vector_SFS_unary_op_tmpl.hpp
"
58
#undef OPNAME
59
#undef OPER
60
61
#define OPNAME exp
62
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
63
#undef OPNAME
64
65
#define OPNAME log
66
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
67
#undef OPNAME
68
69
#define OPNAME log10
70
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
71
#undef OPNAME
72
73
#define OPNAME sqrt
74
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
75
#undef OPNAME
76
77
#define OPNAME cbrt
78
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
79
#undef OPNAME
80
81
#define OPNAME cos
82
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
83
#undef OPNAME
84
85
#define OPNAME sin
86
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
87
#undef OPNAME
88
89
#define OPNAME tan
90
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
91
#undef OPNAME
92
93
#define OPNAME acos
94
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
95
#undef OPNAME
96
97
#define OPNAME asin
98
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
99
#undef OPNAME
100
101
#define OPNAME atan
102
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
103
#undef OPNAME
104
105
#define OPNAME cosh
106
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
107
#undef OPNAME
108
109
#define OPNAME sinh
110
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
111
#undef OPNAME
112
113
#define OPNAME tanh
114
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
115
#undef OPNAME
116
117
#define OPNAME acosh
118
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
119
#undef OPNAME
120
121
#define OPNAME asinh
122
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
123
#undef OPNAME
124
125
#define OPNAME atanh
126
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
127
#undef OPNAME
128
129
#define OPNAME abs
130
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
131
#undef OPNAME
132
133
#define OPNAME fabs
134
#include "
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
"
135
#undef OPNAME
136
137
#define OPNAME operator+
138
#define OPER +
139
#include "
Sacado_MP_Vector_SFS_binary_op_tmpl.hpp
"
140
#undef OPNAME
141
#undef OPER
142
143
#define OPNAME operator-
144
#define OPER -
145
#include "
Sacado_MP_Vector_SFS_binary_op_tmpl.hpp
"
146
#undef OPNAME
147
#undef OPER
148
149
#define OPNAME operator*
150
#define OPER *
151
#include "
Sacado_MP_Vector_SFS_binary_op_tmpl.hpp
"
152
#undef OPNAME
153
#undef OPER
154
155
#define OPNAME operator/
156
#define OPER /
157
#include "
Sacado_MP_Vector_SFS_binary_op_tmpl.hpp
"
158
#undef OPNAME
159
#undef OPER
160
161
#define OPNAME atan2
162
#include "
Sacado_MP_Vector_SFS_binary_func_tmpl.hpp
"
163
#undef OPNAME
164
165
#define OPNAME pow
166
#include "
Sacado_MP_Vector_SFS_binary_func_tmpl.hpp
"
167
#undef OPNAME
168
169
#define OPNAME max
170
#include "
Sacado_MP_Vector_SFS_binary_func_tmpl.hpp
"
171
#undef OPNAME
172
173
#define OPNAME min
174
#include "
Sacado_MP_Vector_SFS_binary_func_tmpl.hpp
"
175
#undef OPNAME
176
177
//#ifdef __CUDACC__
178
//MP_BINARYOP_MACRO(max, ::max)
179
//MP_BINARYOP_MACRO(min, ::min)
180
//#else
181
//MP_BINARYOP_MACRO(max, std::max)
182
//MP_BINARYOP_MACRO(min, std::min)
183
//#endif
184
185
//-------------------------- Relational Operators -----------------------
186
187
#define MP_RELOP_MACRO(OP) \
188
namespace Sacado { \
189
namespace MP { \
190
\
191
template <typename O, typename T, int N, typename D> \
192
KOKKOS_INLINE_FUNCTION \
193
bool \
194
operator OP (const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >& a, \
195
const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >& b) \
196
{ \
197
return a.val() OP b.val(); \
198
} \
199
\
200
template <typename O, typename T, int N, typename D> \
201
KOKKOS_INLINE_FUNCTION \
202
bool \
203
operator OP (const typename Vector< Stokhos::StaticFixedStorage<O,T,N,D> >::value_type& a, \
204
const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >& b) \
205
{ \
206
return a 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 Vector< Stokhos::StaticFixedStorage<O,T,N,D> >& a, \
213
const typename Vector< Stokhos::StaticFixedStorage<O,T,N,D> >::value_type& b) \
214
{ \
215
return a.val() OP b; \
216
} \
217
} \
218
}
219
220
MP_RELOP_MACRO
(==)
221
MP_RELOP_MACRO
(!=)
222
MP_RELOP_MACRO
(<)
223
MP_RELOP_MACRO
(>)
224
MP_RELOP_MACRO
(<=)
225
MP_RELOP_MACRO
(>=)
226
MP_RELOP_MACRO
(<<=)
227
MP_RELOP_MACRO
(>>=)
228
MP_RELOP_MACRO
(&)
229
MP_RELOP_MACRO
(|)
230
231
#undef MP_RELOP_MACRO
232
233
namespace
Sacado
{
234
235
namespace
MP {
236
237
template
<
typename
O,
typename
T,
int
N,
typename
D>
238
KOKKOS_INLINE_FUNCTION
239
bool
operator !
(
const
Vector
<
Stokhos::StaticFixedStorage<O,T,N,D>
>& a)
240
{
241
return
! a.val();
242
}
243
244
}
// namespace MP
245
246
}
// namespace Sacado
247
248
249
//-------------------------- Boolean Operators -----------------------
250
namespace
Sacado
{
251
252
namespace
MP {
253
254
template
<
typename
O,
typename
T,
int
N,
typename
D>
255
KOKKOS_INLINE_FUNCTION
256
bool
toBool
(
const
Vector
<
Stokhos::StaticFixedStorage<O,T,N,D>
>&
x
) {
257
bool
is_zero =
true
;
258
for
(
int
i=0; i<
x
.size(); i++)
259
is_zero = is_zero && (
x
.coeff(i) == 0.0);
260
return
!is_zero;
261
}
262
263
}
// namespace MP
264
265
}
// namespace Sacado
266
267
#define PCE_BOOL_MACRO(OP) \
268
namespace Sacado { \
269
namespace MP { \
270
\
271
template <typename O, typename T, int N, typename D> \
272
KOKKOS_INLINE_FUNCTION \
273
bool \
274
operator OP (const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >& a, \
275
const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >& b) \
276
{ \
277
return toBool(a) OP toBool(b); \
278
} \
279
\
280
template <typename O, typename T, int N, typename D> \
281
KOKKOS_INLINE_FUNCTION \
282
bool \
283
operator OP (const typename Vector< Stokhos::StaticFixedStorage<O,T,N,D> >::value_type& a, \
284
const Vector< Stokhos::StaticFixedStorage<O,T,N,D> >& b) \
285
{ \
286
return 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 Vector< Stokhos::StaticFixedStorage<O,T,N,D> >& a, \
293
const typename Vector< Stokhos::StaticFixedStorage<O,T,N,D> >::value_type& b) \
294
{ \
295
return toBool(a) OP b; \
296
} \
297
} \
298
}
299
300
PCE_BOOL_MACRO
(&&)
301
PCE_BOOL_MACRO
(||)
302
303
#undef PCE_BOOL_MACRO
Sacado_MP_Vector_SFS_unary_func_tmpl.hpp
Sacado::MP::Vector
Definition:
Belos_SolverManager_MP_Vector.hpp:48
MP_RELOP_MACRO
#define MP_RELOP_MACRO(OP)
Definition:
Sacado_MP_Vector_SFS_ops.hpp:187
Sacado_MP_Vector_SFS_binary_op_tmpl.hpp
PCE_BOOL_MACRO
#define PCE_BOOL_MACRO(OP)
Definition:
Sacado_MP_Vector_SFS_ops.hpp:267
Sacado
Definition:
Kokkos_View_UQ_PCE_Utils.hpp:48
cusp::detail::device::x
const IndexType const IndexType const IndexType const IndexType const ValueType const ValueType * x
Definition:
csr_vector.h:260
Sacado_MP_Vector_SFS_binary_func_tmpl.hpp
Stokhos::StaticFixedStorage
Statically allocated storage class.
Definition:
Stokhos_StaticFixedStorage.hpp:59
Sacado::MP::toBool
KOKKOS_INLINE_FUNCTION bool toBool(const Expr< T > &xx)
Definition:
Sacado_MP_Vector_ops.hpp:895
Sacado_MP_Vector_SFS_unary_op_tmpl.hpp
Sacado::MP::operator!
KOKKOS_INLINE_FUNCTION bool operator!(const Expr< T > &expr)
Definition:
Sacado_MP_Vector_ops.hpp:878
Generated by
1.8.16