40 #ifndef TPETRA_CRSMATRIX_DECL_HPP
41 #define TPETRA_CRSMATRIX_DECL_HPP
52 #include "Tpetra_LocalCrsMatrixOperator_fwd.hpp"
53 #include "Tpetra_RowMatrix_decl.hpp"
54 #include "Tpetra_Exceptions.hpp"
55 #include "Tpetra_DistObject.hpp"
56 #include "Tpetra_CrsGraph.hpp"
57 #include "Tpetra_Vector.hpp"
59 #include "KokkosSparse_CrsMatrix.hpp"
65 #include "KokkosSparse_sor_sequential_impl.hpp"
72 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
class crsMatrix_Swap_Tester;
125 template<
class CrsMatrixType>
126 Teuchos::RCP<CrsMatrixType>
128 const Import<
typename CrsMatrixType::local_ordinal_type,
129 typename CrsMatrixType::global_ordinal_type,
130 typename CrsMatrixType::node_type>& importer,
131 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
132 typename CrsMatrixType::global_ordinal_type,
133 typename CrsMatrixType::node_type> >& domainMap = Teuchos::null,
134 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
135 typename CrsMatrixType::global_ordinal_type,
136 typename CrsMatrixType::node_type> >& rangeMap = Teuchos::null,
137 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
192 template<
class CrsMatrixType>
193 Teuchos::RCP<CrsMatrixType>
195 const Import<
typename CrsMatrixType::local_ordinal_type,
196 typename CrsMatrixType::global_ordinal_type,
197 typename CrsMatrixType::node_type>& rowImporter,
198 const Import<
typename CrsMatrixType::local_ordinal_type,
199 typename CrsMatrixType::global_ordinal_type,
200 typename CrsMatrixType::node_type>& domainImporter,
201 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
202 typename CrsMatrixType::global_ordinal_type,
203 typename CrsMatrixType::node_type> >& domainMap,
204 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
205 typename CrsMatrixType::global_ordinal_type,
206 typename CrsMatrixType::node_type> >& rangeMap,
207 const Teuchos::RCP<Teuchos::ParameterList>& params);
242 template<
class CrsMatrixType>
243 Teuchos::RCP<CrsMatrixType>
245 const Export<
typename CrsMatrixType::local_ordinal_type,
246 typename CrsMatrixType::global_ordinal_type,
247 typename CrsMatrixType::node_type>& exporter,
248 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
249 typename CrsMatrixType::global_ordinal_type,
250 typename CrsMatrixType::node_type> >& domainMap = Teuchos::null,
251 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
252 typename CrsMatrixType::global_ordinal_type,
253 typename CrsMatrixType::node_type> >& rangeMap = Teuchos::null,
254 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
289 template<
class CrsMatrixType>
290 Teuchos::RCP<CrsMatrixType>
292 const Export<
typename CrsMatrixType::local_ordinal_type,
293 typename CrsMatrixType::global_ordinal_type,
294 typename CrsMatrixType::node_type>& rowExporter,
295 const Export<
typename CrsMatrixType::local_ordinal_type,
296 typename CrsMatrixType::global_ordinal_type,
297 typename CrsMatrixType::node_type>& domainExporter,
298 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
299 typename CrsMatrixType::global_ordinal_type,
300 typename CrsMatrixType::node_type> >& domainMap,
301 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
302 typename CrsMatrixType::global_ordinal_type,
303 typename CrsMatrixType::node_type> >& rangeMap,
304 const Teuchos::RCP<Teuchos::ParameterList>& params);
419 template <
class Scalar,
424 public RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>,
425 public DistObject<char, LocalOrdinal, GlobalOrdinal, Node>
426 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
427 ,
public ::Tpetra::Details::HasDeprecatedMethods2630_WarningThisClassIsNotForUsers
428 #endif // TPETRA_ENABLE_DEPRECATED_CODE
466 using mag_type =
typename Kokkos::ArithTraits<impl_scalar_type>::mag_type;
490 typename local_graph_type::size_type>;
492 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
493 typedef typename local_matrix_type::row_map_type t_RowPtrs TPETRA_DEPRECATED;
496 typedef typename local_matrix_type::row_map_type::non_const_type t_RowPtrsNC TPETRA_DEPRECATED;
498 typedef typename local_graph_type::entries_type::non_const_type t_LocalOrdinal_1D TPETRA_DEPRECATED;
500 typedef typename local_matrix_type::values_type t_ValuesType TPETRA_DEPRECATED;
503 #endif // TPETRA_ENABLE_DEPRECATED_CODE
511 GlobalOrdinal, Node>&) =
default;
515 GlobalOrdinal, Node>&&) =
default;
520 GlobalOrdinal, Node>&) =
default;
525 GlobalOrdinal, Node>&&) =
default;
544 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
545 const size_t maxNumEntriesPerRow,
546 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
547 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
566 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
567 const Teuchos::ArrayView<const size_t>& numEntPerRowToAlloc,
568 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
569 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
571 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
574 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
575 const Teuchos::ArrayRCP<const size_t>& numEntPerRowToAlloc,
576 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
577 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
578 #endif // TPETRA_ENABLE_DEPRECATED_CODE
602 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
603 const Teuchos::RCP<const map_type>& colMap,
604 const size_t maxNumEntPerRow,
605 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
606 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
630 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
631 const Teuchos::RCP<const map_type>& colMap,
632 const Teuchos::ArrayView<const size_t>& numEntPerRowToAlloc,
633 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
634 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
636 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
639 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
640 const Teuchos::RCP<const map_type>& colMap,
641 const Teuchos::ArrayRCP<const size_t>& numEntPerRowToAlloc,
642 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
643 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
644 #endif // TPETRA_ENABLE_DEPRECATED_CODE
670 explicit CrsMatrix (
const Teuchos::RCP<const crs_graph_type>& graph,
671 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
701 explicit CrsMatrix (
const Teuchos::RCP<const crs_graph_type>& graph,
702 const typename local_matrix_type::values_type& values,
703 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
728 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
729 const Teuchos::RCP<const map_type>& colMap,
730 const typename local_matrix_type::row_map_type& rowPointers,
731 const typename local_graph_type::entries_type::non_const_type& columnIndices,
732 const typename local_matrix_type::values_type& values,
733 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
758 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
759 const Teuchos::RCP<const map_type>& colMap,
760 const Teuchos::ArrayRCP<size_t>& rowPointers,
761 const Teuchos::ArrayRCP<LocalOrdinal>& columnIndices,
762 const Teuchos::ArrayRCP<Scalar>& values,
763 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
785 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
786 const Teuchos::RCP<const map_type>& colMap,
788 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);
825 const Teuchos::RCP<const map_type>& rowMap,
826 const Teuchos::RCP<const map_type>& colMap,
827 const Teuchos::RCP<const map_type>& domainMap,
828 const Teuchos::RCP<const map_type>& rangeMap,
829 const Teuchos::RCP<const import_type>& importer,
830 const Teuchos::RCP<const export_type>& exporter,
831 const Teuchos::RCP<Teuchos::ParameterList>& params =
838 const Teuchos::DataAccess copyOrView);
852 template <
class S2,
class LO2,
class GO2,
class N2>
855 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
856 template <
class Node2>
881 Teuchos::RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node2> > TPETRA_DEPRECATED
882 clone (
const Teuchos::RCP<Node2>& node2,
883 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const
885 using Teuchos::Array;
886 using Teuchos::ArrayRCP;
887 using Teuchos::ArrayView;
889 using Teuchos::ParameterList;
892 using Teuchos::sublist;
895 const char tfecfFuncName[] =
"clone";
898 bool fillCompleteClone =
true;
899 bool useLocalIndices = this->
hasColMap ();
901 if (! params.is_null ()) {
902 fillCompleteClone = params->get (
"fillComplete clone", fillCompleteClone);
903 useLocalIndices = params->get (
"Locally indexed clone", useLocalIndices);
905 bool staticProfileClone =
true;
906 staticProfileClone = params->get (
"Static profile clone", staticProfileClone);
907 pftype = staticProfileClone ? StaticProfile :
ProfileType(StaticProfile+1) ;
910 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
911 ! this->
hasColMap () && useLocalIndices, std::runtime_error,
912 ": You requested that the returned clone have local indices, but the "
913 "the source matrix does not have a column Map yet.");
915 RCP<const Map2> clonedRowMap = this->
getRowMap ()->template clone<Node2> (node2);
918 RCP<CrsMatrix2> clonedMatrix;
919 ArrayRCP<const size_t> numEntriesPerRow;
920 size_t numEntriesForAll = 0;
921 bool boundSameForAllLocalRows =
false;
922 staticGraph_->getNumEntriesPerLocalRowUpperBound (numEntriesPerRow,
924 boundSameForAllLocalRows);
925 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
926 numEntriesForAll != 0 &&
927 static_cast<size_t> (numEntriesPerRow.size ()) != 0,
928 std::logic_error,
": getNumEntriesPerLocalRowUpperBound returned a "
929 "nonzero numEntriesForAll = " << numEntriesForAll <<
" , as well as a "
930 "numEntriesPerRow array of nonzero length " << numEntriesPerRow.size ()
931 <<
". This should never happen. Please report this bug to the Tpetra "
933 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
934 numEntriesForAll != 0 && ! boundSameForAllLocalRows,
935 std::logic_error,
": getNumEntriesPerLocalRowUpperBound returned a "
936 "nonzero numEntriesForAll = " << numEntriesForAll <<
" , but claims "
937 "(via its third output value) that the upper bound is not the same for "
938 "all rows. This should never happen. Please report this bug to the "
939 "Tpetra developers.");
940 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
941 numEntriesPerRow.size () != 0 && boundSameForAllLocalRows,
942 std::logic_error,
": getNumEntriesPerLocalRowUpperBound returned a "
943 "numEntriesPerRow array of nonzero length " << numEntriesPerRow.size ()
944 <<
", but claims (via its third output value) that the upper bound is "
945 "not the same for all rows. This should never happen. Please report "
946 "this bug to the Tpetra developers.");
948 RCP<ParameterList> matParams =
949 params.is_null () ? null : sublist (params,
"CrsMatrix");
950 if (useLocalIndices) {
951 RCP<const Map2> clonedColMap =
952 this->
getColMap ()->template clone<Node2> (node2);
953 if (numEntriesPerRow.is_null ()) {
954 clonedMatrix = rcp (
new CrsMatrix2 (clonedRowMap, clonedColMap,
955 numEntriesForAll, pftype,
959 clonedMatrix = rcp (
new CrsMatrix2 (clonedRowMap, clonedColMap,
960 numEntriesPerRow (), pftype,
965 if (numEntriesPerRow.is_null ()) {
966 clonedMatrix = rcp (
new CrsMatrix2 (clonedRowMap, numEntriesForAll,
970 clonedMatrix = rcp (
new CrsMatrix2 (clonedRowMap,
976 numEntriesPerRow = Teuchos::null;
977 numEntriesForAll = 0;
979 if (useLocalIndices) {
980 clonedMatrix->allocateValues (LocalIndices,
981 CrsMatrix2::GraphNotYetAllocated);
983 ArrayView<const LocalOrdinal> linds;
984 ArrayView<const Scalar> vals;
985 for (LocalOrdinal lrow = clonedRowMap->getMinLocalIndex ();
986 lrow <= clonedRowMap->getMaxLocalIndex ();
990 clonedMatrix->insertLocalValues (lrow, linds, vals);
995 Array<LocalOrdinal> linds;
997 for (LocalOrdinal lrow = clonedRowMap->getMinLocalIndex ();
998 lrow <= clonedRowMap->getMaxLocalIndex ();
1001 if (theNumEntries > static_cast<size_t> (linds.size ())) {
1002 linds.resize (theNumEntries);
1004 if (theNumEntries > static_cast<size_t> (vals.size ())) {
1005 vals.resize (theNumEntries);
1008 linds (), vals (), theNumEntries);
1009 if (theNumEntries != 0) {
1010 clonedMatrix->insertLocalValues (lrow, linds (0, theNumEntries),
1011 vals (0, theNumEntries));
1017 clonedMatrix->allocateValues (GlobalIndices,
1018 CrsMatrix2::GraphNotYetAllocated);
1020 ArrayView<const GlobalOrdinal> ginds;
1021 ArrayView<const Scalar> vals;
1022 for (GlobalOrdinal grow = clonedRowMap->getMinGlobalIndex ();
1023 grow <= clonedRowMap->getMaxGlobalIndex ();
1026 if (ginds.size () > 0) {
1027 clonedMatrix->insertGlobalValues (grow, ginds, vals);
1032 Array<GlobalOrdinal> ginds;
1034 for (GlobalOrdinal grow = clonedRowMap->getMinGlobalIndex ();
1035 grow <= clonedRowMap->getMaxGlobalIndex ();
1038 if (theNumEntries > static_cast<size_t> (ginds.size ())) {
1039 ginds.resize (theNumEntries);
1041 if (theNumEntries > static_cast<size_t> (vals.size ())) {
1042 vals.resize (theNumEntries);
1045 if (theNumEntries != 0) {
1046 clonedMatrix->insertGlobalValues (grow, ginds (0, theNumEntries),
1047 vals (0, theNumEntries));
1053 if (fillCompleteClone) {
1054 RCP<const Map2> clonedRangeMap;
1055 RCP<const Map2> clonedDomainMap;
1059 clonedRangeMap = this->
getRangeMap ()->template clone<Node2> (node2);
1062 clonedRangeMap = clonedRowMap;
1066 clonedDomainMap = this->
getDomainMap ()->template clone<Node2> (node2);
1069 clonedDomainMap = clonedRowMap;
1072 catch (std::exception &e) {
1073 const bool caughtExceptionOnClone =
true;
1074 TEUCHOS_TEST_FOR_EXCEPTION
1075 (caughtExceptionOnClone, std::runtime_error,
1076 Teuchos::typeName (*
this) <<
"::clone: Caught the following "
1077 "exception while cloning range and domain Maps on a clone of "
1078 "type " << Teuchos::typeName (*clonedMatrix) <<
": " << e.what ());
1081 RCP<ParameterList> fillparams =
1082 params.is_null () ? Teuchos::null : sublist (params,
"fillComplete");
1084 clonedMatrix->fillComplete (clonedDomainMap, clonedRangeMap,
1087 catch (std::exception &e) {
1088 const bool caughtExceptionOnClone =
true;
1089 TEUCHOS_TEST_FOR_EXCEPTION(
1090 caughtExceptionOnClone, std::runtime_error,
1091 Teuchos::typeName (*
this) <<
"::clone: Caught the following "
1092 "exception while calling fillComplete() on a clone of type "
1093 << Teuchos::typeName (*clonedMatrix) <<
": " << e.what ());
1096 return clonedMatrix;
1176 const Teuchos::ArrayView<const GlobalOrdinal>& cols,
1177 const Teuchos::ArrayView<const Scalar>& vals);
1195 const LocalOrdinal numEnt,
1196 const Scalar vals[],
1197 const GlobalOrdinal inds[]);
1241 const Teuchos::ArrayView<const LocalOrdinal> &cols,
1242 const Teuchos::ArrayView<const Scalar> &vals);
1260 const LocalOrdinal numEnt,
1261 const Scalar vals[],
1262 const LocalOrdinal cols[]);
1278 const RowInfo& rowInfo,
1279 const GlobalOrdinal inds[],
1281 const LocalOrdinal numElts)
const;
1320 template<
class GlobalIndicesViewType,
1321 class ImplScalarViewType>
1324 const typename UnmanagedView<GlobalIndicesViewType>::type& inputInds,
1325 const typename UnmanagedView<ImplScalarViewType>::type& inputVals)
const
1333 static_assert (Kokkos::is_view<GlobalIndicesViewType>::value,
1334 "First template parameter GlobalIndicesViewType must be "
1336 static_assert (Kokkos::is_view<ImplScalarViewType>::value,
1337 "Second template parameter ImplScalarViewType must be a "
1339 static_assert (static_cast<int> (GlobalIndicesViewType::rank) == 1,
1340 "First template parameter GlobalIndicesViewType must "
1342 static_assert (static_cast<int> (ImplScalarViewType::rank) == 1,
1343 "Second template parameter ImplScalarViewType must have "
1345 static_assert (std::is_same<
1346 typename GlobalIndicesViewType::non_const_value_type,
1348 "First template parameter GlobalIndicesViewType must "
1349 "contain values of type global_ordinal_type.");
1350 static_assert (std::is_same<
1351 typename ImplScalarViewType::non_const_value_type,
1353 "Second template parameter ImplScalarViewType must "
1354 "contain values of type impl_scalar_type.");
1355 typedef LocalOrdinal LO;
1356 const LO numInputEnt = inputInds.extent (0);
1357 if (static_cast<LO> (inputVals.extent (0)) != numInputEnt) {
1358 return Teuchos::OrdinalTraits<LO>::invalid ();
1360 const Scalar*
const inVals =
1361 reinterpret_cast<const Scalar*
> (inputVals.data ());
1371 const Teuchos::ArrayView<const GlobalOrdinal>& cols,
1372 const Teuchos::ArrayView<const Scalar>& vals)
const;
1391 const LocalOrdinal numEnt,
1392 const Scalar vals[],
1393 const GlobalOrdinal cols[])
const;
1410 const LocalOrdinal inds[],
1412 const LocalOrdinal numElts)
const;
1450 template<
class LocalIndicesViewType,
1451 class ImplScalarViewType>
1454 const typename UnmanagedView<LocalIndicesViewType>::type& inputInds,
1455 const typename UnmanagedView<ImplScalarViewType>::type& inputVals)
const
1463 static_assert (Kokkos::is_view<LocalIndicesViewType>::value,
1464 "First template parameter LocalIndicesViewType must be "
1466 static_assert (Kokkos::is_view<ImplScalarViewType>::value,
1467 "Second template parameter ImplScalarViewType must be a "
1469 static_assert (static_cast<int> (LocalIndicesViewType::rank) == 1,
1470 "First template parameter LocalIndicesViewType must "
1472 static_assert (static_cast<int> (ImplScalarViewType::rank) == 1,
1473 "Second template parameter ImplScalarViewType must have "
1475 static_assert (std::is_same<
1476 typename LocalIndicesViewType::non_const_value_type,
1478 "First template parameter LocalIndicesViewType must "
1479 "contain values of type local_ordinal_type.");
1480 static_assert (std::is_same<
1481 typename ImplScalarViewType::non_const_value_type,
1483 "Second template parameter ImplScalarViewType must "
1484 "contain values of type impl_scalar_type.");
1486 typedef LocalOrdinal LO;
1487 const LO numInputEnt = inputInds.extent (0);
1488 if (numInputEnt != inputVals.extent (0)) {
1489 return Teuchos::OrdinalTraits<LO>::invalid ();
1491 const Scalar*
const inVals =
1492 reinterpret_cast<const Scalar*
> (inputVals.data ());
1494 inVals, inputInds.data ());
1502 const Teuchos::ArrayView<const LocalOrdinal>& cols,
1503 const Teuchos::ArrayView<const Scalar>& vals)
const;
1524 const LocalOrdinal numEnt,
1525 const Scalar inputVals[],
1526 const LocalOrdinal inputCols[])
const;
1533 static const bool useAtomicUpdatesByDefault =
1534 #ifdef KOKKOS_ENABLE_SERIAL
1535 ! std::is_same<execution_space, Kokkos::Serial>::value;
1538 #endif // KOKKOS_ENABLE_SERIAL
1567 const GlobalOrdinal inds[],
1569 const LocalOrdinal numElts,
1570 const bool atomic = useAtomicUpdatesByDefault)
const;
1611 const Teuchos::ArrayView<const GlobalOrdinal>& cols,
1612 const Teuchos::ArrayView<const Scalar>& vals,
1613 const bool atomic = useAtomicUpdatesByDefault);
1639 const LocalOrdinal numEnt,
1640 const Scalar vals[],
1641 const GlobalOrdinal cols[],
1642 const bool atomic = useAtomicUpdatesByDefault);
1661 const LocalOrdinal inds[],
1663 const LocalOrdinal numElts,
1664 const bool atomic = useAtomicUpdatesByDefault)
const;
1703 template<
class LocalIndicesViewType,
1704 class ImplScalarViewType>
1707 const typename UnmanagedView<LocalIndicesViewType>::type& inputInds,
1708 const typename UnmanagedView<ImplScalarViewType>::type& inputVals,
1709 const bool atomic = useAtomicUpdatesByDefault)
const
1717 static_assert (Kokkos::is_view<LocalIndicesViewType>::value,
1718 "First template parameter LocalIndicesViewType must be "
1720 static_assert (Kokkos::is_view<ImplScalarViewType>::value,
1721 "Second template parameter ImplScalarViewType must be a "
1723 static_assert (static_cast<int> (LocalIndicesViewType::rank) == 1,
1724 "First template parameter LocalIndicesViewType must "
1726 static_assert (static_cast<int> (ImplScalarViewType::rank) == 1,
1727 "Second template parameter ImplScalarViewType must have "
1729 static_assert (std::is_same<
1730 typename LocalIndicesViewType::non_const_value_type,
1732 "First template parameter LocalIndicesViewType must "
1733 "contain values of type local_ordinal_type.");
1734 static_assert (std::is_same<
1735 typename ImplScalarViewType::non_const_value_type,
1737 "Second template parameter ImplScalarViewType must "
1738 "contain values of type impl_scalar_type.");
1739 typedef LocalOrdinal LO;
1740 const LO numInputEnt = inputInds.extent (0);
1741 if (static_cast<LO> (inputVals.extent (0)) != numInputEnt) {
1742 return Teuchos::OrdinalTraits<LO>::invalid ();
1746 reinterpret_cast<const Scalar*> (inputVals.data ()),
1782 const Teuchos::ArrayView<const LocalOrdinal>& cols,
1783 const Teuchos::ArrayView<const Scalar>& vals,
1784 const bool atomic = useAtomicUpdatesByDefault)
const;
1809 const LocalOrdinal numEnt,
1810 const Scalar vals[],
1811 const LocalOrdinal cols[],
1812 const bool atomic = useAtomicUpdatesByDefault)
const;
1849 const LocalOrdinal inds[],
1851 const LocalOrdinal numElts,
1853 const bool atomic = useAtomicUpdatesByDefault)
const;
1889 const GlobalOrdinal inds[],
1891 const LocalOrdinal numElts,
1893 const bool atomic = useAtomicUpdatesByDefault)
const;
1922 transformLocalValues (
const LocalOrdinal lclRow,
1923 const LocalOrdinal numInputEnt,
1925 const LocalOrdinal inputCols[],
1927 const bool atomic = useAtomicUpdatesByDefault)
const;
1956 transformGlobalValues (
const GlobalOrdinal gblRow,
1957 const LocalOrdinal numInputEnt,
1959 const GlobalOrdinal inputCols[],
1961 const bool atomic = useAtomicUpdatesByDefault)
const;
2007 template<
class LocalIndicesViewType,
2008 class ImplScalarViewType,
2009 class BinaryFunction>
2012 const typename UnmanagedView<LocalIndicesViewType>::type& inputInds,
2013 const typename UnmanagedView<ImplScalarViewType>::type& inputVals,
2015 const bool atomic = useAtomicUpdatesByDefault)
const
2023 static_assert (Kokkos::is_view<LocalIndicesViewType>::value,
2024 "First template parameter LocalIndicesViewType must be "
2026 static_assert (Kokkos::is_view<ImplScalarViewType>::value,
2027 "Second template parameter ImplScalarViewType must be a "
2029 static_assert (static_cast<int> (LocalIndicesViewType::rank) == 1,
2030 "First template parameter LocalIndicesViewType must "
2032 static_assert (static_cast<int> (ImplScalarViewType::rank) == 1,
2033 "Second template parameter ImplScalarViewType must have "
2035 static_assert (std::is_same<
2036 typename LocalIndicesViewType::non_const_value_type,
2038 "First template parameter LocalIndicesViewType must "
2039 "contain values of type local_ordinal_type.");
2040 static_assert (std::is_same<
2041 typename ImplScalarViewType::non_const_value_type,
2043 "Second template parameter ImplScalarViewType must "
2044 "contain values of type impl_scalar_type.");
2045 typedef LocalOrdinal LO;
2046 const LO numInputEnt = inputInds.extent (0);
2047 if (static_cast<LO> (inputVals.extent (0)) != numInputEnt) {
2048 return Teuchos::OrdinalTraits<LO>::invalid ();
2050 return this->transformLocalValues (lclRow,
2099 template<
class BinaryFunction,
class InputMemorySpace>
2102 const Kokkos::View<
const GlobalOrdinal*,
2104 Kokkos::MemoryUnmanaged>& inputInds,
2107 Kokkos::MemoryUnmanaged>& inputVals,
2109 const bool atomic = useAtomicUpdatesByDefault)
const
2111 typedef LocalOrdinal LO;
2112 const LO numInputEnt = inputInds.extent (0);
2113 if (static_cast<LO> (inputVals.extent (0)) != numInputEnt) {
2114 return Teuchos::OrdinalTraits<LO>::invalid ();
2116 return this->transformGlobalValues (gblRow,
2128 void scale (
const Scalar& alpha);
2154 setAllValues (
const typename local_matrix_type::row_map_type& ptr,
2155 const typename local_graph_type::entries_type::non_const_type& ind,
2156 const typename local_matrix_type::values_type& val);
2183 const Teuchos::ArrayRCP<LocalOrdinal>& ind,
2184 const Teuchos::ArrayRCP<Scalar>& val);
2187 getAllValues (Teuchos::ArrayRCP<const size_t>& rowPointers,
2188 Teuchos::ArrayRCP<const LocalOrdinal>& columnIndices,
2189 Teuchos::ArrayRCP<const Scalar>& values)
const;
2238 void resumeFill (
const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
2298 fillComplete (
const Teuchos::RCP<const map_type>& domainMap,
2299 const Teuchos::RCP<const map_type>& rangeMap,
2300 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
2329 fillComplete (
const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
2359 const Teuchos::RCP<const map_type>& rangeMap,
2360 const Teuchos::RCP<const import_type>& importer = Teuchos::null,
2361 const Teuchos::RCP<const export_type>& exporter = Teuchos::null,
2362 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
2374 replaceColMap (
const Teuchos::RCP<const map_type>& newColMap);
2459 const Teuchos::RCP<const map_type>& newColMap,
2460 const Teuchos::RCP<const import_type>& newImport = Teuchos::null,
2461 const bool sortEachRow =
true);
2477 Teuchos::RCP<const import_type>& newImporter);
2500 Teuchos::RCP<const Teuchos::Comm<int> >
getComm()
const override;
2502 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
2503 TPETRA_DEPRECATED Teuchos::RCP<node_type> getNode ()
const override;
2505 #endif // TPETRA_ENABLE_DEPRECATED_CODE
2508 Teuchos::RCP<const map_type>
getRowMap ()
const override;
2511 Teuchos::RCP<const map_type>
getColMap ()
const override;
2514 Teuchos::RCP<const RowGraph<LocalOrdinal, GlobalOrdinal, Node> >
2518 Teuchos::RCP<const crs_graph_type>
getCrsGraph ()
const;
2632 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
2649 size_t TPETRA_DEPRECATED getNodeNumDiags ()
const override;
2675 size_t getNodeNumDiagsImpl ()
const override;
2687 bool TPETRA_DEPRECATED isLowerTriangular ()
const override;
2699 bool TPETRA_DEPRECATED isUpperTriangular ()
const override;
2712 bool isLowerTriangularImpl ()
const override;
2725 bool isUpperTriangularImpl ()
const override;
2726 #endif // TPETRA_ENABLE_DEPRECATED_CODE
2902 const Teuchos::ArrayView<GlobalOrdinal>& Indices,
2903 const Teuchos::ArrayView<Scalar>& Values,
2904 size_t& NumEntries)
const override;
2923 const Teuchos::ArrayView<LocalOrdinal>& colInds,
2924 const Teuchos::ArrayView<Scalar>& vals,
2925 size_t& numEntries)
const override;
2941 Teuchos::ArrayView<const GlobalOrdinal>& indices,
2942 Teuchos::ArrayView<const Scalar>& values)
const override;
2958 Teuchos::ArrayView<const LocalOrdinal>& indices,
2959 Teuchos::ArrayView<const Scalar>& values)
const override;
2987 LocalOrdinal& numEnt,
2988 const LocalOrdinal*& lclColInds,
2989 const Scalar*& vals)
const override;
3016 LocalOrdinal& numEnt,
3018 const LocalOrdinal*& ind)
const;
3027 template<
class OutputScalarType>
3028 typename std::enable_if<! std::is_same<OutputScalarType, impl_scalar_type>::value &&
3029 std::is_convertible<impl_scalar_type, OutputScalarType>::value,
3032 LocalOrdinal& numEnt,
3033 const OutputScalarType*& val,
3034 const LocalOrdinal*& ind)
const
3037 const LocalOrdinal err = this->
getLocalRowView (lclRow, numEnt, valTmp, ind);
3040 val =
reinterpret_cast<const OutputScalarType*
> (valTmp);
3122 Kokkos::MemoryUnmanaged>& offsets)
const;
3148 const Teuchos::ArrayView<const size_t>& offsets)
const;
3232 const Teuchos::ETransp mode = Teuchos::NO_TRANS,
3233 const Scalar& alpha = Teuchos::ScalarTraits<Scalar>::one (),
3234 const Scalar& beta = Teuchos::ScalarTraits<Scalar>::zero ())
const;
3260 template <
class DomainScalar,
class RangeScalar>
3265 const RangeScalar& dampingFactor,
3268 typedef LocalOrdinal LO;
3269 typedef GlobalOrdinal GO;
3272 typedef typename Node::device_type::memory_space dev_mem_space;
3273 typedef typename MMV::dual_view_type::t_host::device_type host_mem_space;
3275 typedef typename k_local_graph_type::size_type offset_type;
3276 const char prefix[] =
"Tpetra::CrsMatrix::localGaussSeidel: ";
3278 TEUCHOS_TEST_FOR_EXCEPTION
3280 prefix <<
"The matrix is not fill complete.");
3283 TEUCHOS_TEST_FOR_EXCEPTION
3285 prefix <<
"B.getNumVectors() = " << numVecs <<
" != "
3287 TEUCHOS_TEST_FOR_EXCEPTION
3290 <<
" != this->getNodeNumRows() = " << lclNumRows <<
".");
3295 const_cast<DMV&
> (B).sync_host ();
3298 const_cast<MMV&
> (D).sync_host ();
3300 auto B_lcl = B.template getLocalView<host_mem_space> ();
3301 auto X_lcl = X.template getLocalView<host_mem_space> ();
3302 auto D_lcl = D.template getLocalView<host_mem_space> ();
3304 offset_type B_stride[8], X_stride[8], D_stride[8];
3305 B_lcl.stride (B_stride);
3306 X_lcl.stride (X_stride);
3307 D_lcl.stride (D_stride);
3310 k_local_graph_type lclGraph = lclMatrix.graph;
3311 typename local_matrix_type::row_map_type ptr = lclGraph.row_map;
3312 typename local_matrix_type::index_type ind = lclGraph.entries;
3313 typename local_matrix_type::values_type val = lclMatrix.values;
3314 const offset_type*
const ptrRaw = ptr.data ();
3315 const LO*
const indRaw = ind.data ();
3318 const std::string dir ((direction == Forward) ?
"F" :
"B");
3324 KokkosSparse::Impl::Sequential::gaussSeidel (static_cast<LO> (lclNumRows),
3325 static_cast<LO> (numVecs),
3326 ptrRaw, indRaw, valRaw,
3327 B_lcl.data (), B_stride[1],
3328 X_lcl.data (), X_stride[1],
3332 const_cast<DMV&
> (B).
template sync<dev_mem_space> ();
3333 X.template sync<dev_mem_space> ();
3334 const_cast<MMV&
> (D).
template sync<dev_mem_space> ();
3363 template <
class DomainScalar,
class RangeScalar>
3368 const Teuchos::ArrayView<LocalOrdinal>& rowIndices,
3369 const RangeScalar& dampingFactor,
3372 typedef LocalOrdinal LO;
3373 typedef GlobalOrdinal GO;
3376 typedef typename Node::device_type::memory_space dev_mem_space;
3377 typedef typename MMV::dual_view_type::t_host::device_type host_mem_space;
3379 typedef typename k_local_graph_type::size_type offset_type;
3380 const char prefix[] =
"Tpetra::CrsMatrix::reorderedLocalGaussSeidel: ";
3382 TEUCHOS_TEST_FOR_EXCEPTION
3384 prefix <<
"The matrix is not fill complete.");
3387 TEUCHOS_TEST_FOR_EXCEPTION
3389 prefix <<
"B.getNumVectors() = " << numVecs <<
" != "
3391 TEUCHOS_TEST_FOR_EXCEPTION
3394 <<
" != this->getNodeNumRows() = " << lclNumRows <<
".");
3395 TEUCHOS_TEST_FOR_EXCEPTION
3396 (static_cast<size_t> (rowIndices.size ()) < lclNumRows,
3397 std::invalid_argument, prefix <<
"rowIndices.size() = "
3398 << rowIndices.size () <<
" < this->getNodeNumRows() = "
3399 << lclNumRows <<
".");
3404 const_cast<DMV&
> (B).sync_host ();
3407 const_cast<MMV&
> (D).sync_host ();
3409 auto B_lcl = B.template getLocalView<host_mem_space> ();
3410 auto X_lcl = X.template getLocalView<host_mem_space> ();
3411 auto D_lcl = D.template getLocalView<host_mem_space> ();
3413 offset_type B_stride[8], X_stride[8], D_stride[8];
3414 B_lcl.stride (B_stride);
3415 X_lcl.stride (X_stride);
3416 D_lcl.stride (D_stride);
3420 typename local_matrix_type::index_type ind = lclGraph.entries;
3421 typename local_matrix_type::row_map_type ptr = lclGraph.row_map;
3422 typename local_matrix_type::values_type val = lclMatrix.values;
3423 const offset_type*
const ptrRaw = ptr.data ();
3424 const LO*
const indRaw = ind.data ();
3427 const std::string dir = (direction == Forward) ?
"F" :
"B";
3432 KokkosSparse::Impl::Sequential::reorderedGaussSeidel (static_cast<LO> (lclNumRows),
3433 static_cast<LO> (numVecs),
3434 ptrRaw, indRaw, valRaw,
3440 rowIndices.getRawPtr (),
3441 static_cast<LO
> (lclNumRows),
3442 static_cast<impl_scalar_type> (dampingFactor),
3444 const_cast<DMV&
> (B).
template sync<dev_mem_space> ();
3445 X.template sync<dev_mem_space> ();
3446 const_cast<MMV&
> (D).
template sync<dev_mem_space> ();
3452 Teuchos::RCP<CrsMatrix<T, LocalOrdinal, GlobalOrdinal, Node> >
3472 Teuchos::ETransp mode = Teuchos::NO_TRANS,
3473 Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
3474 Scalar beta = Teuchos::ScalarTraits<Scalar>::zero())
const override;
3486 Teuchos::RCP<const map_type>
getDomainMap ()
const override;
3494 Teuchos::RCP<const map_type>
getRangeMap ()
const override;
3568 const Scalar& dampingFactor,
3570 const int numSweeps)
const;
3642 const Teuchos::ArrayView<LocalOrdinal>& rowIndices,
3643 const Scalar& dampingFactor,
3645 const int numSweeps)
const;
3679 const Scalar& dampingFactor,
3681 const int numSweeps,
3682 const bool zeroInitialGuess)
const;
3717 const Teuchos::ArrayView<LocalOrdinal>& rowIndices,
3718 const Scalar& dampingFactor,
3720 const int numSweeps,
3721 const bool zeroInitialGuess)
const;
3733 virtual Teuchos::RCP<RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
3734 add (
const Scalar& alpha,
3739 const Teuchos::RCP<Teuchos::ParameterList>& params)
const override;
3751 describe (Teuchos::FancyOStream& out,
3752 const Teuchos::EVerbosityLevel verbLevel =
3753 Teuchos::Describable::verbLevel_default)
const override;
3763 typedef typename DistObject<Scalar, LocalOrdinal, GlobalOrdinal,
3770 applyCrsPadding(
const Kokkos::UnorderedMap<LocalOrdinal, size_t, device_type>& padding);
3775 const size_t numSameIDs,
3776 const LocalOrdinal permuteToLIDs[],
3777 const LocalOrdinal permuteFromLIDs[],
3778 const size_t numPermutes);
3781 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
3783 #else // TPETRA_ENABLE_DEPRECATED_CODE
3785 #endif // TPETRA_ENABLE_DEPRECATED_CODE
3787 const size_t numSameIDs,
3788 const Kokkos::DualView<
3791 const Kokkos::DualView<
3796 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
3798 #else // TPETRA_ENABLE_DEPRECATED_CODE
3800 #endif // TPETRA_ENABLE_DEPRECATED_CODE
3802 const Kokkos::DualView<
3805 Kokkos::DualView<char*, buffer_device_type>& exports,
3806 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
3807 size_t& constantNumPackets,
3816 const Kokkos::DualView<
const char*,
3818 const Kokkos::DualView<
const size_t*,
3820 const size_t constantNumPackets,
3823 const bool atomic = useAtomicUpdatesByDefault);
3830 const Kokkos::DualView<
const char*,
3832 const Kokkos::DualView<
const size_t*,
3834 const size_t constantNumPackets,
3849 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
3851 #else // TPETRA_ENABLE_DEPRECATED_CODE
3853 #endif // TPETRA_ENABLE_DEPRECATED_CODE
3854 (
const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& importLIDs,
3855 Kokkos::DualView<char*, buffer_device_type> imports,
3856 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
3857 const size_t constantNumPackets,
3969 packNew (
const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& exportLIDs,
3970 Kokkos::DualView<char*, buffer_device_type>& exports,
3971 const Kokkos::DualView<size_t*, buffer_device_type>& numPacketsPerLID,
3972 size_t& constantNumPackets,
3983 packNonStaticNew (
const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& exportLIDs,
3984 Kokkos::DualView<char*, buffer_device_type>& exports,
3985 const Kokkos::DualView<size_t*, buffer_device_type>& numPacketsPerLID,
3986 size_t& constantNumPackets,
4019 packRow (
char exports[],
4020 const size_t offset,
4021 const size_t numEnt,
4022 const GlobalOrdinal gidsIn[],
4024 const size_t numBytesPerValue)
const;
4050 packRowStatic (
char*
const numEntOut,
4053 const size_t numEnt,
4054 const LocalOrdinal lclRow)
const;
4082 unpackRow (GlobalOrdinal gidsOut[],
4084 const char imports[],
4085 const size_t offset,
4086 const size_t numBytes,
4087 const size_t numEnt,
4088 const size_t numBytesPerValue);
4099 allocatePackSpaceNew (Kokkos::DualView<char*, buffer_device_type>& exports,
4100 size_t& totalNumEntries,
4113 template<
class CrsMatrixType>
4114 friend Teuchos::RCP<CrsMatrixType>
4116 const Import<
typename CrsMatrixType::local_ordinal_type,
4117 typename CrsMatrixType::global_ordinal_type,
4118 typename CrsMatrixType::node_type>& importer,
4119 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4120 typename CrsMatrixType::global_ordinal_type,
4121 typename CrsMatrixType::node_type> >& domainMap,
4122 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4123 typename CrsMatrixType::global_ordinal_type,
4124 typename CrsMatrixType::node_type> >& rangeMap,
4125 const Teuchos::RCP<Teuchos::ParameterList>& params);
4128 template<
class CrsMatrixType>
4129 friend Teuchos::RCP<CrsMatrixType>
4131 const Import<
typename CrsMatrixType::local_ordinal_type,
4132 typename CrsMatrixType::global_ordinal_type,
4133 typename CrsMatrixType::node_type>& rowImporter,
4134 const Import<
typename CrsMatrixType::local_ordinal_type,
4135 typename CrsMatrixType::global_ordinal_type,
4136 typename CrsMatrixType::node_type>& domainImporter,
4137 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4138 typename CrsMatrixType::global_ordinal_type,
4139 typename CrsMatrixType::node_type> >& domainMap,
4140 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4141 typename CrsMatrixType::global_ordinal_type,
4142 typename CrsMatrixType::node_type> >& rangeMap,
4143 const Teuchos::RCP<Teuchos::ParameterList>& params);
4147 template<
class CrsMatrixType>
4148 friend Teuchos::RCP<CrsMatrixType>
4150 const Export<
typename CrsMatrixType::local_ordinal_type,
4151 typename CrsMatrixType::global_ordinal_type,
4152 typename CrsMatrixType::node_type>& exporter,
4153 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4154 typename CrsMatrixType::global_ordinal_type,
4155 typename CrsMatrixType::node_type> >& domainMap,
4156 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4157 typename CrsMatrixType::global_ordinal_type,
4158 typename CrsMatrixType::node_type> >& rangeMap,
4159 const Teuchos::RCP<Teuchos::ParameterList>& params);
4162 template<
class CrsMatrixType>
4163 friend Teuchos::RCP<CrsMatrixType>
4165 const Export<
typename CrsMatrixType::local_ordinal_type,
4166 typename CrsMatrixType::global_ordinal_type,
4167 typename CrsMatrixType::node_type>& rowExporter,
4168 const Export<
typename CrsMatrixType::local_ordinal_type,
4169 typename CrsMatrixType::global_ordinal_type,
4170 typename CrsMatrixType::node_type>& domainExporter,
4171 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4172 typename CrsMatrixType::global_ordinal_type,
4173 typename CrsMatrixType::node_type> >& domainMap,
4174 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4175 typename CrsMatrixType::global_ordinal_type,
4176 typename CrsMatrixType::node_type> >& rangeMap,
4177 const Teuchos::RCP<Teuchos::ParameterList>& params);
4198 const Teuchos::RCP<const map_type>& domainMap,
4199 const Teuchos::RCP<const map_type>& rangeMap,
4200 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
4221 const Teuchos::RCP<const map_type>& domainMap,
4222 const Teuchos::RCP<const map_type>& rangeMap,
4223 const Teuchos::RCP<Teuchos::ParameterList>& params)
const;
4244 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
4245 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
4246 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
4267 const Teuchos::RCP<const map_type>& domainMap,
4268 const Teuchos::RCP<const map_type>& rangeMap,
4269 const Teuchos::RCP<Teuchos::ParameterList>& params)
const;
4295 const ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node>& rowTransfer,
4296 const Teuchos::RCP<const ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node> > & domainTransfer,
4297 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
4298 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
4299 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
4315 const GlobalOrdinal gblColInds[],
4317 const size_t numInputEnt);
4329 insertGlobalValuesFiltered (
const GlobalOrdinal globalRow,
4330 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
4331 const Teuchos::ArrayView<const Scalar>& values);
4345 combineGlobalValues (
const GlobalOrdinal globalRowIndex,
4346 const Teuchos::ArrayView<const GlobalOrdinal>& columnIndices,
4347 const Teuchos::ArrayView<const Scalar>& values,
4368 combineGlobalValuesRaw (
const LocalOrdinal lclRow,
4369 const LocalOrdinal numEnt,
4371 const GlobalOrdinal cols[],
4385 template<
class BinaryFunction>
4387 transformGlobalValues (
const GlobalOrdinal globalRow,
4388 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
4389 const Teuchos::ArrayView<const Scalar>& values,
4391 const bool atomic = useAtomicUpdatesByDefault)
const
4394 typedef LocalOrdinal LO;
4395 typedef GlobalOrdinal GO;
4397 const LO numInputEnt =
static_cast<LO
> (indices.size ());
4398 if (static_cast<LO> (values.size ()) != numInputEnt) {
4399 return Teuchos::OrdinalTraits<LO>::invalid ();
4402 const GO*
const inputCols = indices.getRawPtr ();
4403 const IST*
const inputVals =
4404 reinterpret_cast<const IST*
> (values.getRawPtr ());
4405 return this->transformGlobalValues (globalRow, numInputEnt, inputVals,
4406 inputCols, f, atomic);
4416 insertNonownedGlobalValues (
const GlobalOrdinal globalRow,
4417 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
4418 const Teuchos::ArrayView<const Scalar>& values);
4465 const typename crs_graph_type::SLocalGlobalViews& newInds,
4466 const Teuchos::ArrayView<impl_scalar_type>& oldRowVals,
4467 const Teuchos::ArrayView<const impl_scalar_type>& newRowVals,
4468 const ELocalGlobal lg,
4469 const ELocalGlobal I);
4472 typedef DistObject<char, LocalOrdinal, GlobalOrdinal, Node> dist_object_type;
4476 typedef Teuchos::OrdinalTraits<LocalOrdinal> OTL;
4477 typedef Kokkos::Details::ArithTraits<impl_scalar_type> STS;
4478 typedef Kokkos::Details::ArithTraits<mag_type> STM;
4479 typedef MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> MV;
4480 typedef Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> V;
4484 enum GraphAllocationStatus {
4485 GraphAlreadyAllocated,
4486 GraphNotYetAllocated
4493 Teuchos::ArrayRCP<Teuchos::Array<impl_scalar_type> >
4494 allocateValues2D ();
4513 void allocateValues (ELocalGlobal lg, GraphAllocationStatus gas);
4526 const RowInfo& rowInfo);
4617 const bool force =
false)
const;
4642 const bool force =
false)
const;
4655 const Teuchos::ETransp mode,
4681 LocalOrdinal& numEnt,
4682 const RowInfo& rowinfo)
const;
4704 LocalOrdinal& numEnt,
4705 const RowInfo& rowinfo)
const;
4714 Teuchos::ArrayView<const impl_scalar_type>
getView (
RowInfo rowinfo)
const;
4727 Teuchos::ArrayView<impl_scalar_type>
4738 Kokkos::View<const impl_scalar_type*, execution_space, Kokkos::MemoryUnmanaged>
4739 getRowView (
const RowInfo& rowInfo)
const;
4752 Kokkos::View<impl_scalar_type*, execution_space, Kokkos::MemoryUnmanaged>
4753 getRowViewNonConst (
const RowInfo& rowInfo)
const;
4759 friend class Tpetra::crsMatrix_Swap_Tester<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
4774 void fillLocalMatrix (
const Teuchos::RCP<Teuchos::ParameterList>& params);
4798 Teuchos::RCP<const Graph> staticGraph_;
4799 Teuchos::RCP< Graph> myGraph_;
4822 typename local_matrix_type::values_type k_values1D_;
4823 Teuchos::ArrayRCP<Teuchos::Array<impl_scalar_type> > values2D_;
4867 std::map<GlobalOrdinal, std::pair<Teuchos::Array<GlobalOrdinal>,
4882 template<
class ViewType,
class OffsetViewType>
4883 struct pack_functor {
4887 OffsetViewType src_offset_;
4888 OffsetViewType dst_offset_;
4889 typedef typename OffsetViewType::non_const_value_type scalar_index_type;
4891 pack_functor (ViewType dst, ViewType src,
4892 OffsetViewType dst_offset, OffsetViewType src_offset) :
4895 src_offset_ (src_offset),
4896 dst_offset_ (dst_offset)
4899 KOKKOS_INLINE_FUNCTION
4900 void operator () (
const LocalOrdinal row)
const {
4901 scalar_index_type srcPos = src_offset_(row);
4902 const scalar_index_type dstEnd = dst_offset_(row+1);
4903 scalar_index_type dstPos = dst_offset_(row);
4904 for ( ; dstPos < dstEnd; ++dstPos, ++srcPos) {
4905 dst_(dstPos) = src_(srcPos);
4919 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
4920 Teuchos::RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
4922 size_t maxNumEntriesPerRow = 0,
4923 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
4926 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE;
4927 return Teuchos::rcp (
new matrix_type (map, maxNumEntriesPerRow, pftype, params));
4930 template<
class CrsMatrixType>
4931 Teuchos::RCP<CrsMatrixType>
4933 const Import<
typename CrsMatrixType::local_ordinal_type,
4934 typename CrsMatrixType::global_ordinal_type,
4935 typename CrsMatrixType::node_type>& importer,
4936 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4937 typename CrsMatrixType::global_ordinal_type,
4938 typename CrsMatrixType::node_type> >& domainMap,
4939 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4940 typename CrsMatrixType::global_ordinal_type,
4941 typename CrsMatrixType::node_type> >& rangeMap,
4942 const Teuchos::RCP<Teuchos::ParameterList>& params)
4944 Teuchos::RCP<CrsMatrixType> destMatrix;
4945 sourceMatrix->importAndFillComplete (destMatrix, importer, domainMap, rangeMap, params);
4949 template<
class CrsMatrixType>
4950 Teuchos::RCP<CrsMatrixType>
4952 const Import<
typename CrsMatrixType::local_ordinal_type,
4953 typename CrsMatrixType::global_ordinal_type,
4954 typename CrsMatrixType::node_type>& rowImporter,
4955 const Import<
typename CrsMatrixType::local_ordinal_type,
4956 typename CrsMatrixType::global_ordinal_type,
4957 typename CrsMatrixType::node_type>& domainImporter,
4958 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4959 typename CrsMatrixType::global_ordinal_type,
4960 typename CrsMatrixType::node_type> >& domainMap,
4961 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4962 typename CrsMatrixType::global_ordinal_type,
4963 typename CrsMatrixType::node_type> >& rangeMap,
4964 const Teuchos::RCP<Teuchos::ParameterList>& params)
4966 Teuchos::RCP<CrsMatrixType> destMatrix;
4967 sourceMatrix->importAndFillComplete (destMatrix, rowImporter, domainImporter, domainMap, rangeMap, params);
4971 template<
class CrsMatrixType>
4972 Teuchos::RCP<CrsMatrixType>
4974 const Export<
typename CrsMatrixType::local_ordinal_type,
4975 typename CrsMatrixType::global_ordinal_type,
4976 typename CrsMatrixType::node_type>& exporter,
4977 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4978 typename CrsMatrixType::global_ordinal_type,
4979 typename CrsMatrixType::node_type> >& domainMap,
4980 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4981 typename CrsMatrixType::global_ordinal_type,
4982 typename CrsMatrixType::node_type> >& rangeMap,
4983 const Teuchos::RCP<Teuchos::ParameterList>& params)
4985 Teuchos::RCP<CrsMatrixType> destMatrix;
4986 sourceMatrix->exportAndFillComplete (destMatrix, exporter, domainMap, rangeMap, params);
4990 template<
class CrsMatrixType>
4991 Teuchos::RCP<CrsMatrixType>
4993 const Export<
typename CrsMatrixType::local_ordinal_type,
4994 typename CrsMatrixType::global_ordinal_type,
4995 typename CrsMatrixType::node_type>& rowExporter,
4996 const Export<
typename CrsMatrixType::local_ordinal_type,
4997 typename CrsMatrixType::global_ordinal_type,
4998 typename CrsMatrixType::node_type>& domainExporter,
4999 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
5000 typename CrsMatrixType::global_ordinal_type,
5001 typename CrsMatrixType::node_type> >& domainMap,
5002 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
5003 typename CrsMatrixType::global_ordinal_type,
5004 typename CrsMatrixType::node_type> >& rangeMap,
5005 const Teuchos::RCP<Teuchos::ParameterList>& params)
5007 Teuchos::RCP<CrsMatrixType> destMatrix;
5008 sourceMatrix->exportAndFillComplete (destMatrix, rowExporter, domainExporter, domainMap, rangeMap, params);
5020 #endif // TPETRA_CRSMATRIX_DECL_HPP
CrsMatrix & operator=(const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &)=default
Copy assignment.
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
bool hasColMap() const override
Whether the matrix has a well-defined column Map.
global_size_t getGlobalNumCols() const override
The number of global columns in the matrix.
void checkInternalState() const
Check that this object's state is sane; throw if it's not.
Abstract interface for local operators (e.g., matrices and preconditioners).
Sparse matrix that presents a row-oriented interface that lets users read or modify entries...
size_t getNodeNumCols() const override
The number of columns connected to the locally owned rows of this matrix.
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().
CrsGraph< LocalOrdinal, GlobalOrdinal, Node > crs_graph_type
The CrsGraph specialization suitable for this CrsMatrix specialization.
void replaceColMap(const Teuchos::RCP< const map_type > &newColMap)
Replace the matrix's column Map with the given Map.
virtual bool supportsRowViews() const override
Return true if getLocalRowView() and getGlobalRowView() are valid for this object.
LocalOrdinal getViewRaw(impl_scalar_type *&vals, LocalOrdinal &numEnt, const RowInfo &rowinfo) const
Nonconst pointer to all entries (including extra space) in the given row.
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.
std::enable_if<!std::is_same< OutputScalarType, impl_scalar_type >::value &&std::is_convertible< impl_scalar_type, OutputScalarType >::value, LocalOrdinal >::type getLocalRowView(const LocalOrdinal lclRow, LocalOrdinal &numEnt, const OutputScalarType *&val, const LocalOrdinal *&ind) const
Get a constant, nonpersisting view of a row of this matrix, using local row and column indices...
LocalOrdinal replaceLocalValues(const LocalOrdinal localRow, const typename UnmanagedView< LocalIndicesViewType >::type &inputInds, const typename UnmanagedView< ImplScalarViewType >::type &inputVals) const
Replace one or more entries' values, using local row and column indices.
Teuchos::RCP< const map_type > getRangeMap() const override
The range Map of this matrix.
global_size_t getGlobalNumRows() const override
Number of global elements in the row map of this matrix.
std::map< GlobalOrdinal, std::pair< Teuchos::Array< GlobalOrdinal >, Teuchos::Array< Scalar > > > nonlocals_
Nonlocal data added using insertGlobalValues().
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...
typename device_type::execution_space execution_space
The Kokkos execution space.
void getLocalRowCopy(LocalOrdinal localRow, const Teuchos::ArrayView< LocalOrdinal > &colInds, const Teuchos::ArrayView< Scalar > &vals, size_t &numEntries) const override
Fill given arrays with a deep copy of the locally owned entries of the matrix in a given row...
typename Kokkos::ArithTraits< impl_scalar_type >::mag_type mag_type
Type of a norm result.
size_t getNumVectors() const
Number of columns in the multivector.
size_t getLocalLength() const
Local number of rows on the calling process.
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to alpha.
One or more distributed dense vectors.
size_t getNodeNumEntries() const override
The local number of entries in this matrix.
void scale(const Scalar &alpha)
Scale the matrix's values: this := alpha*this.
size_t getNodeNumRows() const override
The number of matrix rows owned by the calling process.
void fillLocalGraphAndMatrix(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Fill data into the local graph and matrix.
void resumeFill(const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Resume operations that may change the values or structure of the matrix.
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x) override
Scale the matrix on the left with the given Vector.
GlobalOrdinal global_ordinal_type
The type of each global index in the matrix.
Declaration and generic definition of traits class that tells Tpetra::CrsMatrix how to pack and unpac...
virtual ~CrsMatrix()=default
Destructor (virtual for memory safety of derived classes).
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, Distributor &distor, const CombineMode CM) override
Unpack the imported column indices and values, and combine into matrix.
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...
Import< LocalOrdinal, GlobalOrdinal, Node > import_type
The Import specialization suitable for this CrsMatrix specialization.
void getGlobalRowCopy(GlobalOrdinal GlobalRow, const Teuchos::ArrayView< GlobalOrdinal > &Indices, const Teuchos::ArrayView< Scalar > &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< const crs_graph_type > getCrsGraph() const
This matrix's graph, as a CrsGraph.
size_t getGlobalMaxNumRowEntries() const override
Maximum number of entries in any row of the matrix, over all processes in the matrix's communicator...
void applyNonTranspose(const MV &X_in, MV &Y_in, Scalar alpha, Scalar beta) const
Special case of apply() for mode == Teuchos::NO_TRANS.
Teuchos::RCP< CrsMatrix< T, LocalOrdinal, GlobalOrdinal, Node > > convert() const
Return another CrsMatrix with the same entries, but converted to a different Scalar type T...
Scalar scalar_type
The type of each entry in the matrix.
Allocation information for a locally owned row in a CrsGraph or CrsMatrix.
LocalOrdinal sumIntoLocalValues(const LocalOrdinal localRow, const typename UnmanagedView< LocalIndicesViewType >::type &inputInds, const typename UnmanagedView< ImplScalarViewType >::type &inputVals, const bool atomic=useAtomicUpdatesByDefault) const
Sum into one or more sparse matrix entries, using local row and column indices.
void swap(CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &matrix)
Swaps the data from *this with the data and maps from crsMatrix.
void fillLocalMatrix(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Fill data into the local matrix.
void globalAssemble()
Communicate nonlocal contributions to other processes.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const override
Get a copy of the diagonal entries of the matrix.
std::shared_ptr< local_multiply_op_type > lclMatrix_
The local sparse matrix, wrapped in a multiply operator.
void gaussSeidel(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &D, const Scalar &dampingFactor, const ESweepDirection direction, const int numSweeps) const
"Hybrid" Jacobi + (Gauss-Seidel or SOR) on .
Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > createCrsMatrix(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t maxNumEntriesPerRow=0, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Non-member function to create an empty CrsMatrix given a row map and a non-zero profile.
bool isFillActive() const
Whether the matrix is not fill complete.
Teuchos::RCP< MV > importMV_
Column Map MultiVector used in apply() and gaussSeidel().
typename Kokkos::ArithTraits< Scalar >::val_type impl_scalar_type
The type used internally in place of Scalar.
bool isStaticGraph() const
Indicates that the graph is static, so that new entries cannot be added to this matrix.
size_t global_size_t
Global size_t object.
bool hasTransposeApply() const override
Whether apply() allows applying the transpose or conjugate transpose.
void clearGlobalConstants()
Clear matrix properties that require collectives.
void gaussSeidelCopy(MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &D, const Scalar &dampingFactor, const ESweepDirection direction, const int numSweeps, const bool zeroInitialGuess) const
Version of gaussSeidel(), with fewer requirements on X.
LocalOrdinal getLocalRowViewRaw(const LocalOrdinal lclRow, LocalOrdinal &numEnt, const LocalOrdinal *&lclColInds, const Scalar *&vals) const override
Get a constant, nonpersisting, locally indexed view of the given row of the matrix, using "raw" pointers instead of Teuchos::ArrayView.
LocalOrdinal transformLocalValues(const LocalOrdinal lclRow, const typename UnmanagedView< LocalIndicesViewType >::type &inputInds, const typename UnmanagedView< ImplScalarViewType >::type &inputVals, BinaryFunction f, const bool atomic=useAtomicUpdatesByDefault) const
Transform CrsMatrix entries in place, using local indices to select the entries in the row to transfo...
void allocateValues(ELocalGlobal lg, GraphAllocationStatus gas)
Allocate values (and optionally indices) using the Node.
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.
bool isFillComplete() const override
Whether the matrix is fill complete.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const override
The communicator over which the matrix is distributed.
void sync_host()
Synchronize to Host.
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.
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, Distributor &dist) const
Pack this object's data for an Import or Export.
void reorderedGaussSeidelCopy(MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &D, const Teuchos::ArrayView< LocalOrdinal > &rowIndices, const Scalar &dampingFactor, const ESweepDirection direction, const int numSweeps, const bool zeroInitialGuess) const
Version of reorderedGaussSeidel(), with fewer requirements on X.
ESweepDirection
Sweep direction for Gauss-Seidel or Successive Over-Relaxation (SOR).
GlobalOrdinal getIndexBase() const override
The index base for global indices for this matrix.
Communication plan for data redistribution from a (possibly) multiply-owned to a uniquely-owned distr...
typename crs_graph_type::local_graph_type local_graph_type
The part of the sparse matrix's graph on each MPI process.
Kokkos::StaticCrsGraph< local_ordinal_type, Kokkos::LayoutLeft, execution_space > local_graph_type
The type of the part of the sparse graph on each MPI process.
Node node_type
This class' Kokkos Node type.
Teuchos::RCP< MV > getColumnMapMultiVector(const MV &X_domainMap, const bool force=false) const
Create a (or fetch a cached) column Map MultiVector.
Sets up and executes a communication plan for a Tpetra DistObject.
mag_type frobNorm_
Cached Frobenius norm of the (global) matrix.
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.
Teuchos::RCP< const RowGraph< LocalOrdinal, GlobalOrdinal, Node > > getGraph() const override
This matrix's graph, as a RowGraph.
CombineMode
Rule for combining data in an Import or Export.
DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node >::buffer_device_type buffer_device_type
Kokkos::Device specialization for communication buffers.
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
CrsGraphType::global_ordinal_type getGlobalNumDiags(const CrsGraphType &G)
Number of populated diagonal entries in the given sparse graph, over all processes in the graph's (MP...
bool isGloballyIndexed() const override
Whether the matrix is globally indexed on the calling process.
Forward declaration of Tpetra::CrsMatrix.
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 localGaussSeidel(const MultiVector< DomainScalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< RangeScalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &D, const RangeScalar &dampingFactor, const ESweepDirection direction) const
Gauss-Seidel or SOR on .
bool fillComplete_
Whether the matrix is fill complete.
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.
Abstract base class for objects that can be the source of an Import or Export operation.
typename Node::device_type device_type
The Kokkos device type.
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< MV > getRowMapMultiVector(const MV &Y_rangeMap, const bool force=false) const
Create a (or fetch a cached) row Map MultiVector.
std::string description() const override
A one-line description of this object.
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) const
Get offsets of the diagonal entries in the matrix.
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.
void computeGlobalConstants()
Compute matrix properties that require collectives.
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...
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 modify_host()
Mark data as modified on the host side.
local_matrix_type::values_type getLocalValuesView() const
Get the Kokkos local values.
ProfileType getProfileType() const
Returns true if the matrix was allocated with static data structures.
void getGlobalRowView(GlobalOrdinal GlobalRow, Teuchos::ArrayView< const GlobalOrdinal > &indices, Teuchos::ArrayView< const Scalar > &values) const override
Get a constant, nonpersisting view of a row of this matrix, using global row and column indices...
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) const
Transform CrsMatrix entries in place, using global indices to select the entries in the row to transf...
virtual void removeEmptyProcessesInPlace(const Teuchos::RCP< const map_type > &newMap) override
Remove processes owning zero rows from the Maps and their communicator.
virtual bool checkSizes(const SrcDistObject &source) override
Compare the source and target (this) objects for compatibility.
void insertLocalValues(const LocalOrdinal localRow, const Teuchos::ArrayView< const LocalOrdinal > &cols, const Teuchos::ArrayView< const Scalar > &vals)
Insert one or more entries into the matrix, using local column indices.
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
A parallel distribution of indices over processes.
Teuchos::RCP< const map_type > getDomainMap() const override
The domain Map of this matrix.
Teuchos::ArrayView< const impl_scalar_type > getView(RowInfo rowinfo) const
Constant view of all entries (including extra space) in the given row.
KokkosSparse::CrsMatrix< impl_scalar_type, local_ordinal_type, execution_space, void, typename local_graph_type::size_type > local_matrix_type
The specialization of Kokkos::CrsMatrix that represents the part of the sparse matrix on each MPI pro...
void setAllValues(const typename local_matrix_type::row_map_type &ptr, const typename local_graph_type::entries_type::non_const_type &ind, const typename local_matrix_type::values_type &val)
Set the local matrix using three (compressed sparse row) arrays.
A read-only, row-oriented interface to a sparse matrix.
local_matrix_type getLocalMatrix() const
The local sparse matrix.
void getLocalRowView(LocalOrdinal LocalRow, Teuchos::ArrayView< const LocalOrdinal > &indices, Teuchos::ArrayView< const Scalar > &values) const override
Get a constant, nonpersisting view of a row of this matrix, using local row and column indices...
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x) override
Scale the matrix on the right with the given Vector.
size_t getNodeMaxNumRowEntries() const override
Maximum number of entries in any row of the matrix, on this process.
A distributed dense vector.
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().
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.
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.
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const override
Number of entries in the sparse matrix in the given global row, on the calling (MPI) process...
size_t mergeRowIndicesAndValues(crs_graph_type &graph, const RowInfo &rowInfo)
Merge duplicate row indices in the given row, along with their corresponding values.
LocalOrdinal replaceGlobalValues(const GlobalOrdinal globalRow, const typename UnmanagedView< GlobalIndicesViewType >::type &inputInds, const typename UnmanagedView< ImplScalarViewType >::type &inputVals) const
Replace one or more entries' values, using global indices.
bool isLocallyIndexed() const override
Whether the matrix is locally indexed on the calling process.
Teuchos::RCP< const map_type > getColMap() const override
The Map that describes the column distribution in this matrix.
void reorderedGaussSeidel(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &D, const Teuchos::ArrayView< LocalOrdinal > &rowIndices, const Scalar &dampingFactor, const ESweepDirection direction, const int numSweeps) const
Reordered "Hybrid" Jacobi + (Gauss-Seidel or SOR) on .
Teuchos::ArrayView< impl_scalar_type > getViewNonConst(const RowInfo &rowinfo) const
Nonconst view of all entries (including extra space) in the given row.
Base class for distributed Tpetra objects that support data redistribution.
LocalOrdinal local_ordinal_type
The type of each local index in the matrix.
EStorageStatus
Status of the graph's or matrix's storage, when not in a fill-complete state.
mag_type getFrobeniusNorm() const override
Compute and return the Frobenius norm of the matrix.
::Tpetra::Details::EStorageStatus storageStatus_
Status of the matrix's storage, when not in a fill-complete state.
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 reorderedLocalGaussSeidel(const MultiVector< DomainScalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< RangeScalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &D, const Teuchos::ArrayView< LocalOrdinal > &rowIndices, const RangeScalar &dampingFactor, const ESweepDirection direction) const
Reordered Gauss-Seidel or SOR on .
LocalOrdinal getViewRawConst(const impl_scalar_type *&vals, LocalOrdinal &numEnt, const RowInfo &rowinfo) const
Const pointer to all entries (including extra space) in the given row.
bool isStorageOptimized() const
Returns true if storage has been optimized.
Export< LocalOrdinal, GlobalOrdinal, Node > export_type
The Export specialization suitable for this CrsMatrix specialization.
Teuchos::RCP< MV > exportMV_
Row Map MultiVector used in apply().
Teuchos::RCP< const map_type > getRowMap() const override
The Map that describes the row distribution in this matrix.
global_size_t getGlobalNumEntries() const override
The global number of entries in this matrix.