10#ifndef TPETRA_CRSMATRIX_DECL_HPP
11#define TPETRA_CRSMATRIX_DECL_HPP
18#include "KokkosSparse_Utils.hpp"
19#include "KokkosSparse_CrsMatrix.hpp"
20#include "Tpetra_Details_MatrixApplyHelper.hpp"
21#include "Tpetra_RowMatrix_decl.hpp"
22#include "Tpetra_Exceptions.hpp"
23#include "Tpetra_DistObject.hpp"
24#include "Tpetra_CrsGraph.hpp"
25#include "Tpetra_Vector.hpp"
27#include "Tpetra_Details_ExecutionSpacesUser.hpp"
28#include "Teuchos_DataAccess.hpp"
35template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
36class crsMatrix_Swap_Tester;
89template <
class CrsMatrixType>
90Teuchos::RCP<CrsMatrixType>
92 const Import<
typename CrsMatrixType::local_ordinal_type,
93 typename CrsMatrixType::global_ordinal_type,
94 typename CrsMatrixType::node_type>& importer,
95 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
96 typename CrsMatrixType::global_ordinal_type,
97 typename CrsMatrixType::node_type> >& domainMap = Teuchos::null,
98 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
99 typename CrsMatrixType::global_ordinal_type,
100 typename CrsMatrixType::node_type> >& rangeMap = Teuchos::null,
101 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
156template <
class CrsMatrixType>
157Teuchos::RCP<CrsMatrixType>
159 const Import<
typename CrsMatrixType::local_ordinal_type,
160 typename CrsMatrixType::global_ordinal_type,
161 typename CrsMatrixType::node_type>& rowImporter,
162 const Import<
typename CrsMatrixType::local_ordinal_type,
163 typename CrsMatrixType::global_ordinal_type,
164 typename CrsMatrixType::node_type>& domainImporter,
165 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
166 typename CrsMatrixType::global_ordinal_type,
167 typename CrsMatrixType::node_type> >& domainMap,
168 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
169 typename CrsMatrixType::global_ordinal_type,
170 typename CrsMatrixType::node_type> >& rangeMap,
171 const Teuchos::RCP<Teuchos::ParameterList>& params);
206template <
class CrsMatrixType>
207Teuchos::RCP<CrsMatrixType>
209 const Export<
typename CrsMatrixType::local_ordinal_type,
210 typename CrsMatrixType::global_ordinal_type,
211 typename CrsMatrixType::node_type>& exporter,
212 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
213 typename CrsMatrixType::global_ordinal_type,
214 typename CrsMatrixType::node_type> >& domainMap = Teuchos::null,
215 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
216 typename CrsMatrixType::global_ordinal_type,
217 typename CrsMatrixType::node_type> >& rangeMap = Teuchos::null,
218 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
253template <
class CrsMatrixType>
254Teuchos::RCP<CrsMatrixType>
256 const Export<
typename CrsMatrixType::local_ordinal_type,
257 typename CrsMatrixType::global_ordinal_type,
258 typename CrsMatrixType::node_type>& rowExporter,
259 const Export<
typename CrsMatrixType::local_ordinal_type,
260 typename CrsMatrixType::global_ordinal_type,
261 typename CrsMatrixType::node_type>& domainExporter,
262 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
263 typename CrsMatrixType::global_ordinal_type,
264 typename CrsMatrixType::node_type> >& domainMap,
265 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
266 typename CrsMatrixType::global_ordinal_type,
267 typename CrsMatrixType::node_type> >& rangeMap,
268 const Teuchos::RCP<Teuchos::ParameterList>& params);
273template <
class SC,
class LO,
class GO,
class NO>
393template <
class Scalar,
397class CrsMatrix :
public RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>,
398 public DistObject<char, LocalOrdinal, GlobalOrdinal, Node>,
401 using dist_object_type =
456 using mag_type =
typename KokkosKernels::ArithTraits<impl_scalar_type>::mag_type;
472 typename local_graph_device_type::size_type>;
473 using local_matrix_host_type =
474 typename local_matrix_device_type::host_mirror_type;
476 using row_ptrs_device_view_type =
477 typename row_matrix_type::row_ptrs_device_view_type;
478 using row_ptrs_host_view_type =
479 typename row_matrix_type::row_ptrs_host_view_type;
481 using local_inds_device_view_type =
482 typename row_matrix_type::local_inds_device_view_type;
483 using local_inds_host_view_type =
484 typename row_matrix_type::local_inds_host_view_type;
485 using nonconst_local_inds_host_view_type =
486 typename row_matrix_type::nonconst_local_inds_host_view_type;
488 using global_inds_device_view_type =
489 typename row_matrix_type::global_inds_device_view_type;
490 using global_inds_host_view_type =
491 typename row_matrix_type::global_inds_host_view_type;
492 using nonconst_global_inds_host_view_type =
493 typename row_matrix_type::nonconst_global_inds_host_view_type;
495 using values_device_view_type =
496 typename row_matrix_type::values_device_view_type;
497 using values_host_view_type =
498 typename row_matrix_type::values_host_view_type;
499 using nonconst_values_host_view_type =
500 typename row_matrix_type::nonconst_values_host_view_type;
508 GlobalOrdinal, Node>&) =
default;
512 GlobalOrdinal, Node>&&) =
default;
517 GlobalOrdinal, Node>&) =
default;
522 GlobalOrdinal, Node>&&) =
default;
538 const size_t maxNumEntriesPerRow,
539 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
554 const Teuchos::ArrayView<const size_t>& numEntPerRowToAlloc,
555 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
576 const Teuchos::RCP<const map_type>& colMap,
577 const size_t maxNumEntPerRow,
578 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
599 const Teuchos::RCP<const map_type>& colMap,
600 const Teuchos::ArrayView<const size_t>& numEntPerRowToAlloc,
601 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
631 explicit CrsMatrix(CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& matrix,
632 const Teuchos::RCP<const crs_graph_type>& graph,
633 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
659 explicit CrsMatrix(
const Teuchos::RCP<const crs_graph_type>& graph,
660 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
690 explicit CrsMatrix(
const Teuchos::RCP<const crs_graph_type>& graph,
691 const typename local_matrix_device_type::values_type& values,
692 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
721 const Teuchos::RCP<const map_type>& colMap,
722 const typename local_graph_device_type::row_map_type& rowPointers,
723 const typename local_graph_device_type::entries_type::non_const_type& columnIndices,
724 const typename local_matrix_device_type::values_type& values,
725 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
754 const Teuchos::RCP<const map_type>& colMap,
755 const Teuchos::ArrayRCP<size_t>& rowPointers,
756 const Teuchos::ArrayRCP<LocalOrdinal>& columnIndices,
757 const Teuchos::ArrayRCP<Scalar>& values,
758 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
782 const Teuchos::RCP<const map_type>& colMap,
784 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
817 const Teuchos::RCP<const map_type>& rowMap,
818 const Teuchos::RCP<const map_type>& colMap,
819 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
820 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
821 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
835 const Teuchos::RCP<const map_type>& rowMap,
836 const Teuchos::RCP<const map_type>& colMap,
837 const Teuchos::RCP<const map_type>& domainMap,
838 const Teuchos::RCP<const map_type>& rangeMap,
839 const Teuchos::RCP<const import_type>& importer,
840 const Teuchos::RCP<const export_type>& exporter,
841 const Teuchos::RCP<Teuchos::ParameterList>& params =
862 const Teuchos::RCP<const map_type>& colMap,
863 const CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& source,
864 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
869 CrsMatrix(
const CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& source,
870 const Teuchos::DataAccess copyOrView);
884 template <
class S2,
class LO2,
class GO2,
class N2>
885 friend class CrsMatrix;
888 template <
class S2,
class LO2,
class GO2,
class N2>
895 template <
class MatrixArray,
class MultiVectorArray>
897 const typename std::remove_pointer<typename MultiVectorArray::value_type>::type& X,
899 typename std::remove_pointer<typename MatrixArray::value_type>::type::scalar_type alpha,
900 typename std::remove_pointer<typename MatrixArray::value_type>::type::scalar_type beta,
901 Teuchos::RCP<Teuchos::ParameterList> params);
975 const Teuchos::ArrayView<const GlobalOrdinal>& cols,
976 const Teuchos::ArrayView<const Scalar>& vals);
994 const LocalOrdinal numEnt,
996 const GlobalOrdinal inds[]);
1042 const Teuchos::ArrayView<const LocalOrdinal>& cols,
1043 const Teuchos::ArrayView<const Scalar>& vals,
1067 const LocalOrdinal numEnt,
1068 const Scalar vals[],
1069 const LocalOrdinal cols[],
1084 virtual LocalOrdinal
1088 const GlobalOrdinal inds[],
1090 const LocalOrdinal numElts);
1132 const Kokkos::View<const global_ordinal_type*, Kokkos::AnonymousSpace>& inputInds,
1133 const Kokkos::View<const impl_scalar_type*, Kokkos::AnonymousSpace>& inputVals);
1139 const Teuchos::ArrayView<const GlobalOrdinal>& cols,
1140 const Teuchos::ArrayView<const Scalar>& vals);
1158 const LocalOrdinal numEnt,
1159 const Scalar vals[],
1160 const GlobalOrdinal cols[]);
1174 virtual LocalOrdinal
1178 const LocalOrdinal inds[],
1180 const LocalOrdinal numElts);
1221 const Kokkos::View<const local_ordinal_type*, Kokkos::AnonymousSpace>& inputInds,
1222 const Kokkos::View<const impl_scalar_type*, Kokkos::AnonymousSpace>& inputVals);
1229 const Teuchos::ArrayView<const LocalOrdinal>& cols,
1230 const Teuchos::ArrayView<const Scalar>& vals);
1251 const LocalOrdinal numEnt,
1252 const Scalar inputVals[],
1253 const LocalOrdinal inputCols[]);
1260 static const bool useAtomicUpdatesByDefault =
1261#ifdef KOKKOS_ENABLE_SERIAL
1262 !std::is_same<execution_space, Kokkos::Serial>::value;
1293 virtual LocalOrdinal
1297 const GlobalOrdinal inds[],
1299 const LocalOrdinal numElts,
1300 const bool atomic = useAtomicUpdatesByDefault);
1341 const Teuchos::ArrayView<const GlobalOrdinal>& cols,
1342 const Teuchos::ArrayView<const Scalar>& vals,
1343 const bool atomic = useAtomicUpdatesByDefault);
1369 const LocalOrdinal numEnt,
1370 const Scalar vals[],
1371 const GlobalOrdinal cols[],
1372 const bool atomic = useAtomicUpdatesByDefault);
1388 virtual LocalOrdinal
1392 const LocalOrdinal inds[],
1394 const LocalOrdinal numElts,
1395 const bool atomic = useAtomicUpdatesByDefault);
1437 const Kokkos::View<const local_ordinal_type*, Kokkos::AnonymousSpace>& inputInds,
1438 const Kokkos::View<const impl_scalar_type*, Kokkos::AnonymousSpace>& inputVals,
1439 const bool atomic = useAtomicUpdatesByDefault);
1472 const Teuchos::ArrayView<const LocalOrdinal>& cols,
1473 const Teuchos::ArrayView<const Scalar>& vals,
1474 const bool atomic = useAtomicUpdatesByDefault);
1499 const LocalOrdinal numEnt,
1500 const Scalar vals[],
1501 const LocalOrdinal cols[],
1502 const bool atomic = useAtomicUpdatesByDefault);
1539 const LocalOrdinal inds[],
1541 const LocalOrdinal numElts,
1543 const bool atomic = useAtomicUpdatesByDefault);
1579 const GlobalOrdinal inds[],
1581 const LocalOrdinal numElts,
1583 const bool atomic = useAtomicUpdatesByDefault);
1612 transformLocalValues(
const LocalOrdinal lclRow,
1613 const LocalOrdinal numInputEnt,
1615 const LocalOrdinal inputCols[],
1617 const bool atomic = useAtomicUpdatesByDefault);
1646 transformGlobalValues(
const GlobalOrdinal gblRow,
1647 const LocalOrdinal numInputEnt,
1649 const GlobalOrdinal inputCols[],
1651 const bool atomic = useAtomicUpdatesByDefault);
1697 template <
class LocalIndicesViewType,
1698 class ImplScalarViewType,
1699 class BinaryFunction>
1702 const typename UnmanagedView<LocalIndicesViewType>::type& inputInds,
1703 const typename UnmanagedView<ImplScalarViewType>::type& inputVals,
1705 const bool atomic = useAtomicUpdatesByDefault) {
1712 static_assert(Kokkos::is_view<LocalIndicesViewType>::value,
1713 "First template parameter LocalIndicesViewType must be "
1715 static_assert(Kokkos::is_view<ImplScalarViewType>::value,
1716 "Second template parameter ImplScalarViewType must be a "
1718 static_assert(
static_cast<int>(LocalIndicesViewType::rank) == 1,
1719 "First template parameter LocalIndicesViewType must "
1721 static_assert(
static_cast<int>(ImplScalarViewType::rank) == 1,
1722 "Second template parameter ImplScalarViewType must have "
1724 static_assert(std::is_same<
1725 typename LocalIndicesViewType::non_const_value_type,
1727 "First template parameter LocalIndicesViewType must "
1728 "contain values of type local_ordinal_type.");
1729 static_assert(std::is_same<
1730 typename ImplScalarViewType::non_const_value_type,
1732 "Second template parameter ImplScalarViewType must "
1733 "contain values of type impl_scalar_type.");
1734 typedef LocalOrdinal LO;
1735 const LO numInputEnt = inputInds.extent(0);
1736 if (
static_cast<LO
>(inputVals.extent(0)) != numInputEnt) {
1737 return Teuchos::OrdinalTraits<LO>::invalid();
1739 return this->transformLocalValues(lclRow,
1788 template <
class BinaryFunction,
class InputMemorySpace>
1791 const Kokkos::View<
const GlobalOrdinal*,
1793 Kokkos::MemoryUnmanaged>& inputInds,
1796 Kokkos::MemoryUnmanaged>& inputVals,
1798 const bool atomic = useAtomicUpdatesByDefault) {
1799 typedef LocalOrdinal LO;
1800 const LO numInputEnt = inputInds.extent(0);
1801 if (
static_cast<LO
>(inputVals.extent(0)) != numInputEnt) {
1802 return Teuchos::OrdinalTraits<LO>::invalid();
1804 return this->transformGlobalValues(gblRow,
1844 const typename local_graph_device_type::entries_type::non_const_type& ind,
1845 const typename local_matrix_device_type::values_type& val);
1896 const Teuchos::ArrayRCP<LocalOrdinal>& ind,
1897 const Teuchos::ArrayRCP<Scalar>& val);
1958 void resumeFill(
const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
2019 const Teuchos::RCP<const map_type>& rangeMap,
2020 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
2049 fillComplete(
const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
2079 const Teuchos::RCP<const map_type>& rangeMap,
2080 const Teuchos::RCP<const import_type>& importer = Teuchos::null,
2081 const Teuchos::RCP<const export_type>& exporter = Teuchos::null,
2082 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
2187 const Teuchos::RCP<const map_type>& newColMap,
2188 const Teuchos::RCP<const import_type>& newImport = Teuchos::null,
2189 const bool sortEachRow =
true);
2218 Teuchos::RCP<const import_type>& newImporter);
2247 Teuchos::RCP<const export_type>& newExporter);
2270 Teuchos::RCP<const Teuchos::Comm<int> >
getComm()
const override;
2279 Teuchos::RCP<const RowGraph<LocalOrdinal, GlobalOrdinal, Node> >
2299#if __armclang_major__ == 22 && __armclang_minor__ == 1
2304#define TPETRA_DETAILS_ALWAYS_INLINE __attribute__((always_inline))
2306#define TPETRA_DETAILS_ALWAYS_INLINE
2322 local_matrix_host_type getLocalMatrixHost()
const;
2323#undef TPETRA_DETAILS_ALWAYS_INLINE
2553 using values_dualv_type =
2554 Kokkos::DualView<impl_scalar_type*, device_type>;
2555 using values_wdv_type =
2557 values_wdv_type valuesUnpacked_wdv;
2558 mutable values_wdv_type valuesPacked_wdv;
2611 nonconst_global_inds_host_view_type& Indices,
2612 nonconst_values_host_view_type& Values,
2613 size_t& NumEntries)
const override;
2631 nonconst_local_inds_host_view_type& Indices,
2632 nonconst_values_host_view_type& Values,
2633 size_t& NumEntries)
const override;
2650 global_inds_host_view_type& indices,
2651 values_host_view_type& values)
const override;
2667 local_inds_host_view_type& indices,
2668 values_host_view_type& values)
const override;
2756 Kokkos::MemoryUnmanaged>& offsets)
const;
2782 const Teuchos::ArrayView<const size_t>& offsets)
const;
2866 const Teuchos::ETransp mode = Teuchos::NO_TRANS,
2867 const Scalar& alpha = Teuchos::ScalarTraits<Scalar>::one(),
2868 const Scalar& beta = Teuchos::ScalarTraits<Scalar>::zero())
const;
2873 Teuchos::RCP<CrsMatrix<T, LocalOrdinal, GlobalOrdinal, Node> >
2900 Teuchos::ETransp mode = Teuchos::NO_TRANS,
2901 Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
2902 Scalar beta = Teuchos::ScalarTraits<Scalar>::zero())
const override;
2938 virtual Teuchos::RCP<RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
2944 const Teuchos::RCP<Teuchos::ParameterList>& params)
const override;
2957 const Teuchos::EVerbosityLevel verbLevel =
2958 Teuchos::Describable::verbLevel_default)
const override;
2968 typedef typename DistObject<Scalar, LocalOrdinal, GlobalOrdinal,
2976 const typename crs_graph_type::padding_type& padding,
2977 const bool verbose);
2981 copyAndPermuteStaticGraph(
2983 const size_t numSameIDs,
2984 const LocalOrdinal permuteToLIDs[],
2985 const LocalOrdinal permuteFromLIDs[],
2986 const size_t numPermutes);
2989 copyAndPermuteNonStaticGraph(
2991 const size_t numSameIDs,
2992 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteToLIDs_dv,
2993 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteFromLIDs_dv,
2994 const size_t numPermutes);
2997 using dist_object_type::
3003 const size_t numSameIDs,
3004 const Kokkos::DualView<
3007 const Kokkos::DualView<
3014 const Kokkos::DualView<
3017 Kokkos::DualView<char*, buffer_device_type>& exports,
3018 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
3019 size_t& constantNumPackets)
override;
3030 unpackAndCombineImpl(
3033 Kokkos::DualView<char*, buffer_device_type> imports,
3034 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
3035 const size_t constantNumPackets,
3037 const bool verbose);
3042 unpackAndCombineImplNonStatic(
3045 Kokkos::DualView<char*, buffer_device_type> imports,
3046 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
3047 const size_t constantNumPackets,
3061 unpackAndCombine(
const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& importLIDs,
3062 Kokkos::DualView<char*, buffer_device_type> imports,
3063 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
3064 const size_t constantNumPackets,
3178 packNew(
const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& exportLIDs,
3179 Kokkos::DualView<char*, buffer_device_type>& exports,
3180 const Kokkos::DualView<size_t*, buffer_device_type>& numPacketsPerLID,
3181 size_t& constantNumPackets)
const;
3191 packNonStaticNew(
const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& exportLIDs,
3192 Kokkos::DualView<char*, buffer_device_type>& exports,
3193 const Kokkos::DualView<size_t*, buffer_device_type>& numPacketsPerLID,
3194 size_t& constantNumPackets)
const;
3226 packRow(
char exports[],
3227 const size_t offset,
3228 const size_t numEnt,
3229 const GlobalOrdinal gidsIn[],
3231 const size_t numBytesPerValue)
const;
3257 packRowStatic(
char*
const numEntOut,
3260 const size_t numEnt,
3261 const LocalOrdinal lclRow)
const;
3289 unpackRow(GlobalOrdinal gidsOut[],
3291 const char imports[],
3292 const size_t offset,
3293 const size_t numBytes,
3294 const size_t numEnt,
3295 const size_t numBytesPerValue);
3306 allocatePackSpaceNew(Kokkos::DualView<char*, buffer_device_type>& exports,
3307 size_t& totalNumEntries,
3314 typename local_matrix_host_type::values_type::const_type
3316 return valuesPacked_wdv.getHostView(s);
3320 typename local_matrix_host_type::values_type
3322 return valuesPacked_wdv.getHostView(s);
3326 typename local_matrix_host_type::values_type
3328 return valuesPacked_wdv.getHostView(s);
3332 typename local_matrix_device_type::values_type::const_type
3334 return valuesPacked_wdv.getDeviceView(s);
3338 typename local_matrix_device_type::values_type
3340 return valuesPacked_wdv.getDeviceView(s);
3344 typename local_matrix_device_type::values_type
3346 return valuesPacked_wdv.getDeviceView(s);
3351 template <
class CrsMatrixType>
3352 friend Teuchos::RCP<CrsMatrixType>
3354 const Import<
typename CrsMatrixType::local_ordinal_type,
3355 typename CrsMatrixType::global_ordinal_type,
3356 typename CrsMatrixType::node_type>& importer,
3357 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3358 typename CrsMatrixType::global_ordinal_type,
3359 typename CrsMatrixType::node_type> >& domainMap,
3360 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3361 typename CrsMatrixType::global_ordinal_type,
3362 typename CrsMatrixType::node_type> >& rangeMap,
3363 const Teuchos::RCP<Teuchos::ParameterList>& params);
3366 template <
class CrsMatrixType>
3367 friend Teuchos::RCP<CrsMatrixType>
3369 const Import<
typename CrsMatrixType::local_ordinal_type,
3370 typename CrsMatrixType::global_ordinal_type,
3371 typename CrsMatrixType::node_type>& rowImporter,
3372 const Import<
typename CrsMatrixType::local_ordinal_type,
3373 typename CrsMatrixType::global_ordinal_type,
3374 typename CrsMatrixType::node_type>& domainImporter,
3375 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3376 typename CrsMatrixType::global_ordinal_type,
3377 typename CrsMatrixType::node_type> >& domainMap,
3378 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3379 typename CrsMatrixType::global_ordinal_type,
3380 typename CrsMatrixType::node_type> >& rangeMap,
3381 const Teuchos::RCP<Teuchos::ParameterList>& params);
3384 template <
class CrsMatrixType>
3385 friend Teuchos::RCP<CrsMatrixType>
3387 const Export<
typename CrsMatrixType::local_ordinal_type,
3388 typename CrsMatrixType::global_ordinal_type,
3389 typename CrsMatrixType::node_type>& exporter,
3390 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3391 typename CrsMatrixType::global_ordinal_type,
3392 typename CrsMatrixType::node_type> >& domainMap,
3393 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3394 typename CrsMatrixType::global_ordinal_type,
3395 typename CrsMatrixType::node_type> >& rangeMap,
3396 const Teuchos::RCP<Teuchos::ParameterList>& params);
3399 template <
class CrsMatrixType>
3400 friend Teuchos::RCP<CrsMatrixType>
3402 const Export<
typename CrsMatrixType::local_ordinal_type,
3403 typename CrsMatrixType::global_ordinal_type,
3404 typename CrsMatrixType::node_type>& rowExporter,
3405 const Export<
typename CrsMatrixType::local_ordinal_type,
3406 typename CrsMatrixType::global_ordinal_type,
3407 typename CrsMatrixType::node_type>& domainExporter,
3408 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3409 typename CrsMatrixType::global_ordinal_type,
3410 typename CrsMatrixType::node_type> >& domainMap,
3411 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3412 typename CrsMatrixType::global_ordinal_type,
3413 typename CrsMatrixType::node_type> >& rangeMap,
3414 const Teuchos::RCP<Teuchos::ParameterList>& params);
3435 const Teuchos::RCP<const map_type>& domainMap,
3436 const Teuchos::RCP<const map_type>& rangeMap,
3437 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
3458 const Teuchos::RCP<const map_type>& domainMap,
3459 const Teuchos::RCP<const map_type>& rangeMap,
3460 const Teuchos::RCP<Teuchos::ParameterList>& params)
const;
3480 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
3481 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
3482 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
3503 const Teuchos::RCP<const map_type>& domainMap,
3504 const Teuchos::RCP<const map_type>& rangeMap,
3505 const Teuchos::RCP<Teuchos::ParameterList>& params)
const;
3529 transferAndFillComplete(Teuchos::RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >& destMatrix,
3530 const ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node>& rowTransfer,
3531 const Teuchos::RCP<const ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node> >& domainTransfer,
3532 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
3533 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
3534 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
3551 const GlobalOrdinal gblColInds[],
3553 const size_t numInputEnt);
3566 insertGlobalValuesFiltered(
3567 const GlobalOrdinal globalRow,
3568 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3569 const Teuchos::ArrayView<const Scalar>& values,
3575 insertGlobalValuesFilteredChecked(
3576 const GlobalOrdinal globalRow,
3577 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3578 const Teuchos::ArrayView<const Scalar>& values,
3579 const char*
const prefix,
3581 const bool verbose);
3595 combineGlobalValues(
3596 const GlobalOrdinal globalRowIndex,
3597 const Teuchos::ArrayView<const GlobalOrdinal>& columnIndices,
3598 const Teuchos::ArrayView<const Scalar>& values,
3600 const char*
const prefix,
3602 const bool verbose);
3626 combineGlobalValuesRaw(
const LocalOrdinal lclRow,
3627 const LocalOrdinal numEnt,
3629 const GlobalOrdinal cols[],
3631 const char*
const prefix,
3633 const bool verbose);
3646 template <
class BinaryFunction>
3648 transformGlobalValues(
const GlobalOrdinal globalRow,
3649 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3650 const Teuchos::ArrayView<const Scalar>& values,
3652 const bool atomic = useAtomicUpdatesByDefault) {
3654 typedef LocalOrdinal LO;
3655 typedef GlobalOrdinal GO;
3657 const LO numInputEnt =
static_cast<LO
>(indices.size());
3658 if (
static_cast<LO
>(values.size()) != numInputEnt) {
3659 return Teuchos::OrdinalTraits<LO>::invalid();
3662 const GO*
const inputCols = indices.getRawPtr();
3663 const IST*
const inputVals =
3664 reinterpret_cast<const IST*
>(values.getRawPtr());
3665 return this->transformGlobalValues(globalRow, numInputEnt, inputVals,
3666 inputCols, f, atomic);
3676 insertNonownedGlobalValues(
const GlobalOrdinal globalRow,
3677 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3678 const Teuchos::ArrayView<const Scalar>& values);
3725 const typename crs_graph_type::SLocalGlobalViews& newInds,
3726 const Teuchos::ArrayView<impl_scalar_type>& oldRowVals,
3727 const Teuchos::ArrayView<const impl_scalar_type>& newRowVals,
3728 const ELocalGlobal lg,
3729 const ELocalGlobal I);
3733 typedef Teuchos::OrdinalTraits<LocalOrdinal> OTL;
3734 typedef KokkosKernels::ArithTraits<impl_scalar_type> STS;
3735 typedef KokkosKernels::ArithTraits<mag_type> STM;
3736 typedef MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> MV;
3737 typedef Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> V;
3741 enum GraphAllocationStatus {
3742 GraphAlreadyAllocated,
3743 GraphNotYetAllocated
3766 const bool verbose);
3840 const bool force =
false)
const;
3865 const bool force =
false)
const;
3890 const Teuchos::ETransp mode,
3898 typename values_dualv_type::t_host::const_type
3903 typename values_dualv_type::t_dev::const_type
3908 typename values_dualv_type::t_host
3913 typename values_dualv_type::t_dev
3921 using local_matrix_int_rowptrs_device_type =
3931 local_matrix_int_rowptrs_device_type,
3932 typename MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::device_view_type>;
3934 std::shared_ptr<ApplyHelper> getApplyHelper()
const {
3937 applyHelper = std::make_shared<ApplyHelper>(A_lcl.nnz(), A_lcl.graph.row_map);
3944 friend class Tpetra::crsMatrix_Swap_Tester<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
3948 template <
typename S,
typename LO,
typename GO,
typename NODE,
typename LOV>
3949 friend struct Tpetra::MMdetails::KernelWrappers;
3950 template <
typename S,
typename LO,
typename GO,
typename NODE,
typename LOV>
3951 friend struct Tpetra::MMdetails::KernelWrappers2;
3960 friend struct Tpetra::MMdetails::CrsMatrixApplyHelperAccess;
3963 friend void Tpetra::MMdetails::import_and_extract_views<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
3964 const CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
3965 Teuchos::RCP<
const Map<LocalOrdinal, GlobalOrdinal, Node> > targetMap,
3966 CrsMatrixStruct<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Aview,
3967 Teuchos::RCP<
const Import<LocalOrdinal, GlobalOrdinal, Node> > prototypeImporter,
3968 bool userAssertsThereAreNoRemotes,
3969 const std::string& label,
3970 const Teuchos::RCP<Teuchos::ParameterList>& params);
3975 void swap(CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& matrix);
4007 Teuchos::RCP<const Graph> staticGraph_;
4008 Teuchos::RCP<Graph> myGraph_;
4022 Details::STORAGE_1D_UNPACKED;
4054 std::map<GlobalOrdinal, std::pair<Teuchos::Array<GlobalOrdinal>,
4055 Teuchos::Array<Scalar> > >
4064 mutable std::shared_ptr<ApplyHelper> applyHelper;
4071 template <
class DestViewType,
class SrcViewType,
4072 class DestOffsetViewType,
class SrcOffsetViewType>
4073 struct pack_functor {
4077 SrcOffsetViewType src_offset_;
4078 DestOffsetViewType dst_offset_;
4079 typedef typename DestOffsetViewType::non_const_value_type scalar_index_type;
4081 pack_functor(DestViewType dst,
4082 const SrcViewType src,
4083 DestOffsetViewType dst_offset,
4084 const SrcOffsetViewType src_offset)
4087 , src_offset_(src_offset)
4088 , dst_offset_(dst_offset) {}
4090 KOKKOS_INLINE_FUNCTION
4091 void operator()(
const LocalOrdinal row)
const {
4092 scalar_index_type srcPos = src_offset_(row);
4093 const scalar_index_type dstEnd = dst_offset_(row + 1);
4094 scalar_index_type dstPos = dst_offset_(row);
4095 for (; dstPos < dstEnd; ++dstPos, ++srcPos) {
4096 dst_(dstPos) = src_(srcPos);
4106template <
class Scalar,
4108 class GlobalOrdinal,
4110Teuchos::RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
4113 const size_t maxNumEntriesPerRow = 0,
4114 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) {
4116 CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
4117 return Teuchos::rcp(
new matrix_type(map, maxNumEntriesPerRow,
4121template <
class CrsMatrixType>
4122Teuchos::RCP<CrsMatrixType>
4124 const Import<
typename CrsMatrixType::local_ordinal_type,
4125 typename CrsMatrixType::global_ordinal_type,
4126 typename CrsMatrixType::node_type>& importer,
4127 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4128 typename CrsMatrixType::global_ordinal_type,
4129 typename CrsMatrixType::node_type> >& domainMap,
4130 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4131 typename CrsMatrixType::global_ordinal_type,
4132 typename CrsMatrixType::node_type> >& rangeMap,
4133 const Teuchos::RCP<Teuchos::ParameterList>& params) {
4134 Teuchos::RCP<CrsMatrixType> destMatrix;
4135 sourceMatrix->importAndFillComplete(destMatrix, importer, domainMap, rangeMap, params);
4139template <
class CrsMatrixType>
4140Teuchos::RCP<CrsMatrixType>
4142 const Import<
typename CrsMatrixType::local_ordinal_type,
4143 typename CrsMatrixType::global_ordinal_type,
4144 typename CrsMatrixType::node_type>& rowImporter,
4145 const Import<
typename CrsMatrixType::local_ordinal_type,
4146 typename CrsMatrixType::global_ordinal_type,
4147 typename CrsMatrixType::node_type>& domainImporter,
4148 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4149 typename CrsMatrixType::global_ordinal_type,
4150 typename CrsMatrixType::node_type> >& domainMap,
4151 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4152 typename CrsMatrixType::global_ordinal_type,
4153 typename CrsMatrixType::node_type> >& rangeMap,
4154 const Teuchos::RCP<Teuchos::ParameterList>& params) {
4155 Teuchos::RCP<CrsMatrixType> destMatrix;
4156 sourceMatrix->importAndFillComplete(destMatrix, rowImporter, domainImporter, domainMap, rangeMap, params);
4160template <
class CrsMatrixType>
4161Teuchos::RCP<CrsMatrixType>
4163 const Export<
typename CrsMatrixType::local_ordinal_type,
4164 typename CrsMatrixType::global_ordinal_type,
4165 typename CrsMatrixType::node_type>& exporter,
4166 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4167 typename CrsMatrixType::global_ordinal_type,
4168 typename CrsMatrixType::node_type> >& domainMap,
4169 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4170 typename CrsMatrixType::global_ordinal_type,
4171 typename CrsMatrixType::node_type> >& rangeMap,
4172 const Teuchos::RCP<Teuchos::ParameterList>& params) {
4173 Teuchos::RCP<CrsMatrixType> destMatrix;
4174 sourceMatrix->exportAndFillComplete(destMatrix, exporter, domainMap, rangeMap, params);
4178template <
class CrsMatrixType>
4179Teuchos::RCP<CrsMatrixType>
4181 const Export<
typename CrsMatrixType::local_ordinal_type,
4182 typename CrsMatrixType::global_ordinal_type,
4183 typename CrsMatrixType::node_type>& rowExporter,
4184 const Export<
typename CrsMatrixType::local_ordinal_type,
4185 typename CrsMatrixType::global_ordinal_type,
4186 typename CrsMatrixType::node_type>& domainExporter,
4187 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4188 typename CrsMatrixType::global_ordinal_type,
4189 typename CrsMatrixType::node_type> >& domainMap,
4190 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4191 typename CrsMatrixType::global_ordinal_type,
4192 typename CrsMatrixType::node_type> >& rangeMap,
4193 const Teuchos::RCP<Teuchos::ParameterList>& params) {
4194 Teuchos::RCP<CrsMatrixType> destMatrix;
4195 sourceMatrix->exportAndFillComplete(destMatrix, rowExporter, domainExporter, domainMap, rangeMap, params);
4205template <
class CrsMatrixType>
4207 typename Teuchos::ScalarTraits<typename CrsMatrixType::scalar_type>::magnitudeType
const& threshold =
4208 Teuchos::ScalarTraits<typename CrsMatrixType::scalar_type>::magnitude(Teuchos::ScalarTraits<typename CrsMatrixType::scalar_type>::zero())) {
4209 auto localMatrix = matrix.getLocalMatrixDevice();
4210 size_t nnzBefore = localMatrix.nnz();
4211 localMatrix = KokkosSparse::removeCrsMatrixZeros(localMatrix, threshold);
4212 size_t localNNZRemoved = nnzBefore - localMatrix.nnz();
4215 size_t globalNNZRemoved = 0;
4216 Teuchos::reduceAll<int, size_t>(*(matrix.getComm()), Teuchos::REDUCE_SUM, 1, &localNNZRemoved, &globalNNZRemoved);
4217 if (globalNNZRemoved !=
size_t(0)) {
4218 matrix.resumeFill();
4219 matrix.setAllValues(localMatrix);
4220 matrix.expertStaticFillComplete(matrix.getDomainMap(), matrix.getRangeMap());
Forward declaration of Tpetra::CrsMatrix.
Declaration and generic definition of traits class that tells Tpetra::CrsMatrix how to pack and unpac...
Forward declaration of some Tpetra Matrix Matrix objects.
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
KokkosSparse::StaticCrsGraph< local_ordinal_type, Kokkos::LayoutLeft, device_type, void, size_t > local_graph_device_type
The type of the part of the sparse graph on each MPI process.
typename local_graph_device_type::host_mirror_type local_graph_host_type
The type of the part of the sparse graph on each MPI process.
virtual void insertGlobalValuesImpl(crs_graph_type &graph, RowInfo &rowInfo, const GlobalOrdinal gblColInds[], const impl_scalar_type vals[], const size_t numInputEnt)
Common implementation detail of insertGlobalValues and insertGlobalValuesFiltered.
bool isGloballyIndexed() const override
Whether the matrix is globally indexed on the calling process.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const override
Print this object with the given verbosity level to the given output stream.
CrsMatrix(const Teuchos::RCP< const map_type > &rowMap, const Teuchos::RCP< const map_type > &colMap, const Teuchos::ArrayRCP< size_t > &rowPointers, const Teuchos::ArrayRCP< LocalOrdinal > &columnIndices, const Teuchos::ArrayRCP< Scalar > &values, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Constructor specifying column Map and arrays containing the local matrix. In almost all cases the loc...
std::map< GO, std::pair< Teuchos::Array< GO >, Teuchos::Array< SC > > > nonlocals_
void localApply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, const Teuchos::ETransp mode=Teuchos::NO_TRANS, const Scalar &alpha=Teuchos::ScalarTraits< Scalar >::one(), const Scalar &beta=Teuchos::ScalarTraits< Scalar >::zero()) const
Compute the local part of a sparse matrix-(Multi)Vector multiply.
void unpackAndCombine(const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &importLIDs, Kokkos::DualView< char *, buffer_device_type > imports, Kokkos::DualView< size_t *, buffer_device_type > numPacketsPerLID, const size_t constantNumPackets, const CombineMode CM) override
Unpack the imported column indices and values, and combine into matrix.
LocalOrdinal replaceLocalValues(const LocalOrdinal localRow, const LocalOrdinal numEnt, const Scalar inputVals[], const LocalOrdinal inputCols[])
Epetra compatibility version of replaceLocalValues, that takes raw pointers instead of Kokkos::View.
CrsMatrix & operator=(const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &)=default
Copy assignment.
void replaceRangeMap(const Teuchos::RCP< const map_type > &newRangeMap)
Replace the current range Map with the given objects.
Details::EStorageStatus storageStatus_
typename device_type::execution_space execution_space
void importAndFillComplete(Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &destMatrix, const import_type &rowImporter, const import_type &domainImporter, const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms) const
Import from this to the given destination matrix, and make the result fill complete.
LocalOrdinal sumIntoGlobalValues(const GlobalOrdinal globalRow, const LocalOrdinal numEnt, const Scalar vals[], const GlobalOrdinal cols[], const bool atomic=useAtomicUpdatesByDefault)
Epetra compatibility version of sumIntoGlobalValues (see above), that takes input as raw pointers ins...
void applyNonTranspose(const MV &X_in, MV &Y_in, Scalar alpha, Scalar beta) const
void importAndFillComplete(Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &destMatrix, const import_type &importer, const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null) const
Import from this to the given destination matrix, and make the result fill complete.
CrsGraph< LO, GO, NT > crs_graph_type
local_ordinal_type replaceGlobalValues(const global_ordinal_type globalRow, const Kokkos::View< const global_ordinal_type *, Kokkos::AnonymousSpace > &inputInds, const Kokkos::View< const impl_scalar_type *, Kokkos::AnonymousSpace > &inputVals)
Replace one or more entries' values, using global indices.
Teuchos::RCP< CrsMatrixType > importAndFillCompleteCrsMatrix(const Teuchos::RCP< const CrsMatrixType > &sourceMatrix, const Import< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &rowImporter, const Import< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &domainImporter, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &domainMap, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Nonmember CrsMatrix constructor that fuses Import and fillComplete().
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
size_t getGlobalMaxNumRowEntries() const override
Maximum number of entries in any row of the matrix, over all processes in the matrix's communicator.
void getGlobalRowCopy(GlobalOrdinal GlobalRow, nonconst_global_inds_host_view_type &Indices, nonconst_values_host_view_type &Values, size_t &NumEntries) const override
Fill given arrays with a deep copy of the locally owned entries of the matrix in a given row,...
LocalOrdinal replaceGlobalValues(const GlobalOrdinal globalRow, const LocalOrdinal numEnt, const Scalar vals[], const GlobalOrdinal cols[])
Overload of replaceGlobalValues (see above), that takes raw pointers instead of Kokkos::View.
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const override
Number of entries in the sparse matrix in the given global row, on the calling (MPI) process.
void scale(const Scalar &alpha)
Scale the matrix's values: this := alpha*this.
void sortAndMergeIndicesAndValues(const bool sorted, const bool merged)
Sort and merge duplicate local column indices in all rows on the calling process, along with their co...
void packNew(const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &exportLIDs, Kokkos::DualView< char *, buffer_device_type > &exports, const Kokkos::DualView< size_t *, buffer_device_type > &numPacketsPerLID, size_t &constantNumPackets) const
Pack this object's data for an Import or Export.
size_t getLocalNumCols() const override
The number of columns connected to the locally owned rows of this matrix.
Teuchos::RCP< const map_type > getDomainMap() const override
The domain Map of this matrix.
bool hasColMap() const override
Whether the matrix has a well-defined column Map.
row_ptrs_host_view_type getLocalRowPtrsHost() const
Get a host view of the CRS packed row pointers.
mag_type getNormInf() const
Compute and return the infinity norm of the matrix.
Teuchos::RCP< CrsMatrix< T, LocalOrdinal, GlobalOrdinal, Node > > convert() const
Return another CrsMatrix with the same entries, but converted to a different Scalar type T.
values_dualv_type::t_dev getValuesViewDeviceNonConst(const RowInfo &rowinfo)
Get a non-const Device view of the locally owned values row myRow, such that rowinfo = getRowInfo(myR...
void expertStaticFillComplete(const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap, const Teuchos::RCP< const import_type > &importer=Teuchos::null, const Teuchos::RCP< const export_type > &exporter=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Perform a fillComplete on a matrix that already has data.
CrsMatrix(const Teuchos::RCP< const crs_graph_type > &graph, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Constructor specifying a previously constructed graph.
LocalOrdinal transformLocalValues(const LocalOrdinal lclRow, const typename UnmanagedView< LocalIndicesViewType >::type &inputInds, const typename UnmanagedView< ImplScalarViewType >::type &inputVals, BinaryFunction f, const bool atomic=useAtomicUpdatesByDefault)
Transform CrsMatrix entries in place, using local indices to select the entries in the row to transfo...
local_ordinal_type sumIntoLocalValues(const local_ordinal_type localRow, const Kokkos::View< const local_ordinal_type *, Kokkos::AnonymousSpace > &inputInds, const Kokkos::View< const impl_scalar_type *, Kokkos::AnonymousSpace > &inputVals, const bool atomic=useAtomicUpdatesByDefault)
Sum into one or more sparse matrix entries, using local row and column indices.
LocalOrdinal sumIntoLocalValues(const LocalOrdinal localRow, const LocalOrdinal numEnt, const Scalar vals[], const LocalOrdinal cols[], const bool atomic=useAtomicUpdatesByDefault)
Epetra compatibility version of sumIntoLocalValues (see above) that takes raw pointers instead of Kok...
virtual Teuchos::RCP< RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > add(const Scalar &alpha, const RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms) const override
Implementation of RowMatrix::add: return alpha*A + beta*this.
CrsMatrix(CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &&)=default
Move constructor.
CrsMatrix(const Teuchos::RCP< const map_type > &rowMap, const Teuchos::ArrayView< const size_t > &numEntPerRowToAlloc, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Constructor specifying (possibly different) number of entries in each row.
void applyTranspose(const MV &X_in, MV &Y_in, const Teuchos::ETransp mode, Scalar alpha, Scalar beta) const
size_t getNumEntriesInLocalRow(local_ordinal_type localRow) const override
Number of entries in the sparse matrix in the given local row, on the calling (MPI) process.
Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > createCrsMatrix(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, const size_t maxNumEntriesPerRow=0, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Create an empty CrsMatrix given a row map and a single integer upper bound on the number of stored en...
Teuchos::RCP< MV > exportMV_
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const override
The communicator over which the matrix is distributed.
bool isFillActive() const
Whether the matrix is not fill complete.
CrsMatrix(const Teuchos::RCP< const map_type > &rowMap, const Teuchos::RCP< const map_type > &colMap, const local_matrix_device_type &lclMatrix, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Constructor specifying column Map and a local matrix, which the resulting CrsMatrix views.
RowMatrix< SC, LO, GO, NT > row_matrix_type
void replaceDomainMapAndImporter(const Teuchos::RCP< const map_type > &newDomainMap, Teuchos::RCP< const import_type > &newImporter)
Replace the current domain Map and Import with the given objects.
local_matrix_host_type::values_type getLocalValuesHost(Access::ReadWriteStruct s)
Get the Kokkos local values on host, read write.
LocalOrdinal sumIntoGlobalValues(const GlobalOrdinal globalRow, const Teuchos::ArrayView< const GlobalOrdinal > &cols, const Teuchos::ArrayView< const Scalar > &vals, const bool atomic=useAtomicUpdatesByDefault)
Sum into one or more sparse matrix entries, using global indices.
mag_type getNorm1(bool assumeSymmetric=false) const
Compute and return the 1-norm of the matrix.
void setAllValues(const Teuchos::ArrayRCP< size_t > &ptr, const Teuchos::ArrayRCP< LocalOrdinal > &ind, const Teuchos::ArrayRCP< Scalar > &val)
Set the local matrix using three (compressed sparse row) arrays.
virtual ~CrsMatrix()=default
Destructor (virtual for memory safety of derived classes).
void apply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const override
Compute a sparse matrix-MultiVector multiply.
mag_type getFrobeniusNorm() const override
Compute and return the Frobenius norm of the matrix.
void insertLocalValues(const LocalOrdinal localRow, const Teuchos::ArrayView< const LocalOrdinal > &cols, const Teuchos::ArrayView< const Scalar > &vals, const CombineMode CM=ADD)
Insert one or more entries into the matrix, using local column indices.
global_size_t getGlobalNumCols() const override
The number of global columns in the matrix.
Teuchos::RCP< const map_type > getRangeMap() const override
The range Map of this matrix.
Teuchos::RCP< MV > importMV_
CrsMatrix(const local_matrix_device_type &lclMatrix, const Teuchos::RCP< const map_type > &rowMap, const Teuchos::RCP< const map_type > &colMap, const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap, const Teuchos::RCP< const import_type > &importer, const Teuchos::RCP< const export_type > &exporter, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
void allocateValues(ELocalGlobal lg, GraphAllocationStatus gas, const bool verbose)
Allocate values (and optionally indices) using the Node.
size_t getLocalNumEntries() const override
The local number of entries in this matrix.
Map< LO, GO, NT > map_type
typename NT::device_type device_type
typename KokkosKernels::ArithTraits< impl_scalar_type >::mag_type mag_type
virtual LocalOrdinal sumIntoGlobalValuesImpl(impl_scalar_type rowVals[], const crs_graph_type &graph, const RowInfo &rowInfo, const GlobalOrdinal inds[], const impl_scalar_type newVals[], const LocalOrdinal numElts, const bool atomic=useAtomicUpdatesByDefault)
Implementation detail of sumIntoGlobalValues.
void replaceDomainMap(const Teuchos::RCP< const map_type > &newDomainMap)
Replace the current domain Map with the given objects.
CrsMatrix(const local_matrix_device_type &lclMatrix, const Teuchos::RCP< const map_type > &rowMap, const Teuchos::RCP< const map_type > &colMap, const Teuchos::RCP< const map_type > &domainMap=Teuchos::null, const Teuchos::RCP< const map_type > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Constructor specifying column, domain and range Maps, and a local matrix, which the resulting CrsMatr...
friend void batchedApply(const MatrixArray &Matrices, const typename std::remove_pointer< typename MultiVectorArray::value_type >::type &X, MultiVectorArray &Y, typename std::remove_pointer< typename MatrixArray::value_type >::type::scalar_type alpha, typename std::remove_pointer< typename MatrixArray::value_type >::type::scalar_type beta, Teuchos::RCP< Teuchos::ParameterList > params)
Does multiply matrix apply() calls with a single X vector.
void removeCrsMatrixZeros(CrsMatrixType &matrix, typename Teuchos::ScalarTraits< typename CrsMatrixType::scalar_type >::magnitudeType const &threshold=Teuchos::ScalarTraits< typename CrsMatrixType::scalar_type >::magnitude(Teuchos::ScalarTraits< typename CrsMatrixType::scalar_type >::zero()))
Remove zero entries from a matrix.
std::string description() const override
A one-line description of this object.
CrsMatrix(const Teuchos::RCP< const map_type > &rowMap, const size_t maxNumEntriesPerRow, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Constructor specifying the maximum number of entries that any row on the process can take.
CrsMatrix(const Teuchos::RCP< const map_type > &rowMap, const Teuchos::RCP< const map_type > &colMap, const typename local_graph_device_type::row_map_type &rowPointers, const typename local_graph_device_type::entries_type::non_const_type &columnIndices, const typename local_matrix_device_type::values_type &values, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Constructor specifying column Map and arrays containing the matrix in local indices....
void reindexColumns(crs_graph_type *const graph, const Teuchos::RCP< const map_type > &newColMap, const Teuchos::RCP< const import_type > &newImport=Teuchos::null, const bool sortEachRow=true)
Reindex the column indices in place, and replace the column Map. Optionally, replace the Import objec...
Teuchos::RCP< MV > getColumnMapMultiVector(const MV &X_domainMap, const bool force=false) const
Create a (or fetch a cached) column Map MultiVector.
void replaceRangeMapAndExporter(const Teuchos::RCP< const map_type > &newRangeMap, Teuchos::RCP< const export_type > &newExporter)
Replace the current Range Map and Export with the given objects.
size_t getLocalMaxNumRowEntries() const override
Maximum number of entries in any row of the matrix, on this process.
void replaceColMap(const Teuchos::RCP< const map_type > &newColMap)
Replace the matrix's column Map with the given Map.
global_size_t getGlobalNumRows() const override
Number of global elements in the row map of this matrix.
local_matrix_host_type::values_type::const_type getLocalValuesHost(Access::ReadOnlyStruct s) const
Get the Kokkos local values on host, read only.
void globalAssemble()
Communicate nonlocal contributions to other processes.
void checkInternalState() const
Check that this object's state is sane; throw if it's not.
bool hasTransposeApply() const override
Whether apply() allows applying the transpose or conjugate transpose.
GlobalOrdinal getIndexBase() const override
The index base for global indices for this matrix.
void insertGlobalValues(const GlobalOrdinal globalRow, const LocalOrdinal numEnt, const Scalar vals[], const GlobalOrdinal inds[])
Epetra compatibility version of insertGlobalValues (see above) that takes arguments as raw pointers,...
CrsMatrix(CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &matrix, const Teuchos::RCP< const crs_graph_type > &graph, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Constructor specifying a matrix and a previously constructed graph, presumably a subset of the matrix...
CrsMatrix(const Teuchos::RCP< const crs_graph_type > &graph, const typename local_matrix_device_type::values_type &values, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Constructor specifying a previously constructed graph and entries array.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const override
Get a constant, nonpersisting view of a row of this matrix, using local row and column indices,...
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to alpha.
void fillLocalGraphAndMatrix(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Fill data into the local graph and matrix.
DistObject< SC, LO, GO, NT >::buffer_device_type buffer_device_type
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag, const Teuchos::ArrayView< const size_t > &offsets) const
Variant of getLocalDiagCopy() that uses precomputed offsets.
row_ptrs_device_view_type getLocalRowPtrsDevice() const
Get a device view of the CRS packed row pointers.
Export< LO, GO, NT > export_type
local_inds_host_view_type getLocalIndicesHost() const
Get a host view of the CRS packed column indicies.
TPETRA_DETAILS_ALWAYS_INLINE local_matrix_device_type getLocalMatrixDevice() const
The local sparse matrix.
void getLocalRowView(LocalOrdinal LocalRow, local_inds_host_view_type &indices, values_host_view_type &values) const override
Get a constant view of a row of this matrix, using local row and column indices.
Teuchos::RCP< const map_type > getColMap() const override
The Map that describes the column distribution in this matrix.
LocalOrdinal replaceGlobalValues(const GlobalOrdinal globalRow, const Teuchos::ArrayView< const GlobalOrdinal > &cols, const Teuchos::ArrayView< const Scalar > &vals)
Overload of replaceGlobalValues (see above), that takes Teuchos::ArrayView (host pointers) instead of...
void insertGlobalValues(const GlobalOrdinal globalRow, const Teuchos::ArrayView< const GlobalOrdinal > &cols, const Teuchos::ArrayView< const Scalar > &vals)
Insert one or more entries into the matrix, using global column indices.
void fillComplete(const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Tell the matrix that you are done changing its structure or values, and that you are ready to do comp...
typename crs_graph_type::local_graph_device_type local_graph_device_type
void getGlobalRowView(GlobalOrdinal GlobalRow, global_inds_host_view_type &indices, values_host_view_type &values) const override
Get a constant, nonpersisting view of a row of this matrix, using global row and column indices.
void setAllValues(const typename local_graph_device_type::row_map_type &ptr, const typename local_graph_device_type::entries_type::non_const_type &ind, const typename local_matrix_device_type::values_type &val)
Set the local matrix using three (compressed sparse row) arrays.
Teuchos::RCP< const RowGraph< LocalOrdinal, GlobalOrdinal, Node > > getGraph() const override
This matrix's graph, as a RowGraph.
virtual void copyAndPermute(const SrcDistObject &source, const size_t numSameIDs, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &permuteToLIDs, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &permuteFromLIDs, const CombineMode CM) override
virtual void removeEmptyProcessesInPlace(const Teuchos::RCP< const map_type > &newMap) override
Remove processes owning zero rows from the Maps and their communicator.
local_matrix_device_type::values_type getLocalValuesDevice(Access::ReadWriteStruct s)
Get the Kokkos local values on device, read write.
virtual LocalOrdinal sumIntoLocalValuesImpl(impl_scalar_type rowVals[], const crs_graph_type &graph, const RowInfo &rowInfo, const LocalOrdinal inds[], const impl_scalar_type newVals[], const LocalOrdinal numElts, const bool atomic=useAtomicUpdatesByDefault)
Implementation detail of sumIntoLocalValues.
void swap(CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &matrix)
Swaps the data from *this with the data and maps from crsMatrix.
void fillComplete(const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Tell the matrix that you are done changing its structure or values, and that you are ready to do comp...
CrsMatrix(const Teuchos::RCP< const map_type > &rowMap, const Teuchos::RCP< const map_type > &colMap, const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Constructor specifying a CrsMatrix and row and column maps. The resulting CrsMatrix views the same lo...
bool isStaticGraph() const
Indicates that the graph is static, so that new entries cannot be added to this matrix.
global_size_t getGlobalNumEntries() const override
The global number of entries in this matrix.
virtual LocalOrdinal replaceLocalValuesImpl(impl_scalar_type rowVals[], const crs_graph_type &graph, const RowInfo &rowInfo, const LocalOrdinal inds[], const impl_scalar_type newVals[], const LocalOrdinal numElts)
Implementation detail of replaceLocalValues.
Teuchos::RCP< CrsMatrixType > importAndFillCompleteCrsMatrix(const Teuchos::RCP< const CrsMatrixType > &sourceMatrix, const Import< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &importer, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Nonmember CrsMatrix constructor that fuses Import and fillComplete().
KokkosSparse::CrsMatrix< impl_scalar_type, local_ordinal_type, device_type, void, typename local_graph_device_type::size_type > local_matrix_device_type
size_t getLocalNumRows() const override
The number of matrix rows owned by the calling process.
bool isFillComplete() const override
Whether the matrix is fill complete.
LocalOrdinal transformGlobalValues(const GlobalOrdinal gblRow, const Kokkos::View< const GlobalOrdinal *, InputMemorySpace, Kokkos::MemoryUnmanaged > &inputInds, const Kokkos::View< const impl_scalar_type *, InputMemorySpace, Kokkos::MemoryUnmanaged > &inputVals, BinaryFunction f, const bool atomic=useAtomicUpdatesByDefault)
Transform CrsMatrix entries in place, using global indices to select the entries in the row to transf...
virtual bool checkSizes(const SrcDistObject &source) override
Compare the source and target (this) objects for compatibility.
Teuchos::RCP< const map_type > getRowMap() const override
The Map that describes the row distribution in this matrix.
typename device_type::memory_space memory_space
local_matrix_device_type::values_type getLocalValuesDevice(Access::OverwriteAllStruct s)
Get the Kokkos local values on device, overwrite all.
local_ordinal_type replaceLocalValues(const local_ordinal_type localRow, const Kokkos::View< const local_ordinal_type *, Kokkos::AnonymousSpace > &inputInds, const Kokkos::View< const impl_scalar_type *, Kokkos::AnonymousSpace > &inputVals)
Replace one or more entries' values, using local row and column indices.
LocalOrdinal replaceLocalValues(const LocalOrdinal localRow, const Teuchos::ArrayView< const LocalOrdinal > &cols, const Teuchos::ArrayView< const Scalar > &vals)
Backwards compatibility version of replaceLocalValues (see above), that takes Teuchos::ArrayView (hos...
void exportAndFillComplete(Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &destMatrix, const export_type &exporter, const Teuchos::RCP< const map_type > &domainMap=Teuchos::null, const Teuchos::RCP< const map_type > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null) const
Export from this to the given destination matrix, and make the result fill complete.
local_matrix_host_type::values_type getLocalValuesHost(Access::OverwriteAllStruct s)
Get the Kokkos local values on host, overwrite all.
values_dualv_type::t_host::const_type getValuesViewHost(const RowInfo &rowinfo) const
Get a const Host view of the locally owned values row myRow, such that rowinfo = getRowInfo(myRow).
CrsMatrix(const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &)=default
Copy constructor.
void insertLocalValues(const LocalOrdinal localRow, const LocalOrdinal numEnt, const Scalar vals[], const LocalOrdinal cols[], const CombineMode CM=ADD)
Epetra compatibility version of insertLocalValues (see above) that takes arguments as raw pointers,...
CrsMatrix(const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Teuchos::DataAccess copyOrView)
Copy constructor, with option to do deep or shallow copy.
bool isLocallyIndexed() const override
Whether the matrix is locally indexed on the calling process.
typename row_matrix_type::impl_scalar_type impl_scalar_type
CrsMatrix(const Teuchos::RCP< const map_type > &rowMap, const Teuchos::RCP< const map_type > &colMap, const Teuchos::ArrayView< const size_t > &numEntPerRowToAlloc, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Constructor specifying column Map and number of entries in each row.
Teuchos::RCP< MV > getRowMapMultiVector(const MV &Y_rangeMap, const bool force=false) const
Create a (or fetch a cached) row Map MultiVector.
local_matrix_device_type::values_type::const_type getLocalValuesDevice(Access::ReadOnlyStruct s) const
Get the Kokkos local values on device, read only.
virtual LocalOrdinal replaceGlobalValuesImpl(impl_scalar_type rowVals[], const crs_graph_type &graph, const RowInfo &rowInfo, const GlobalOrdinal inds[], const impl_scalar_type newVals[], const LocalOrdinal numElts)
Implementation detail of replaceGlobalValues.
values_dualv_type::t_host getValuesViewHostNonConst(const RowInfo &rowinfo)
Get a non-const Host view of the locally owned values row myRow, such that rowinfo = getRowInfo(myRow...
void resumeFill(const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Resume operations that may change the values or structure of the matrix.
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) const
Get offsets of the diagonal entries in the matrix.
void fillLocalMatrix(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Fill data into the local matrix.
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x) override
Scale the matrix on the right with the given Vector.
Teuchos::RCP< CrsMatrixType > exportAndFillCompleteCrsMatrix(const Teuchos::RCP< const CrsMatrixType > &sourceMatrix, const Export< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &rowExporter, const Export< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &domainExporter, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &domainMap, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Nonmember CrsMatrix constructor that fuses Export and fillComplete().
bool isStorageOptimized() const
Returns true if storage has been optimized.
Import< LO, GO, NT > import_type
void getLocalRowCopy(LocalOrdinal LocalRow, nonconst_local_inds_host_view_type &Indices, nonconst_values_host_view_type &Values, size_t &NumEntries) const override
Fill given arrays with a deep copy of the locally owned entries of the matrix in a given row,...
Teuchos::RCP< CrsMatrixType > exportAndFillCompleteCrsMatrix(const Teuchos::RCP< const CrsMatrixType > &sourceMatrix, const Export< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &exporter, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Nonmember CrsMatrix constructor that fuses Export and fillComplete().
values_dualv_type::t_dev::const_type getValuesViewDevice(const RowInfo &rowinfo) const
Get a const Device view of the locally owned values row myRow, such that rowinfo = getRowInfo(myRow).
void setAllValues(const local_matrix_device_type &localMatrix)
Set the local matrix using an existing local matrix.
CrsMatrix(const Teuchos::RCP< const map_type > &rowMap, const Teuchos::RCP< const map_type > &colMap, const size_t maxNumEntPerRow, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Constructor specifying column Map and fixed number of entries for each row.
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x) override
Scale the matrix on the left with the given Vector.
CrsMatrix & operator=(CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &&)=default
Move assignment.
LocalOrdinal sumIntoLocalValues(const LocalOrdinal localRow, const Teuchos::ArrayView< const LocalOrdinal > &cols, const Teuchos::ArrayView< const Scalar > &vals, const bool atomic=useAtomicUpdatesByDefault)
Sum into one or more sparse matrix entries, using local row and column indices.
void exportAndFillComplete(Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &destMatrix, const export_type &rowExporter, const export_type &domainExporter, const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms) const
Export from this to the given destination matrix, and make the result fill complete.
virtual bool supportsRowViews() const override
Return true if getLocalRowView() and getGlobalRowView() are valid for this object.
local_inds_device_view_type getLocalIndicesDevice() const
Get a device_view of the CRS packed column indicies.
Teuchos::RCP< const crs_graph_type > getCrsGraph() const
This matrix's graph, as a CrsGraph.
virtual LocalOrdinal getBlockSize() const override
The number of degrees of freedom per mesh point.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag, const Kokkos::View< const size_t *, device_type, Kokkos::MemoryUnmanaged > &offsets) const
Variant of getLocalDiagCopy() that uses precomputed offsets.
A class can inherit from this if it wants to use Tpetra managed spaces.
A wrapper around Kokkos::DualView to safely manage data that might be replicated between host and dev...
DistObject(const Teuchos::RCP< const map_type > &map)
virtual void packAndPrepare(const SrcDistObject &source, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &exportLIDs, Kokkos::DualView< packet_type *, buffer_device_type > &exports, Kokkos::DualView< size_t *, buffer_device_type > numPacketsPerLID, size_t &constantNumPackets)
Pack data and metadata for communication (sends).
virtual void unpackAndCombine(const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &importLIDs, Kokkos::DualView< packet_type *, buffer_device_type > imports, Kokkos::DualView< size_t *, buffer_device_type > numPacketsPerLID, const size_t constantNumPackets, const CombineMode combineMode)
Perform any unpacking and combining after communication.
Communication plan for data redistribution from a (possibly) multiply-owned to a uniquely-owned distr...
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
A parallel distribution of indices over processes.
One or more distributed dense vectors.
Abstract interface for operators (e.g., matrices and preconditioners).
A read-only, row-oriented interface to a sparse matrix.
typename KokkosKernels::ArithTraits< SC >::val_type impl_scalar_type
Abstract base class for objects that can be the source of an Import or Export operation.
A distributed dense vector.
Implementation details of Tpetra.
EStorageStatus
Status of the graph's or matrix's storage, when not in a fill-complete state.
void residual(const Operator< SC, LO, GO, NO > &A, const MultiVector< SC, LO, GO, NO > &X, const MultiVector< SC, LO, GO, NO > &B, MultiVector< SC, LO, GO, NO > &R)
Computes R = B - A * X.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
Teuchos::RCP< CrsMatrixType > exportAndFillCompleteCrsMatrix(const Teuchos::RCP< const CrsMatrixType > &sourceMatrix, const Export< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &exporter, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Nonmember CrsMatrix constructor that fuses Export and fillComplete().
size_t global_size_t
Global size_t object.
Teuchos::RCP< CrsMatrixType > importAndFillCompleteCrsMatrix(const Teuchos::RCP< const CrsMatrixType > &sourceMatrix, const Import< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &importer, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Nonmember CrsMatrix constructor that fuses Import and fillComplete().
CombineMode
Rule for combining data in an Import or Export.
Allocation information for a locally owned row in a CrsGraph or CrsMatrix.