41#ifndef TPETRA_CRSMATRIX_DECL_HPP
42#define TPETRA_CRSMATRIX_DECL_HPP
48#include "Tpetra_LocalCrsMatrixOperator.hpp"
49#include "Tpetra_RowMatrix_decl.hpp"
50#include "Tpetra_Exceptions.hpp"
51#include "Tpetra_DistObject.hpp"
52#include "Tpetra_CrsGraph.hpp"
53#include "Tpetra_Vector.hpp"
55#include "Tpetra_Details_ExecutionSpacesUser.hpp"
56#include "KokkosSparse_Utils.hpp"
57#include "KokkosSparse_CrsMatrix.hpp"
58#include "Teuchos_DataAccess.hpp"
65 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
class crsMatrix_Swap_Tester;
118 template<
class CrsMatrixType>
119 Teuchos::RCP<CrsMatrixType>
121 const Import<
typename CrsMatrixType::local_ordinal_type,
122 typename CrsMatrixType::global_ordinal_type,
123 typename CrsMatrixType::node_type>& importer,
124 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
125 typename CrsMatrixType::global_ordinal_type,
126 typename CrsMatrixType::node_type> >& domainMap = Teuchos::null,
127 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
128 typename CrsMatrixType::global_ordinal_type,
129 typename CrsMatrixType::node_type> >& rangeMap = Teuchos::null,
130 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
185 template<
class CrsMatrixType>
186 Teuchos::RCP<CrsMatrixType>
188 const Import<
typename CrsMatrixType::local_ordinal_type,
189 typename CrsMatrixType::global_ordinal_type,
190 typename CrsMatrixType::node_type>& rowImporter,
191 const Import<
typename CrsMatrixType::local_ordinal_type,
192 typename CrsMatrixType::global_ordinal_type,
193 typename CrsMatrixType::node_type>& domainImporter,
194 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
195 typename CrsMatrixType::global_ordinal_type,
196 typename CrsMatrixType::node_type> >& domainMap,
197 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
198 typename CrsMatrixType::global_ordinal_type,
199 typename CrsMatrixType::node_type> >& rangeMap,
200 const Teuchos::RCP<Teuchos::ParameterList>& params);
235 template<
class CrsMatrixType>
236 Teuchos::RCP<CrsMatrixType>
238 const Export<
typename CrsMatrixType::local_ordinal_type,
239 typename CrsMatrixType::global_ordinal_type,
240 typename CrsMatrixType::node_type>& exporter,
241 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
242 typename CrsMatrixType::global_ordinal_type,
243 typename CrsMatrixType::node_type> >& domainMap = Teuchos::null,
244 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
245 typename CrsMatrixType::global_ordinal_type,
246 typename CrsMatrixType::node_type> >& rangeMap = Teuchos::null,
247 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
282 template<
class CrsMatrixType>
283 Teuchos::RCP<CrsMatrixType>
285 const Export<
typename CrsMatrixType::local_ordinal_type,
286 typename CrsMatrixType::global_ordinal_type,
287 typename CrsMatrixType::node_type>& rowExporter,
288 const Export<
typename CrsMatrixType::local_ordinal_type,
289 typename CrsMatrixType::global_ordinal_type,
290 typename CrsMatrixType::node_type>& domainExporter,
291 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
292 typename CrsMatrixType::global_ordinal_type,
293 typename CrsMatrixType::node_type> >& domainMap,
294 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
295 typename CrsMatrixType::global_ordinal_type,
296 typename CrsMatrixType::node_type> >& rangeMap,
297 const Teuchos::RCP<Teuchos::ParameterList>& params);
302 template<
class SC,
class LO,
class GO,
class NO>
422 template <
class Scalar,
427 public RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>,
428 public DistObject<char, LocalOrdinal, GlobalOrdinal, Node>,
433 using dist_object_type =
489 using mag_type =
typename Kokkos::ArithTraits<impl_scalar_type>::mag_type;
505 typename local_graph_device_type::size_type>;
506 using local_matrix_host_type =
507 typename local_matrix_device_type::HostMirror;
516 using row_ptrs_device_view_type =
517 typename row_matrix_type::row_ptrs_device_view_type;
518 using row_ptrs_host_view_type =
519 typename row_matrix_type::row_ptrs_host_view_type;
522 using local_inds_device_view_type =
523 typename row_matrix_type::local_inds_device_view_type;
524 using local_inds_host_view_type =
525 typename row_matrix_type::local_inds_host_view_type;
526 using nonconst_local_inds_host_view_type =
527 typename row_matrix_type::nonconst_local_inds_host_view_type;
529 using global_inds_device_view_type =
530 typename row_matrix_type::global_inds_device_view_type;
531 using global_inds_host_view_type =
532 typename row_matrix_type::global_inds_host_view_type;
533 using nonconst_global_inds_host_view_type =
534 typename row_matrix_type::nonconst_global_inds_host_view_type;
536 using values_device_view_type =
537 typename row_matrix_type::values_device_view_type;
538 using values_host_view_type =
539 typename row_matrix_type::values_host_view_type;
540 using nonconst_values_host_view_type =
541 typename row_matrix_type::nonconst_values_host_view_type;
549 GlobalOrdinal, Node>&) =
default;
553 GlobalOrdinal, Node>&&) =
default;
558 GlobalOrdinal, Node>&) =
default;
563 GlobalOrdinal, Node>&&) =
default;
579 const size_t maxNumEntriesPerRow,
580 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
595 const Teuchos::ArrayView<const size_t>& numEntPerRowToAlloc,
596 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
618 const Teuchos::RCP<const map_type>& colMap,
619 const size_t maxNumEntPerRow,
620 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
641 const Teuchos::RCP<const map_type>& colMap,
642 const Teuchos::ArrayView<const size_t>& numEntPerRowToAlloc,
643 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
673 explicit CrsMatrix (CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& matrix,
674 const Teuchos::RCP<const crs_graph_type>& graph,
675 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
701 explicit CrsMatrix (
const Teuchos::RCP<const crs_graph_type>& graph,
702 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
732 explicit CrsMatrix (
const Teuchos::RCP<const crs_graph_type>& graph,
733 const typename local_matrix_device_type::values_type& values,
734 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
763 const Teuchos::RCP<const map_type>& colMap,
764 const typename local_graph_device_type::row_map_type& rowPointers,
765 const typename local_graph_device_type::entries_type::non_const_type& columnIndices,
766 const typename local_matrix_device_type::values_type& values,
767 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
796 const Teuchos::RCP<const map_type>& colMap,
797 const Teuchos::ArrayRCP<size_t>& rowPointers,
798 const Teuchos::ArrayRCP<LocalOrdinal>& columnIndices,
799 const Teuchos::ArrayRCP<Scalar>& values,
800 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
824 const Teuchos::RCP<const map_type>& colMap,
826 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
859 const Teuchos::RCP<const map_type>& rowMap,
860 const Teuchos::RCP<const map_type>& colMap,
861 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
862 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
863 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
870 const Teuchos::RCP<const map_type>& rowMap,
871 const Teuchos::RCP<const map_type>& colMap,
872 const Teuchos::RCP<const map_type>& domainMap,
873 const Teuchos::RCP<const map_type>& rangeMap,
874 const Teuchos::RCP<const import_type>& importer,
875 const Teuchos::RCP<const export_type>& exporter,
876 const Teuchos::RCP<Teuchos::ParameterList>& params =
882 CrsMatrix (
const CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& source,
883 const Teuchos::DataAccess copyOrView);
897 template <
class S2,
class LO2,
class GO2,
class N2>
898 friend class CrsMatrix;
901 template <
class S2,
class LO2,
class GO2,
class N2>
908 template <
class MatrixArray,
class MultiVectorArray>
910 const typename std::remove_pointer<typename MultiVectorArray::value_type>::type & X,
912 typename std::remove_pointer<typename MatrixArray::value_type>::type::scalar_type alpha,
913 typename std::remove_pointer<typename MatrixArray::value_type>::type::scalar_type beta,
914 Teuchos::RCP<Teuchos::ParameterList> params);
988 const Teuchos::ArrayView<const GlobalOrdinal>& cols,
989 const Teuchos::ArrayView<const Scalar>& vals);
1007 const LocalOrdinal numEnt,
1008 const Scalar vals[],
1009 const GlobalOrdinal inds[]);
1055 const Teuchos::ArrayView<const LocalOrdinal> &cols,
1056 const Teuchos::ArrayView<const Scalar> &vals,
1080 const LocalOrdinal numEnt,
1081 const Scalar vals[],
1082 const LocalOrdinal cols[],
1096 virtual LocalOrdinal
1100 const GlobalOrdinal inds[],
1102 const LocalOrdinal numElts);
1144 const Kokkos::View<const global_ordinal_type*, Kokkos::AnonymousSpace>& inputInds,
1145 const Kokkos::View<const impl_scalar_type*, Kokkos::AnonymousSpace>& inputVals);
1151 const Teuchos::ArrayView<const GlobalOrdinal>& cols,
1152 const Teuchos::ArrayView<const Scalar>& vals);
1170 const LocalOrdinal numEnt,
1171 const Scalar vals[],
1172 const GlobalOrdinal cols[]);
1185 virtual LocalOrdinal
1189 const LocalOrdinal inds[],
1191 const LocalOrdinal numElts);
1232 const Kokkos::View<const local_ordinal_type*, Kokkos::AnonymousSpace>& inputInds,
1233 const Kokkos::View<const impl_scalar_type*, Kokkos::AnonymousSpace>& inputVals);
1240 const Teuchos::ArrayView<const LocalOrdinal>& cols,
1241 const Teuchos::ArrayView<const Scalar>& vals);
1262 const LocalOrdinal numEnt,
1263 const Scalar inputVals[],
1264 const LocalOrdinal inputCols[]);
1271 static const bool useAtomicUpdatesByDefault =
1272#ifdef KOKKOS_ENABLE_SERIAL
1273 ! std::is_same<execution_space, Kokkos::Serial>::value;
1302 virtual LocalOrdinal
1306 const GlobalOrdinal inds[],
1308 const LocalOrdinal numElts,
1309 const bool atomic = useAtomicUpdatesByDefault);
1350 const Teuchos::ArrayView<const GlobalOrdinal>& cols,
1351 const Teuchos::ArrayView<const Scalar>& vals,
1352 const bool atomic = useAtomicUpdatesByDefault);
1378 const LocalOrdinal numEnt,
1379 const Scalar vals[],
1380 const GlobalOrdinal cols[],
1381 const bool atomic = useAtomicUpdatesByDefault);
1396 virtual LocalOrdinal
1400 const LocalOrdinal inds[],
1402 const LocalOrdinal numElts,
1403 const bool atomic = useAtomicUpdatesByDefault);
1445 const Kokkos::View<const local_ordinal_type*, Kokkos::AnonymousSpace>& inputInds,
1446 const Kokkos::View<const impl_scalar_type*, Kokkos::AnonymousSpace>& inputVals,
1447 const bool atomic = useAtomicUpdatesByDefault);
1480 const Teuchos::ArrayView<const LocalOrdinal>& cols,
1481 const Teuchos::ArrayView<const Scalar>& vals,
1482 const bool atomic = useAtomicUpdatesByDefault);
1507 const LocalOrdinal numEnt,
1508 const Scalar vals[],
1509 const LocalOrdinal cols[],
1510 const bool atomic = useAtomicUpdatesByDefault);
1547 const LocalOrdinal inds[],
1549 const LocalOrdinal numElts,
1551 const bool atomic = useAtomicUpdatesByDefault);
1587 const GlobalOrdinal inds[],
1589 const LocalOrdinal numElts,
1591 const bool atomic = useAtomicUpdatesByDefault);
1620 transformLocalValues (
const LocalOrdinal lclRow,
1621 const LocalOrdinal numInputEnt,
1623 const LocalOrdinal inputCols[],
1625 const bool atomic = useAtomicUpdatesByDefault);
1654 transformGlobalValues (
const GlobalOrdinal gblRow,
1655 const LocalOrdinal numInputEnt,
1657 const GlobalOrdinal inputCols[],
1659 const bool atomic = useAtomicUpdatesByDefault);
1705 template<
class LocalIndicesViewType,
1706 class ImplScalarViewType,
1707 class BinaryFunction>
1710 const typename UnmanagedView<LocalIndicesViewType>::type& inputInds,
1711 const typename UnmanagedView<ImplScalarViewType>::type& inputVals,
1713 const bool atomic = useAtomicUpdatesByDefault)
1721 static_assert (Kokkos::is_view<LocalIndicesViewType>::value,
1722 "First template parameter LocalIndicesViewType must be "
1724 static_assert (Kokkos::is_view<ImplScalarViewType>::value,
1725 "Second template parameter ImplScalarViewType must be a "
1727 static_assert (
static_cast<int> (LocalIndicesViewType::rank) == 1,
1728 "First template parameter LocalIndicesViewType must "
1730 static_assert (
static_cast<int> (ImplScalarViewType::rank) == 1,
1731 "Second template parameter ImplScalarViewType must have "
1733 static_assert (std::is_same<
1734 typename LocalIndicesViewType::non_const_value_type,
1736 "First template parameter LocalIndicesViewType must "
1737 "contain values of type local_ordinal_type.");
1738 static_assert (std::is_same<
1739 typename ImplScalarViewType::non_const_value_type,
1741 "Second template parameter ImplScalarViewType must "
1742 "contain values of type impl_scalar_type.");
1743 typedef LocalOrdinal LO;
1744 const LO numInputEnt = inputInds.extent (0);
1745 if (
static_cast<LO
> (inputVals.extent (0)) != numInputEnt) {
1746 return Teuchos::OrdinalTraits<LO>::invalid ();
1748 return this->transformLocalValues (lclRow,
1797 template<
class BinaryFunction,
class InputMemorySpace>
1800 const Kokkos::View<
const GlobalOrdinal*,
1802 Kokkos::MemoryUnmanaged>& inputInds,
1805 Kokkos::MemoryUnmanaged>& inputVals,
1807 const bool atomic = useAtomicUpdatesByDefault)
1809 typedef LocalOrdinal LO;
1810 const LO numInputEnt = inputInds.extent (0);
1811 if (
static_cast<LO
> (inputVals.extent (0)) != numInputEnt) {
1812 return Teuchos::OrdinalTraits<LO>::invalid ();
1814 return this->transformGlobalValues (gblRow,
1854 const typename local_graph_device_type::entries_type::non_const_type& ind,
1855 const typename local_matrix_device_type::values_type& val);
1906 const Teuchos::ArrayRCP<LocalOrdinal>& ind,
1907 const Teuchos::ArrayRCP<Scalar>& val);
1915 {
return getCrsGraph()->getLocalRowPtrsDevice(); }
1923 {
return getCrsGraph()->getLocalIndicesDevice(); }
1972 void resumeFill (
const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
2033 const Teuchos::RCP<const map_type>& rangeMap,
2034 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
2063 fillComplete (
const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
2093 const Teuchos::RCP<const map_type>& rangeMap,
2094 const Teuchos::RCP<const import_type>& importer = Teuchos::null,
2095 const Teuchos::RCP<const export_type>& exporter = Teuchos::null,
2096 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
2201 const Teuchos::RCP<const map_type>& newColMap,
2202 const Teuchos::RCP<const import_type>& newImport = Teuchos::null,
2203 const bool sortEachRow =
true);
2232 Teuchos::RCP<const import_type>& newImporter);
2261 Teuchos::RCP<const export_type>& newExporter);
2284 Teuchos::RCP<const Teuchos::Comm<int> >
getComm()
const override;
2294 Teuchos::RCP<const RowGraph<LocalOrdinal, GlobalOrdinal, Node> >
2324 local_matrix_host_type getLocalMatrixHost ()
const;
2542 using values_dualv_type =
2543 Kokkos::DualView<impl_scalar_type*, device_type>;
2544 using values_wdv_type =
2546 values_wdv_type valuesUnpacked_wdv;
2547 mutable values_wdv_type valuesPacked_wdv;
2549 using ordinal_rowptrs_type =
typename local_multiply_op_type::ordinal_view_type;
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> >
2893 Teuchos::ETransp mode = Teuchos::NO_TRANS,
2894 Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
2895 Scalar beta = Teuchos::ScalarTraits<Scalar>::zero())
const override;
2931 virtual Teuchos::RCP<RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
2937 const Teuchos::RCP<Teuchos::ParameterList>& params)
const override;
2950 const Teuchos::EVerbosityLevel verbLevel =
2951 Teuchos::Describable::verbLevel_default)
const override;
2961 typedef typename DistObject<Scalar, LocalOrdinal, GlobalOrdinal,
2969 const typename crs_graph_type::padding_type& padding,
2970 const bool verbose);
2974 copyAndPermuteStaticGraph(
2976 const size_t numSameIDs,
2977 const LocalOrdinal permuteToLIDs[],
2978 const LocalOrdinal permuteFromLIDs[],
2979 const size_t numPermutes);
2982 copyAndPermuteNonStaticGraph(
2984 const size_t numSameIDs,
2985 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteToLIDs_dv,
2986 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteFromLIDs_dv,
2987 const size_t numPermutes);
2992 using dist_object_type::
3000 const size_t numSameIDs,
3001 const Kokkos::DualView<
3004 const Kokkos::DualView<
3012 const Kokkos::DualView<
3015 Kokkos::DualView<char*, buffer_device_type>& exports,
3016 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
3017 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,
3062 (
const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& importLIDs,
3063 Kokkos::DualView<char*, buffer_device_type> imports,
3064 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
3065 const size_t constantNumPackets,
3181 packNew (
const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& exportLIDs,
3182 Kokkos::DualView<char*, buffer_device_type>& exports,
3183 const Kokkos::DualView<size_t*, buffer_device_type>& numPacketsPerLID,
3184 size_t& constantNumPackets)
const;
3194 packNonStaticNew (
const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& exportLIDs,
3195 Kokkos::DualView<char*, buffer_device_type>& exports,
3196 const Kokkos::DualView<size_t*, buffer_device_type>& numPacketsPerLID,
3197 size_t& constantNumPackets)
const;
3229 packRow (
char exports[],
3230 const size_t offset,
3231 const size_t numEnt,
3232 const GlobalOrdinal gidsIn[],
3234 const size_t numBytesPerValue)
const;
3260 packRowStatic (
char*
const numEntOut,
3263 const size_t numEnt,
3264 const LocalOrdinal lclRow)
const;
3292 unpackRow (GlobalOrdinal gidsOut[],
3294 const char imports[],
3295 const size_t offset,
3296 const size_t numBytes,
3297 const size_t numEnt,
3298 const size_t numBytesPerValue);
3309 allocatePackSpaceNew (Kokkos::DualView<char*, buffer_device_type>& exports,
3310 size_t& totalNumEntries,
3317 typename local_matrix_host_type::values_type::const_type
3320 return valuesPacked_wdv.getHostView(s);
3324 typename local_matrix_host_type::values_type
3327 return valuesPacked_wdv.getHostView(s);
3331 typename local_matrix_host_type::values_type
3334 return valuesPacked_wdv.getHostView(s);
3338 typename local_matrix_device_type::values_type::const_type
3341 return valuesPacked_wdv.getDeviceView(s);
3345 typename local_matrix_device_type::values_type
3348 return valuesPacked_wdv.getDeviceView(s);
3352 typename local_matrix_device_type::values_type
3355 return valuesPacked_wdv.getDeviceView(s);
3360 template<
class CrsMatrixType>
3361 friend Teuchos::RCP<CrsMatrixType>
3363 const Import<
typename CrsMatrixType::local_ordinal_type,
3364 typename CrsMatrixType::global_ordinal_type,
3365 typename CrsMatrixType::node_type>& importer,
3366 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3367 typename CrsMatrixType::global_ordinal_type,
3368 typename CrsMatrixType::node_type> >& domainMap,
3369 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3370 typename CrsMatrixType::global_ordinal_type,
3371 typename CrsMatrixType::node_type> >& rangeMap,
3372 const Teuchos::RCP<Teuchos::ParameterList>& params);
3375 template<
class CrsMatrixType>
3376 friend Teuchos::RCP<CrsMatrixType>
3378 const Import<
typename CrsMatrixType::local_ordinal_type,
3379 typename CrsMatrixType::global_ordinal_type,
3380 typename CrsMatrixType::node_type>& rowImporter,
3381 const Import<
typename CrsMatrixType::local_ordinal_type,
3382 typename CrsMatrixType::global_ordinal_type,
3383 typename CrsMatrixType::node_type>& domainImporter,
3384 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3385 typename CrsMatrixType::global_ordinal_type,
3386 typename CrsMatrixType::node_type> >& domainMap,
3387 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3388 typename CrsMatrixType::global_ordinal_type,
3389 typename CrsMatrixType::node_type> >& rangeMap,
3390 const Teuchos::RCP<Teuchos::ParameterList>& params);
3394 template<
class CrsMatrixType>
3395 friend Teuchos::RCP<CrsMatrixType>
3397 const Export<
typename CrsMatrixType::local_ordinal_type,
3398 typename CrsMatrixType::global_ordinal_type,
3399 typename CrsMatrixType::node_type>& exporter,
3400 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3401 typename CrsMatrixType::global_ordinal_type,
3402 typename CrsMatrixType::node_type> >& domainMap,
3403 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3404 typename CrsMatrixType::global_ordinal_type,
3405 typename CrsMatrixType::node_type> >& rangeMap,
3406 const Teuchos::RCP<Teuchos::ParameterList>& params);
3409 template<
class CrsMatrixType>
3410 friend Teuchos::RCP<CrsMatrixType>
3412 const Export<
typename CrsMatrixType::local_ordinal_type,
3413 typename CrsMatrixType::global_ordinal_type,
3414 typename CrsMatrixType::node_type>& rowExporter,
3415 const Export<
typename CrsMatrixType::local_ordinal_type,
3416 typename CrsMatrixType::global_ordinal_type,
3417 typename CrsMatrixType::node_type>& domainExporter,
3418 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3419 typename CrsMatrixType::global_ordinal_type,
3420 typename CrsMatrixType::node_type> >& domainMap,
3421 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3422 typename CrsMatrixType::global_ordinal_type,
3423 typename CrsMatrixType::node_type> >& rangeMap,
3424 const Teuchos::RCP<Teuchos::ParameterList>& params);
3445 const Teuchos::RCP<const map_type>& domainMap,
3446 const Teuchos::RCP<const map_type>& rangeMap,
3447 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
3468 const Teuchos::RCP<const map_type>& domainMap,
3469 const Teuchos::RCP<const map_type>& rangeMap,
3470 const Teuchos::RCP<Teuchos::ParameterList>& params)
const;
3491 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
3492 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
3493 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
3514 const Teuchos::RCP<const map_type>& domainMap,
3515 const Teuchos::RCP<const map_type>& rangeMap,
3516 const Teuchos::RCP<Teuchos::ParameterList>& params)
const;
3541 transferAndFillComplete (Teuchos::RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >& destMatrix,
3542 const ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node>& rowTransfer,
3543 const Teuchos::RCP<const ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node> > & domainTransfer,
3544 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
3545 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
3546 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
3563 const GlobalOrdinal gblColInds[],
3565 const size_t numInputEnt);
3578 insertGlobalValuesFiltered(
3579 const GlobalOrdinal globalRow,
3580 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3581 const Teuchos::ArrayView<const Scalar>& values,
3587 insertGlobalValuesFilteredChecked(
3588 const GlobalOrdinal globalRow,
3589 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3590 const Teuchos::ArrayView<const Scalar>& values,
3591 const char*
const prefix,
3593 const bool verbose);
3607 combineGlobalValues(
3608 const GlobalOrdinal globalRowIndex,
3609 const Teuchos::ArrayView<const GlobalOrdinal>& columnIndices,
3610 const Teuchos::ArrayView<const Scalar>& values,
3612 const char*
const prefix,
3614 const bool verbose);
3638 combineGlobalValuesRaw(
const LocalOrdinal lclRow,
3639 const LocalOrdinal numEnt,
3641 const GlobalOrdinal cols[],
3643 const char*
const prefix,
3645 const bool verbose);
3658 template<
class BinaryFunction>
3660 transformGlobalValues (
const GlobalOrdinal globalRow,
3661 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3662 const Teuchos::ArrayView<const Scalar>& values,
3664 const bool atomic = useAtomicUpdatesByDefault)
3667 typedef LocalOrdinal LO;
3668 typedef GlobalOrdinal GO;
3670 const LO numInputEnt =
static_cast<LO
> (indices.size ());
3671 if (
static_cast<LO
> (values.size ()) != numInputEnt) {
3672 return Teuchos::OrdinalTraits<LO>::invalid ();
3675 const GO*
const inputCols = indices.getRawPtr ();
3676 const IST*
const inputVals =
3677 reinterpret_cast<const IST*
> (values.getRawPtr ());
3678 return this->transformGlobalValues (globalRow, numInputEnt, inputVals,
3679 inputCols, f, atomic);
3689 insertNonownedGlobalValues (
const GlobalOrdinal globalRow,
3690 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3691 const Teuchos::ArrayView<const Scalar>& values);
3738 const typename crs_graph_type::SLocalGlobalViews& newInds,
3739 const Teuchos::ArrayView<impl_scalar_type>& oldRowVals,
3740 const Teuchos::ArrayView<const impl_scalar_type>& newRowVals,
3741 const ELocalGlobal lg,
3742 const ELocalGlobal I);
3746 typedef Teuchos::OrdinalTraits<LocalOrdinal> OTL;
3747 typedef Kokkos::ArithTraits<impl_scalar_type> STS;
3748 typedef Kokkos::ArithTraits<mag_type> STM;
3749 typedef MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> MV;
3750 typedef Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> V;
3754 enum GraphAllocationStatus {
3755 GraphAlreadyAllocated,
3756 GraphNotYetAllocated
3779 const bool verbose);
3867 const bool force =
false)
const;
3892 const bool force =
false)
const;
3905 const Teuchos::ETransp mode,
3913 typename values_dualv_type::t_host::const_type
3918 typename values_dualv_type::t_dev::const_type
3923 typename values_dualv_type::t_host
3928 typename values_dualv_type::t_dev
3935 friend class Tpetra::crsMatrix_Swap_Tester<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
3940 void swap(CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> & matrix);
3974 Teuchos::RCP<const Graph> staticGraph_;
3975 Teuchos::RCP< Graph> myGraph_;
3989 Details::STORAGE_1D_UNPACKED;
4021 std::map<GlobalOrdinal, std::pair<Teuchos::Array<GlobalOrdinal>,
4029 template<
class DestViewType,
class SrcViewType,
4030 class DestOffsetViewType,
class SrcOffsetViewType>
4031 struct pack_functor {
4035 SrcOffsetViewType src_offset_;
4036 DestOffsetViewType dst_offset_;
4037 typedef typename DestOffsetViewType::non_const_value_type scalar_index_type;
4039 pack_functor (DestViewType dst,
4040 const SrcViewType src,
4041 DestOffsetViewType dst_offset,
4042 const SrcOffsetViewType src_offset) :
4045 src_offset_ (src_offset),
4046 dst_offset_ (dst_offset)
4049 KOKKOS_INLINE_FUNCTION
4050 void operator () (
const LocalOrdinal row)
const {
4051 scalar_index_type srcPos = src_offset_(row);
4052 const scalar_index_type dstEnd = dst_offset_(row+1);
4053 scalar_index_type dstPos = dst_offset_(row);
4054 for ( ; dstPos < dstEnd; ++dstPos, ++srcPos) {
4055 dst_(dstPos) = src_(srcPos);
4065 template<
class Scalar,
4067 class GlobalOrdinal,
4069 Teuchos::RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
4072 const size_t maxNumEntriesPerRow = 0,
4073 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
4076 CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
4077 return Teuchos::rcp(
new matrix_type(map, maxNumEntriesPerRow,
4081 template<
class CrsMatrixType>
4082 Teuchos::RCP<CrsMatrixType>
4084 const Import<
typename CrsMatrixType::local_ordinal_type,
4085 typename CrsMatrixType::global_ordinal_type,
4086 typename CrsMatrixType::node_type>& importer,
4087 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4088 typename CrsMatrixType::global_ordinal_type,
4089 typename CrsMatrixType::node_type> >& domainMap,
4090 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4091 typename CrsMatrixType::global_ordinal_type,
4092 typename CrsMatrixType::node_type> >& rangeMap,
4093 const Teuchos::RCP<Teuchos::ParameterList>& params)
4095 Teuchos::RCP<CrsMatrixType> destMatrix;
4096 sourceMatrix->importAndFillComplete (destMatrix, importer, domainMap, rangeMap, params);
4100 template<
class CrsMatrixType>
4101 Teuchos::RCP<CrsMatrixType>
4103 const Import<
typename CrsMatrixType::local_ordinal_type,
4104 typename CrsMatrixType::global_ordinal_type,
4105 typename CrsMatrixType::node_type>& rowImporter,
4106 const Import<
typename CrsMatrixType::local_ordinal_type,
4107 typename CrsMatrixType::global_ordinal_type,
4108 typename CrsMatrixType::node_type>& domainImporter,
4109 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4110 typename CrsMatrixType::global_ordinal_type,
4111 typename CrsMatrixType::node_type> >& domainMap,
4112 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4113 typename CrsMatrixType::global_ordinal_type,
4114 typename CrsMatrixType::node_type> >& rangeMap,
4115 const Teuchos::RCP<Teuchos::ParameterList>& params)
4117 Teuchos::RCP<CrsMatrixType> destMatrix;
4118 sourceMatrix->importAndFillComplete (destMatrix, rowImporter, domainImporter, domainMap, rangeMap, params);
4122 template<
class CrsMatrixType>
4123 Teuchos::RCP<CrsMatrixType>
4125 const Export<
typename CrsMatrixType::local_ordinal_type,
4126 typename CrsMatrixType::global_ordinal_type,
4127 typename CrsMatrixType::node_type>& exporter,
4128 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4129 typename CrsMatrixType::global_ordinal_type,
4130 typename CrsMatrixType::node_type> >& domainMap,
4131 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4132 typename CrsMatrixType::global_ordinal_type,
4133 typename CrsMatrixType::node_type> >& rangeMap,
4134 const Teuchos::RCP<Teuchos::ParameterList>& params)
4136 Teuchos::RCP<CrsMatrixType> destMatrix;
4137 sourceMatrix->exportAndFillComplete (destMatrix, exporter, domainMap, rangeMap, params);
4141 template<
class CrsMatrixType>
4142 Teuchos::RCP<CrsMatrixType>
4144 const Export<
typename CrsMatrixType::local_ordinal_type,
4145 typename CrsMatrixType::global_ordinal_type,
4146 typename CrsMatrixType::node_type>& rowExporter,
4147 const Export<
typename CrsMatrixType::local_ordinal_type,
4148 typename CrsMatrixType::global_ordinal_type,
4149 typename CrsMatrixType::node_type>& domainExporter,
4150 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4151 typename CrsMatrixType::global_ordinal_type,
4152 typename CrsMatrixType::node_type> >& domainMap,
4153 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4154 typename CrsMatrixType::global_ordinal_type,
4155 typename CrsMatrixType::node_type> >& rangeMap,
4156 const Teuchos::RCP<Teuchos::ParameterList>& params)
4158 Teuchos::RCP<CrsMatrixType> destMatrix;
4159 sourceMatrix->exportAndFillComplete (destMatrix, rowExporter, domainExporter, domainMap, rangeMap, params);
4169 template<
class CrsMatrixType>
4172 typename Teuchos::ScalarTraits<typename CrsMatrixType::scalar_type>::magnitudeType
const & threshold =
4173 Teuchos::ScalarTraits<typename CrsMatrixType::scalar_type>::magnitude( Teuchos::ScalarTraits<typename CrsMatrixType::scalar_type>::zero() ))
4175 auto localMatrix = matrix.getLocalMatrixDevice();
4176 size_t nnzBefore = localMatrix.nnz();
4177 localMatrix = KokkosSparse::removeCrsMatrixZeros(localMatrix,threshold);
4178 size_t localNNZRemoved = nnzBefore - localMatrix.nnz();
4181 size_t globalNNZRemoved = 0;
4182 Teuchos::reduceAll<int, size_t> (*(matrix.getComm()), Teuchos::REDUCE_SUM, 1, &localNNZRemoved, &globalNNZRemoved);
4183 if(globalNNZRemoved !=
size_t(0)) {
4184 matrix.resumeFill();
4185 matrix.setAllValues(localMatrix);
4186 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...
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
typename local_graph_device_type::HostMirror local_graph_host_type
The type of the part of the sparse graph on each MPI process.
Kokkos::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.
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.
LocalCrsMatrixOperator< scalar_type, scalar_type, device_type > local_multiply_op_type
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.
ordinal_rowptrs_type ordinalRowptrs
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
Special case of apply() for mode == Teuchos::NO_TRANS.
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.
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.
std::shared_ptr< local_multiply_op_type > getLocalMultiplyOperator() const
The local sparse matrix operator (a wrapper of getLocalMatrixDevice() that supports local matrix-vect...
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.
KokkosSparse::CrsMatrix< impl_scalar_type, local_ordinal_type, device_type, void, typename local_graph_device_type::size_type > local_matrix_device_type
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
Special case of apply() for mode != Teuchos::NO_TRANS.
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.
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
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.
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.
typename Kokkos::ArithTraits< impl_scalar_type >::mag_type mag_type
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...
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().
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.
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.
static size_t mergeRowIndicesAndValues(size_t rowLen, local_ordinal_type *cols, impl_scalar_type *vals)
Merge duplicate row indices in the given row, along with their corresponding values.
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...
Abstract interface for local operators (e.g., matrices and preconditioners).
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 Kokkos::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.