Stokhos Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
src
sacado
kokkos
pce
linalg
Kokkos_InnerProductSpaceTraits_UQ_PCE.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
#ifndef KOKKOS_INNER_PRODUCT_SPACE_TRAITS_UQ_PCE_HPP
43
#define KOKKOS_INNER_PRODUCT_SPACE_TRAITS_UQ_PCE_HPP
44
45
#include "
Sacado_UQ_PCE.hpp
"
46
#include "Kokkos_InnerProductSpaceTraits.hpp"
47
#include "
Kokkos_ArithTraits_UQ_PCE.hpp
"
48
49
//----------------------------------------------------------------------------
50
// Specializations of Kokkos::InnerProductSpaceTraits for Sacado::UQ::PCE
51
// scalar type
52
//----------------------------------------------------------------------------
53
54
namespace
Kokkos
{
55
namespace
Details
{
56
57
template
<
typename
S>
58
class
InnerProductSpaceTraits<
Sacado
::UQ::PCE<S> > {
59
public
:
60
typedef
Sacado::UQ::PCE<S>
val_type
;
61
62
typedef
typename
val_type::value_type
base_value_type
;
63
typedef
typename
val_type::ordinal_type
ordinal_type
;
64
typedef
InnerProductSpaceTraits<base_value_type>
BIT
;
65
typedef
typename
BIT::dot_type
base_dot_type
;
66
67
typedef
typename
Kokkos::ArithTraits<val_type>::mag_type
mag_type
;
68
typedef
base_dot_type
dot_type
;
69
70
static
KOKKOS_FORCEINLINE_FUNCTION
71
mag_type
norm
(
const
val_type
& x) {
72
//return ArithTraits<val_type>::abs (x);
73
const
ordinal_type
sz = x.size();
74
mag_type
nrm =
mag_type
(0);
75
for
(
ordinal_type
i=0; i<sz; ++i) {
76
const
mag_type
n = BIT::norm( x.fastAccessCoeff(i) );
77
nrm += n*n;
78
}
79
return
std::sqrt(nrm);
80
}
81
82
static
KOKKOS_FORCEINLINE_FUNCTION
83
dot_type
dot
(
const
val_type
& x,
const
val_type
& y) {
84
const
ordinal_type
xsz = x.size();
85
const
ordinal_type
ysz = y.size();
86
const
ordinal_type
sz = xsz > ysz ? xsz : ysz;
87
88
dot_type
r =
dot_type
(0);
89
if
(x.hasFastAccess(sz) && y.hasFastAccess(sz))
90
for
(
ordinal_type
i=0; i<sz; ++i)
91
r += BIT::dot( x.fastAccessCoeff(i), y.fastAccessCoeff(i) );
92
else
93
for
(
ordinal_type
i=0; i<sz; ++i)
94
r += BIT::dot( x.coeff(i), y.coeff(i) );
95
96
return
r;
97
}
98
99
};
100
101
template
<
typename
S>
102
class
InnerProductSpaceTraits< const
Sacado
::UQ::PCE<S> > {
103
public
:
104
typedef
Sacado::UQ::PCE<S>
val_type
;
105
106
typedef
typename
val_type::value_type
base_value_type
;
107
typedef
typename
val_type::ordinal_type
ordinal_type
;
108
typedef
InnerProductSpaceTraits<base_value_type>
BIT
;
109
typedef
typename
BIT::dot_type
base_dot_type
;
110
111
typedef
typename
Kokkos::ArithTraits<val_type>::mag_type
mag_type
;
112
typedef
base_dot_type
dot_type
;
113
114
static
KOKKOS_FORCEINLINE_FUNCTION
115
mag_type
norm
(
const
val_type
& x) {
116
//return ArithTraits<val_type>::abs (x);
117
const
ordinal_type
sz = x.size();
118
mag_type
nrm =
mag_type
(0);
119
for
(
ordinal_type
i=0; i<sz; ++i) {
120
const
mag_type
n = BIT::norm( x.fastAccessCoeff(i) );
121
nrm += n*n;
122
}
123
return
std::sqrt(nrm);
124
}
125
126
static
KOKKOS_FORCEINLINE_FUNCTION
127
dot_type
dot
(
const
val_type
& x,
const
val_type
& y) {
128
const
ordinal_type
xsz = x.size();
129
const
ordinal_type
ysz = y.size();
130
const
ordinal_type
sz = xsz > ysz ? xsz : ysz;
131
132
dot_type
r =
dot_type
(0);
133
if
(x.hasFastAccess(sz) && y.hasFastAccess(sz))
134
for
(
ordinal_type
i=0; i<sz; ++i)
135
r += BIT::dot( x.fastAccessCoeff(i), y.fastAccessCoeff(i) );
136
else
137
for
(
ordinal_type
i=0; i<sz; ++i)
138
r += BIT::dot( x.coeff(i), y.coeff(i) );
139
140
return
r;
141
}
142
143
};
144
145
}
146
}
147
148
#endif
/* #ifndef KOKKOS_INNER_PRODUCT_SPACE_TRAITS_UQ_PCE_HPP */
Kokkos_ArithTraits_UQ_PCE.hpp
Sacado_UQ_PCE.hpp
Kokkos::Details::InnerProductSpaceTraits< Sacado::UQ::PCE< S > >::ordinal_type
val_type::ordinal_type ordinal_type
Definition
Kokkos_InnerProductSpaceTraits_UQ_PCE.hpp:63
Kokkos::Details::InnerProductSpaceTraits< Sacado::UQ::PCE< S > >::base_value_type
val_type::value_type base_value_type
Definition
Kokkos_InnerProductSpaceTraits_UQ_PCE.hpp:62
Kokkos::Details::InnerProductSpaceTraits< Sacado::UQ::PCE< S > >::BIT
InnerProductSpaceTraits< base_value_type > BIT
Definition
Kokkos_InnerProductSpaceTraits_UQ_PCE.hpp:64
Kokkos::Details::InnerProductSpaceTraits< Sacado::UQ::PCE< S > >::dot_type
base_dot_type dot_type
Definition
Kokkos_InnerProductSpaceTraits_UQ_PCE.hpp:68
Kokkos::Details::InnerProductSpaceTraits< Sacado::UQ::PCE< S > >::mag_type
Kokkos::ArithTraits< val_type >::mag_type mag_type
Definition
Kokkos_InnerProductSpaceTraits_UQ_PCE.hpp:67
Kokkos::Details::InnerProductSpaceTraits< Sacado::UQ::PCE< S > >::val_type
Sacado::UQ::PCE< S > val_type
Definition
Kokkos_InnerProductSpaceTraits_UQ_PCE.hpp:60
Kokkos::Details::InnerProductSpaceTraits< Sacado::UQ::PCE< S > >::norm
static KOKKOS_FORCEINLINE_FUNCTION mag_type norm(const val_type &x)
Definition
Kokkos_InnerProductSpaceTraits_UQ_PCE.hpp:71
Kokkos::Details::InnerProductSpaceTraits< Sacado::UQ::PCE< S > >::base_dot_type
BIT::dot_type base_dot_type
Definition
Kokkos_InnerProductSpaceTraits_UQ_PCE.hpp:65
Kokkos::Details::InnerProductSpaceTraits< Sacado::UQ::PCE< S > >::dot
static KOKKOS_FORCEINLINE_FUNCTION dot_type dot(const val_type &x, const val_type &y)
Definition
Kokkos_InnerProductSpaceTraits_UQ_PCE.hpp:83
Kokkos::Details::InnerProductSpaceTraits< const Sacado::UQ::PCE< S > >::ordinal_type
val_type::ordinal_type ordinal_type
Definition
Kokkos_InnerProductSpaceTraits_UQ_PCE.hpp:107
Kokkos::Details::InnerProductSpaceTraits< const Sacado::UQ::PCE< S > >::base_dot_type
BIT::dot_type base_dot_type
Definition
Kokkos_InnerProductSpaceTraits_UQ_PCE.hpp:109
Kokkos::Details::InnerProductSpaceTraits< const Sacado::UQ::PCE< S > >::val_type
Sacado::UQ::PCE< S > val_type
Definition
Kokkos_InnerProductSpaceTraits_UQ_PCE.hpp:104
Kokkos::Details::InnerProductSpaceTraits< const Sacado::UQ::PCE< S > >::base_value_type
val_type::value_type base_value_type
Definition
Kokkos_InnerProductSpaceTraits_UQ_PCE.hpp:106
Kokkos::Details::InnerProductSpaceTraits< const Sacado::UQ::PCE< S > >::norm
static KOKKOS_FORCEINLINE_FUNCTION mag_type norm(const val_type &x)
Definition
Kokkos_InnerProductSpaceTraits_UQ_PCE.hpp:115
Kokkos::Details::InnerProductSpaceTraits< const Sacado::UQ::PCE< S > >::dot_type
base_dot_type dot_type
Definition
Kokkos_InnerProductSpaceTraits_UQ_PCE.hpp:112
Kokkos::Details::InnerProductSpaceTraits< const Sacado::UQ::PCE< S > >::mag_type
Kokkos::ArithTraits< val_type >::mag_type mag_type
Definition
Kokkos_InnerProductSpaceTraits_UQ_PCE.hpp:111
Kokkos::Details::InnerProductSpaceTraits< const Sacado::UQ::PCE< S > >::BIT
InnerProductSpaceTraits< base_value_type > BIT
Definition
Kokkos_InnerProductSpaceTraits_UQ_PCE.hpp:108
Kokkos::Details::InnerProductSpaceTraits< const Sacado::UQ::PCE< S > >::dot
static KOKKOS_FORCEINLINE_FUNCTION dot_type dot(const val_type &x, const val_type &y)
Definition
Kokkos_InnerProductSpaceTraits_UQ_PCE.hpp:127
Sacado::UQ::PCE
Definition
Kokkos_View_UQ_PCE_Fwd.hpp:65
Kokkos::Details
Definition
Kokkos_InnerProductSpaceTraits_UQ_PCE.hpp:55
Kokkos
Definition
Stokhos_CrsMatrix.hpp:663
Sacado
Definition
Kokkos_View_UQ_PCE_Fwd.hpp:62
Generated by
1.17.0