Sacado Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
src
Sacado_StaticArrayTraits.hpp
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
#ifndef SACADO_STATICARRAYTRAITS_HPP
31
#define SACADO_STATICARRAYTRAITS_HPP
32
33
#include <cstring>
34
35
#include "
Sacado_Traits.hpp
"
36
37
namespace
Sacado
{
38
42
template <typename T, bool isScalar = IsScalarType<T>::value>
43
struct
ss_array
{
44
46
SACADO_INLINE_FUNCTION
47
static
void
copy
(
const
T
* src,
T
* dest,
int
sz) {
48
for
(
int
i=0; i<sz; ++i)
49
*(dest++) = *(src++);
50
}
51
53
SACADO_INLINE_FUNCTION
54
static
void
zero
(
T
* dest,
int
sz) {
55
for
(
int
i=0; i<sz; ++i)
56
*(dest++) =
T
(0.);
57
}
58
};
59
64
template
<
typename
T>
65
struct
ss_array
<
T
,
true
> {
66
68
SACADO_INLINE_FUNCTION
69
static
void
copy
(
const
T
* src,
T
* dest,
int
sz) {
70
if
(sz > 0)
71
#if defined( __CUDACC__) || defined(__HIPCC__ )
72
for
(
int
i=0; i<sz; ++i)
73
dest[i] = src[i];
74
#else
75
std::memcpy(dest,src,sz*
sizeof
(
T
));
76
#endif
77
}
78
80
SACADO_INLINE_FUNCTION
81
static
void
zero
(
T
* dest,
int
sz) {
82
if
(sz > 0)
83
#if defined(__CUDACC__ ) || defined(__HIPCC__ )
84
for
(
int
i=0; i<sz; ++i)
85
dest[i] =
T
(0.);
86
#else
87
std::memset(dest,0,sz*
sizeof
(
T
));
88
#endif
89
}
90
91
};
92
93
}
// namespace Sacado
94
95
#endif
// SACAD0_STATICARRAYTRAITS_HPP
SACADO_INLINE_FUNCTION
#define SACADO_INLINE_FUNCTION
Definition
Sacado_ConfigDefs.h:110
true
expr true
Definition
Sacado_ELRFad_Ops.hpp:183
Sacado_Traits.hpp
T
#define T
Definition
Sacado_rad.hpp:573
Sacado
Definition
Sacado_mpl_apply.hpp:39
Sacado::ss_array< T, true >::zero
static SACADO_INLINE_FUNCTION void zero(T *dest, int sz)
Zero out array dest of length sz.
Definition
Sacado_StaticArrayTraits.hpp:81
Sacado::ss_array< T, true >::copy
static SACADO_INLINE_FUNCTION void copy(const T *src, T *dest, int sz)
Copy array from src to dest of length sz.
Definition
Sacado_StaticArrayTraits.hpp:69
Sacado::ss_array
Static array allocation class that works for any type.
Definition
Sacado_StaticArrayTraits.hpp:43
Sacado::ss_array::zero
static SACADO_INLINE_FUNCTION void zero(T *dest, int sz)
Zero out array dest of length sz.
Definition
Sacado_StaticArrayTraits.hpp:54
Sacado::ss_array::copy
static SACADO_INLINE_FUNCTION void copy(const T *src, T *dest, int sz)
Copy array from src to dest of length sz.
Definition
Sacado_StaticArrayTraits.hpp:47
Generated by
1.17.0