44 #ifndef TPETRA_DETAILS_GETDIAGCOPYWITHOUTOFFSETS_DECL_HPP
45 #define TPETRA_DETAILS_GETDIAGCOPYWITHOUTOFFSETS_DECL_HPP
56 #include "TpetraCore_config.h"
57 #include "Kokkos_Core.hpp"
58 #include "Kokkos_ArithTraits.hpp"
60 #include "Tpetra_RowMatrix_decl.hpp"
62 #include <type_traits>
79 template<
class DiagType,
83 typedef typename LocalMapType::local_ordinal_type LO;
84 typedef typename LocalMapType::global_ordinal_type GO;
85 typedef typename CrsMatrixType::device_type device_type;
86 typedef typename CrsMatrixType::value_type scalar_type;
87 typedef typename CrsMatrixType::size_type offset_type;
100 const LocalMapType& rowMap,
101 const LocalMapType& colMap,
102 const CrsMatrixType& A) :
103 D_ (D), rowMap_ (rowMap), colMap_ (colMap), A_ (A)
112 const LO INV = Tpetra::Details::OrdinalTraits<LO>::invalid ();
113 const scalar_type
ZERO =
114 Kokkos::Details::ArithTraits<scalar_type>::zero ();
117 D_(lclRowInd) =
ZERO;
118 const GO gblInd = rowMap_.getGlobalElement (lclRowInd);
119 const LO lclColInd = colMap_.getLocalElement (gblInd);
121 if (lclColInd != INV) {
122 auto curRow = A_.rowConst (lclRowInd);
128 const LO numEnt = curRow.length;
129 for ( ; offset < numEnt; ++offset) {
130 if (curRow.colidx(offset) == lclColInd) {
135 if (offset == numEnt) {
139 D_(lclRowInd) = curRow.value(offset);
148 LocalMapType rowMap_;
150 LocalMapType colMap_;
178 template<
class DiagType,
181 static typename LocalMapType::local_ordinal_type
183 const LocalMapType& rowMap,
184 const LocalMapType& colMap,
185 const CrsMatrixType& A)
187 static_assert (Kokkos::Impl::is_view<DiagType>::value,
188 "DiagType must be a Kokkos::View.");
189 static_assert (static_cast<int> (DiagType::rank) == 1,
190 "DiagType must be a 1-D Kokkos::View.");
191 static_assert (std::is_same<DiagType, typename DiagType::non_const_type>::value,
192 "DiagType must be a nonconst Kokkos::View.");
193 typedef typename LocalMapType::local_ordinal_type LO;
194 typedef typename CrsMatrixType::device_type device_type;
195 typedef typename device_type::execution_space execution_space;
196 typedef Kokkos::RangePolicy<execution_space, LO> policy_type;
198 typedef Kokkos::View<
typename DiagType::non_const_value_type*,
199 typename DiagType::array_layout,
200 typename DiagType::device_type,
201 Kokkos::MemoryUnmanaged> diag_type;
204 functor (D_out, rowMap, colMap, A);
205 const LO numRows =
static_cast<LO
> (D.extent (0));
207 Kokkos::parallel_reduce (policy_type (0, numRows), functor, errCount);
247 template<
class SC,
class LO,
class GO,
class NT>
250 const ::Tpetra::RowMatrix<SC, LO, GO, NT>& A,
252 #ifdef HAVE_TPETRA_DEBUG
254 #else // ! HAVE_TPETRA_DEBUG
256 #endif // HAVE_TPETRA_DEBUG
261 #endif // TPETRA_DETAILS_GETDIAGCOPYWITHOUTOFFSETS_DECL_HPP
Import KokkosSparse::OrdinalTraits, a traits class for "invalid" (flag) values of integer types...
Functor that implements much of the one-argument overload of Tpetra::CrsMatrix::getLocalDiagCopy, for the case where the matrix is fill complete.
LO value_type
The result of the reduction; number of errors.
Declaration of the Tpetra::Vector class.
KOKKOS_FUNCTION void operator()(const LO &lclRowInd, value_type &errCount) const
Operator for Kokkos::parallel_for.
static LocalMapType::local_ordinal_type getDiagCopyWithoutOffsets(const DiagType &D, const LocalMapType &rowMap, const LocalMapType &colMap, const CrsMatrixType &A)
Given a locally indexed, local sparse matrix, and corresponding local row and column Maps...
LO getLocalDiagCopyWithoutOffsetsNotFillComplete(::Tpetra::Vector< SC, LO, GO, NT > &diag, const ::Tpetra::RowMatrix< SC, LO, GO, NT > &A, const bool debug=false)
Given a locally indexed, global sparse matrix, extract the matrix's diagonal entries into a Tpetra::V...
Replace old values with zero.
A distributed dense vector.
CrsMatrixGetDiagCopyFunctor(const DiagType &D, const LocalMapType &rowMap, const LocalMapType &colMap, const CrsMatrixType &A)
Constructor.