Debian Codegraph @

packages/stokhos/src/sacado/kokkos/pce/tpetra/Tpetra_Details_fill_UQ_PCE.hpp

raw
1 // @HEADER
2 // *****************************************************************************
3 // Tpetra: Templated Linear Algebra Services Package
4 //
5 // Copyright 2008 NTESS and the Tpetra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9
10 #ifndef TPETRA_DETAILS_FILL_UQ_PCE_HPP
11 #define TPETRA_DETAILS_FILL_UQ_PCE_HPP
12
13 #include "Tpetra_Details_fill.hpp"
14 #include "Stokhos_Sacado_Kokkos_UQ_PCE.hpp"
15
16 namespace Tpetra {
17 namespace Details {
18 namespace Blas {
19
20 template<class DT, class ... DP,
21 class ValueType,
22 class IndexType,
23 class ExecutionSpace>
24 typename std::enable_if<
25 Kokkos::is_view_uq_pce< Kokkos::View<DT,DP...> >::value >::type
26 fill (const ExecutionSpace& execSpace,
27 const Kokkos::View<DT,DP...>& X,
28 const ValueType& alpha,
29 const IndexType numRows,
30 const IndexType numCols)
31 {
32 static_assert (std::is_integral<IndexType>::value,
33 "IndexType must be a built-in integer type.");
34 Kokkos::deep_copy(execSpace, X, alpha);
35 }
36
37 template<class DT, class ... DP,
38 class ValueType,
39 class IndexType,
40 class ExecutionSpace>
41 typename std::enable_if<
42 Kokkos::is_view_uq_pce< Kokkos::View<DT,DP...> >::value >::type
43 fill (const ExecutionSpace& execSpace,
44 const Kokkos::View<DT,DP...>& X,
45 const ValueType& alpha,
46 const IndexType numRows,
47 const IndexType numCols,
48 const size_t whichVectors[])
49 {
50 typedef Kokkos::View<DT,DP...> ViewType;
51 static_assert (ViewType::rank == 2, "ViewType must be a rank-2 "
52 "Kokkos::View in order to call the \"whichVectors\" "
53 "specialization of fill.");
54 static_assert (std::is_integral<IndexType>::value,
55 "IndexType must be a built-in integer type.");
56 for (IndexType k = 0; k < numCols; ++k) {
57 const IndexType j = whichVectors[k];
58 auto X_j = Kokkos::subview (X, Kokkos::ALL (), j);
59 Kokkos::deep_copy(execSpace, X_j, alpha);
60 }
61 }
62
63 } // namespace Blas
64 } // namespace Details
65 } // namespace Tpetra
66
67 #endif // TPETRA_DETAILS_FILL_UQ_PCE_HPP