Stokhos Package Browser (Single Doxygen Collection)
Version of the Day
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
sacado
kokkos
vector
linalg
Kokkos_MV_MP_Vector.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_MV_MP_VECTOR_HPP
43
#define KOKKOS_MV_MP_VECTOR_HPP
44
45
#include "
Sacado_MP_Vector.hpp
"
46
#include "
Kokkos_View_MP_Vector.hpp
"
47
#include "
Kokkos_InnerProductSpaceTraits_MP_Vector.hpp
"
48
#include "
Kokkos_Blas1_MP_Vector.hpp
"
49
50
//----------------------------------------------------------------------------
51
// Specializations of Kokkos Vector/MultiVector math functions
52
//----------------------------------------------------------------------------
53
/*
54
namespace Kokkos {
55
56
// Rank-1 vector add with Sacado::MP::Vector scalar type, constant a, b
57
template <typename RS, typename RL, typename RD, typename RM,
58
typename XS, typename XL, typename XD, typename XM,
59
typename YS, typename YL, typename YD, typename YM>
60
Kokkos::View< Sacado::MP::Vector<RS>*, RL, RD, RM>
61
V_Add( const Kokkos::View< Sacado::MP::Vector<RS>*, RL, RD, RM >& r,
62
const typename Sacado::MP::Vector<XS>::value_type& av,
63
const Kokkos::View< Sacado::MP::Vector<XS>*, XL, XD, XM >& x,
64
const typename Sacado::MP::Vector<XS>::value_type& bv,
65
const Kokkos::View< Sacado::MP::Vector<YS>*, YL, YD, YM >& y,
66
int n = -1)
67
{
68
typedef Kokkos::View< Sacado::MP::Vector<RS>*, RL, RD, RM > RVector;
69
typedef Kokkos::View< Sacado::MP::Vector<XS>*, XL, XD, XM > XVector;
70
typedef Kokkos::View< Sacado::MP::Vector<YS>*, YL, YD, YM > YVector;
71
72
typename RVector::flat_array_type r_flat = r;
73
typename XVector::flat_array_type x_flat = x;
74
typename YVector::flat_array_type y_flat = y;
75
if (n != -1) n = n * r.sacado_size();
76
77
V_Add( r_flat, av, x_flat, bv, y_flat, n );
78
79
return r;
80
}
81
82
// Rank-1 vector add with Sacado::MP::Vector scalar type, non-constant a, b
83
template <typename RS, typename RL, typename RD, typename RM,
84
typename XS, typename XL, typename XD, typename XM,
85
typename YS, typename YL, typename YD, typename YM>
86
Kokkos::View< Sacado::MP::Vector<RS>*, RL, RD, RM>
87
V_Add( const Kokkos::View< Sacado::MP::Vector<RS>*, RL, RD, RM >& r,
88
const Sacado::MP::Vector<XS>& av,
89
const Kokkos::View< Sacado::MP::Vector<XS>*, XL, XD, XM >& x,
90
const Sacado::MP::Vector<XS>& bv,
91
const Kokkos::View< Sacado::MP::Vector<YS>*, YL, YD, YM >& y,
92
int n = -1)
93
{
94
if (Sacado::is_constant(av) && Sacado::is_constant(bv)) {
95
return V_Add( r, av.fastAccessCoeff(0), x, bv.fastAccessCoeff(0), y, n );
96
}
97
else {
98
Impl::raise_error("V_Add not implemented for non-constant a or b");
99
}
100
return r;
101
}
102
103
// Rank-2 vector add with Sacado::MP::Vector scalar type, constant a, b
104
template <typename RS, typename RL, typename RD, typename RM,
105
typename XS, typename XL, typename XD, typename XM,
106
typename YS, typename YL, typename YD, typename YM>
107
Kokkos::View< Sacado::MP::Vector<RS>**, RL, RD, RM>
108
MV_Add( const Kokkos::View< Sacado::MP::Vector<RS>**, RL, RD, RM >& r,
109
const typename Sacado::MP::Vector<XS>::value_type& av,
110
const Kokkos::View< Sacado::MP::Vector<XS>**, XL, XD, XM >& x,
111
const typename Sacado::MP::Vector<XS>::value_type& bv,
112
const Kokkos::View< Sacado::MP::Vector<YS>**, YL, YD, YM >& y,
113
int n = -1)
114
{
115
typedef Kokkos::View< Sacado::MP::Vector<RS>**, RL, RD, RM > RVector;
116
typedef Kokkos::View< Sacado::MP::Vector<XS>**, XL, XD, XM > XVector;
117
typedef Kokkos::View< Sacado::MP::Vector<YS>**, YL, YD, YM > YVector;
118
119
typename RVector::flat_array_type r_flat = r;
120
typename XVector::flat_array_type x_flat = x;
121
typename YVector::flat_array_type y_flat = y;
122
if (n != -1) n = n * r.sacado_size();
123
124
MV_Add( r_flat, av, x_flat, bv, y_flat, n );
125
126
return r;
127
}
128
129
// Rank-2 vector add with Sacado::MP::Vector scalar type, non-constant a, b
130
template <typename RS, typename RL, typename RD, typename RM,
131
typename XS, typename XL, typename XD, typename XM,
132
typename YS, typename YL, typename YD, typename YM>
133
Kokkos::View< Sacado::MP::Vector<RS>**, RL, RD, RM>
134
MV_Add( const Kokkos::View< Sacado::MP::Vector<RS>**, RL, RD, RM >& r,
135
const Sacado::MP::Vector<XS>& av,
136
const Kokkos::View< Sacado::MP::Vector<XS>**, XL, XD, XM >& x,
137
const Sacado::MP::Vector<XS>& bv,
138
const Kokkos::View< Sacado::MP::Vector<YS>**, YL, YD, YM >& y,
139
int n = -1)
140
{
141
if (Sacado::is_constant(av) && Sacado::is_constant(bv)) {
142
return MV_Add( r, av.fastAccessCoeff(0), x, bv.fastAccessCoeff(0), y, n );
143
}
144
else {
145
Impl::raise_error("MV_Add not implemented for non-constant a or b");
146
}
147
return r;
148
}
149
150
// Rank-1 dot product
151
template <typename XS, typename XL, typename XD, typename XM,
152
typename YS, typename YL, typename YD, typename YM>
153
typename Details::InnerProductSpaceTraits< Sacado::MP::Vector<XS> >::dot_type
154
V_Dot( const Kokkos::View< Sacado::MP::Vector<XS>*, XL, XD, XM >& x,
155
const Kokkos::View< Sacado::MP::Vector<YS>*, YL, YD, YM >& y,
156
int n = -1 )
157
{
158
typedef Kokkos::View< Sacado::MP::Vector<XS>*, XL, XD, XM > XVector;
159
typedef Kokkos::View< Sacado::MP::Vector<YS>*, YL, YD, YM > YVector;
160
161
typename XVector::flat_array_type x_flat = x;
162
typename YVector::flat_array_type y_flat = y;
163
if (n != -1) n = n * x.sacado_size();
164
165
return V_Dot( x_flat, y_flat, n );
166
}
167
168
// Rank-2 dot product
169
template <typename rVector,
170
typename XS, typename XL, typename XD, typename XM,
171
typename YS, typename YL, typename YD, typename YM>
172
void
173
MV_Dot( const rVector& r,
174
const Kokkos::View< Sacado::MP::Vector<XS>**, XL, XD, XM >& x,
175
const Kokkos::View< Sacado::MP::Vector<YS>**, YL, YD, YM >& y,
176
int n = -1 )
177
{
178
typedef Kokkos::View< Sacado::MP::Vector<XS>**, XL, XD, XM > XVector;
179
typedef Kokkos::View< Sacado::MP::Vector<YS>**, YL, YD, YM > YVector;
180
181
typename XVector::flat_array_type x_flat = x;
182
typename YVector::flat_array_type y_flat = y;
183
if (n != -1) n = n * x.sacado_size();
184
185
MV_Dot( r, x_flat, y_flat, n );
186
}
187
188
} // namespace Kokkos
189
*/
190
#endif
/* #ifndef KOKKOS_MV_MP_VECTOR_HPP */
Kokkos_Blas1_MP_Vector.hpp
Kokkos_View_MP_Vector.hpp
Sacado_MP_Vector.hpp
Kokkos_InnerProductSpaceTraits_MP_Vector.hpp
Generated by
1.8.5