42 #ifndef TPETRA_CRSMATRIX_DECL_HPP
43 #define TPETRA_CRSMATRIX_DECL_HPP
54 #include "Tpetra_RowMatrix_decl.hpp"
55 #include "Tpetra_Exceptions.hpp"
56 #include "Tpetra_DistObject.hpp"
57 #include "Tpetra_CrsGraph.hpp"
58 #include "Tpetra_Vector.hpp"
64 #include "KokkosSparse.hpp"
69 #include "KokkosSparse_sor_sequential_impl.hpp"
74 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
class crsMatrix_Swap_Tester;
127 template<
class CrsMatrixType>
128 Teuchos::RCP<CrsMatrixType>
130 const Import<
typename CrsMatrixType::local_ordinal_type,
131 typename CrsMatrixType::global_ordinal_type,
132 typename CrsMatrixType::node_type>& importer,
133 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
134 typename CrsMatrixType::global_ordinal_type,
135 typename CrsMatrixType::node_type> >& domainMap = Teuchos::null,
136 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
137 typename CrsMatrixType::global_ordinal_type,
138 typename CrsMatrixType::node_type> >& rangeMap = Teuchos::null,
139 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
194 template<
class CrsMatrixType>
195 Teuchos::RCP<CrsMatrixType>
197 const Import<
typename CrsMatrixType::local_ordinal_type,
198 typename CrsMatrixType::global_ordinal_type,
199 typename CrsMatrixType::node_type>& rowImporter,
200 const Import<
typename CrsMatrixType::local_ordinal_type,
201 typename CrsMatrixType::global_ordinal_type,
202 typename CrsMatrixType::node_type>& domainImporter,
203 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
204 typename CrsMatrixType::global_ordinal_type,
205 typename CrsMatrixType::node_type> >& domainMap,
206 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
207 typename CrsMatrixType::global_ordinal_type,
208 typename CrsMatrixType::node_type> >& rangeMap,
209 const Teuchos::RCP<Teuchos::ParameterList>& params);
244 template<
class CrsMatrixType>
245 Teuchos::RCP<CrsMatrixType>
247 const Export<
typename CrsMatrixType::local_ordinal_type,
248 typename CrsMatrixType::global_ordinal_type,
249 typename CrsMatrixType::node_type>& exporter,
250 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
251 typename CrsMatrixType::global_ordinal_type,
252 typename CrsMatrixType::node_type> >& domainMap = Teuchos::null,
253 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
254 typename CrsMatrixType::global_ordinal_type,
255 typename CrsMatrixType::node_type> >& rangeMap = Teuchos::null,
256 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
291 template<
class CrsMatrixType>
292 Teuchos::RCP<CrsMatrixType>
294 const Export<
typename CrsMatrixType::local_ordinal_type,
295 typename CrsMatrixType::global_ordinal_type,
296 typename CrsMatrixType::node_type>& rowExporter,
297 const Export<
typename CrsMatrixType::local_ordinal_type,
298 typename CrsMatrixType::global_ordinal_type,
299 typename CrsMatrixType::node_type>& domainExporter,
300 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
301 typename CrsMatrixType::global_ordinal_type,
302 typename CrsMatrixType::node_type> >& domainMap,
303 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
304 typename CrsMatrixType::global_ordinal_type,
305 typename CrsMatrixType::node_type> >& rangeMap,
306 const Teuchos::RCP<Teuchos::ParameterList>& params);
421 template <
class Scalar,
426 public RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>,
427 public DistObject<char, LocalOrdinal, GlobalOrdinal, Node>
428 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
429 ,
public ::Tpetra::Details::HasDeprecatedMethods2630_WarningThisClassIsNotForUsers
430 #endif // TPETRA_ENABLE_DEPRECATED_CODE
468 using mag_type =
typename Kokkos::ArithTraits<impl_scalar_type>::mag_type;
492 typename local_graph_type::size_type>;
494 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
495 typedef typename local_matrix_type::row_map_type t_RowPtrs TPETRA_DEPRECATED;
498 typedef typename local_matrix_type::row_map_type::non_const_type t_RowPtrsNC TPETRA_DEPRECATED;
500 typedef typename local_graph_type::entries_type::non_const_type t_LocalOrdinal_1D TPETRA_DEPRECATED;
502 typedef typename local_matrix_type::values_type t_ValuesType TPETRA_DEPRECATED;
505 #endif // TPETRA_ENABLE_DEPRECATED_CODE
528 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
529 const size_t maxNumEntriesPerRow,
530 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
531 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
550 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
551 const Teuchos::ArrayView<const size_t>& numEntPerRowToAlloc,
552 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
553 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
555 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
558 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
559 const Teuchos::ArrayRCP<const size_t>& numEntPerRowToAlloc,
561 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
562 #endif // TPETRA_ENABLE_DEPRECATED_CODE
586 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
587 const Teuchos::RCP<const map_type>& colMap,
588 const size_t maxNumEntPerRow,
589 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
590 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
614 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
615 const Teuchos::RCP<const map_type>& colMap,
616 const Teuchos::ArrayView<const size_t>& numEntPerRowToAlloc,
617 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
618 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
620 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
623 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
624 const Teuchos::RCP<const map_type>& colMap,
625 const Teuchos::ArrayRCP<const size_t>& numEntPerRowToAlloc,
627 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
628 #endif // TPETRA_ENABLE_DEPRECATED_CODE
654 explicit CrsMatrix (
const Teuchos::RCP<const crs_graph_type>& graph,
655 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
685 explicit CrsMatrix (
const Teuchos::RCP<const crs_graph_type>& graph,
686 const typename local_matrix_type::values_type& values,
687 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
712 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
713 const Teuchos::RCP<const map_type>& colMap,
714 const typename local_matrix_type::row_map_type& rowPointers,
715 const typename local_graph_type::entries_type::non_const_type& columnIndices,
716 const typename local_matrix_type::values_type& values,
717 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
742 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
743 const Teuchos::RCP<const map_type>& colMap,
744 const Teuchos::ArrayRCP<size_t>& rowPointers,
745 const Teuchos::ArrayRCP<LocalOrdinal>& columnIndices,
746 const Teuchos::ArrayRCP<Scalar>& values,
747 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
769 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
770 const Teuchos::RCP<const map_type>& colMap,
772 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
801 const Teuchos::RCP<const map_type>& rowMap,
802 const Teuchos::RCP<const map_type>& colMap,
803 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
804 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
805 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
812 const Teuchos::DataAccess copyOrView);
815 template <
class S2,
class LO2,
class GO2,
class N2>
818 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
819 template <
class Node2>
844 Teuchos::RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node2> > TPETRA_DEPRECATED
845 clone (
const Teuchos::RCP<Node2>& node2,
846 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const
848 using Teuchos::Array;
849 using Teuchos::ArrayRCP;
850 using Teuchos::ArrayView;
852 using Teuchos::ParameterList;
855 using Teuchos::sublist;
858 const char tfecfFuncName[] =
"clone";
861 bool fillCompleteClone =
true;
862 bool useLocalIndices = this->
hasColMap ();
864 if (! params.is_null ()) {
865 fillCompleteClone = params->get (
"fillComplete clone", fillCompleteClone);
866 useLocalIndices = params->get (
"Locally indexed clone", useLocalIndices);
868 bool staticProfileClone =
true;
869 staticProfileClone = params->get (
"Static profile clone", staticProfileClone);
870 pftype = staticProfileClone ? StaticProfile : DynamicProfile;
873 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
874 ! this->
hasColMap () && useLocalIndices, std::runtime_error,
875 ": You requested that the returned clone have local indices, but the "
876 "the source matrix does not have a column Map yet.");
878 RCP<const Map2> clonedRowMap = this->
getRowMap ()->template clone<Node2> (node2);
881 RCP<CrsMatrix2> clonedMatrix;
882 ArrayRCP<const size_t> numEntriesPerRow;
883 size_t numEntriesForAll = 0;
884 bool boundSameForAllLocalRows =
false;
885 staticGraph_->getNumEntriesPerLocalRowUpperBound (numEntriesPerRow,
887 boundSameForAllLocalRows);
888 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
889 numEntriesForAll != 0 &&
890 static_cast<size_t> (numEntriesPerRow.size ()) != 0,
891 std::logic_error,
": getNumEntriesPerLocalRowUpperBound returned a "
892 "nonzero numEntriesForAll = " << numEntriesForAll <<
" , as well as a "
893 "numEntriesPerRow array of nonzero length " << numEntriesPerRow.size ()
894 <<
". This should never happen. Please report this bug to the Tpetra "
896 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
897 numEntriesForAll != 0 && ! boundSameForAllLocalRows,
898 std::logic_error,
": getNumEntriesPerLocalRowUpperBound returned a "
899 "nonzero numEntriesForAll = " << numEntriesForAll <<
" , but claims "
900 "(via its third output value) that the upper bound is not the same for "
901 "all rows. This should never happen. Please report this bug to the "
902 "Tpetra developers.");
903 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
904 numEntriesPerRow.size () != 0 && boundSameForAllLocalRows,
905 std::logic_error,
": getNumEntriesPerLocalRowUpperBound returned a "
906 "numEntriesPerRow array of nonzero length " << numEntriesPerRow.size ()
907 <<
", but claims (via its third output value) that the upper bound is "
908 "not the same for all rows. This should never happen. Please report "
909 "this bug to the Tpetra developers.");
911 RCP<ParameterList> matParams =
912 params.is_null () ? null : sublist (params,
"CrsMatrix");
913 if (useLocalIndices) {
914 RCP<const Map2> clonedColMap =
915 this->
getColMap ()->template clone<Node2> (node2);
916 if (numEntriesPerRow.is_null ()) {
917 clonedMatrix = rcp (
new CrsMatrix2 (clonedRowMap, clonedColMap,
918 numEntriesForAll, pftype,
922 clonedMatrix = rcp (
new CrsMatrix2 (clonedRowMap, clonedColMap,
923 numEntriesPerRow (), pftype,
928 if (numEntriesPerRow.is_null ()) {
929 clonedMatrix = rcp (
new CrsMatrix2 (clonedRowMap, numEntriesForAll,
933 clonedMatrix = rcp (
new CrsMatrix2 (clonedRowMap,
939 numEntriesPerRow = Teuchos::null;
940 numEntriesForAll = 0;
942 if (useLocalIndices) {
943 clonedMatrix->allocateValues (LocalIndices,
944 CrsMatrix2::GraphNotYetAllocated);
946 ArrayView<const LocalOrdinal> linds;
947 ArrayView<const Scalar> vals;
948 for (LocalOrdinal lrow = clonedRowMap->getMinLocalIndex ();
949 lrow <= clonedRowMap->getMaxLocalIndex ();
953 clonedMatrix->insertLocalValues (lrow, linds, vals);
958 Array<LocalOrdinal> linds;
960 for (LocalOrdinal lrow = clonedRowMap->getMinLocalIndex ();
961 lrow <= clonedRowMap->getMaxLocalIndex ();
964 if (theNumEntries > static_cast<size_t> (linds.size ())) {
965 linds.resize (theNumEntries);
967 if (theNumEntries > static_cast<size_t> (vals.size ())) {
968 vals.resize (theNumEntries);
971 linds (), vals (), theNumEntries);
972 if (theNumEntries != 0) {
973 clonedMatrix->insertLocalValues (lrow, linds (0, theNumEntries),
974 vals (0, theNumEntries));
980 clonedMatrix->allocateValues (GlobalIndices,
981 CrsMatrix2::GraphNotYetAllocated);
983 ArrayView<const GlobalOrdinal> ginds;
984 ArrayView<const Scalar> vals;
985 for (GlobalOrdinal grow = clonedRowMap->getMinGlobalIndex ();
986 grow <= clonedRowMap->getMaxGlobalIndex ();
989 if (ginds.size () > 0) {
990 clonedMatrix->insertGlobalValues (grow, ginds, vals);
995 Array<GlobalOrdinal> ginds;
997 for (GlobalOrdinal grow = clonedRowMap->getMinGlobalIndex ();
998 grow <= clonedRowMap->getMaxGlobalIndex ();
1001 if (theNumEntries > static_cast<size_t> (ginds.size ())) {
1002 ginds.resize (theNumEntries);
1004 if (theNumEntries > static_cast<size_t> (vals.size ())) {
1005 vals.resize (theNumEntries);
1008 if (theNumEntries != 0) {
1009 clonedMatrix->insertGlobalValues (grow, ginds (0, theNumEntries),
1010 vals (0, theNumEntries));
1016 if (fillCompleteClone) {
1017 RCP<const Map2> clonedRangeMap;
1018 RCP<const Map2> clonedDomainMap;
1022 clonedRangeMap = this->
getRangeMap ()->template clone<Node2> (node2);
1025 clonedRangeMap = clonedRowMap;
1029 clonedDomainMap = this->
getDomainMap ()->template clone<Node2> (node2);
1032 clonedDomainMap = clonedRowMap;
1035 catch (std::exception &e) {
1036 const bool caughtExceptionOnClone =
true;
1037 TEUCHOS_TEST_FOR_EXCEPTION
1038 (caughtExceptionOnClone, std::runtime_error,
1039 Teuchos::typeName (*
this) <<
"::clone: Caught the following "
1040 "exception while cloning range and domain Maps on a clone of "
1041 "type " << Teuchos::typeName (*clonedMatrix) <<
": " << e.what ());
1044 RCP<ParameterList> fillparams =
1045 params.is_null () ? Teuchos::null : sublist (params,
"fillComplete");
1047 clonedMatrix->fillComplete (clonedDomainMap, clonedRangeMap,
1050 catch (std::exception &e) {
1051 const bool caughtExceptionOnClone =
true;
1052 TEUCHOS_TEST_FOR_EXCEPTION(
1053 caughtExceptionOnClone, std::runtime_error,
1054 Teuchos::typeName (*
this) <<
"::clone: Caught the following "
1055 "exception while calling fillComplete() on a clone of type "
1056 << Teuchos::typeName (*clonedMatrix) <<
": " << e.what ());
1059 return clonedMatrix;
1071 CrsMatrix (
const CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>&) =
delete;
1080 CrsMatrix (CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>&&) =
delete;
1091 operator= (
const CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>&) =
delete;
1101 operator= (CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>&&) =
delete;
1190 const Teuchos::ArrayView<const GlobalOrdinal>& cols,
1191 const Teuchos::ArrayView<const Scalar>& vals);
1209 const LocalOrdinal numEnt,
1210 const Scalar vals[],
1211 const GlobalOrdinal inds[]);
1255 const Teuchos::ArrayView<const LocalOrdinal> &cols,
1256 const Teuchos::ArrayView<const Scalar> &vals);
1274 const LocalOrdinal numEnt,
1275 const Scalar vals[],
1276 const LocalOrdinal cols[]);
1292 const RowInfo& rowInfo,
1293 const GlobalOrdinal inds[],
1295 const LocalOrdinal numElts)
const;
1334 template<
class GlobalIndicesViewType,
1335 class ImplScalarViewType>
1338 const typename UnmanagedView<GlobalIndicesViewType>::type& inputInds,
1339 const typename UnmanagedView<ImplScalarViewType>::type& inputVals)
const
1347 static_assert (Kokkos::is_view<GlobalIndicesViewType>::value,
1348 "First template parameter GlobalIndicesViewType must be "
1350 static_assert (Kokkos::is_view<ImplScalarViewType>::value,
1351 "Second template parameter ImplScalarViewType must be a "
1353 static_assert (static_cast<int> (GlobalIndicesViewType::rank) == 1,
1354 "First template parameter GlobalIndicesViewType must "
1356 static_assert (static_cast<int> (ImplScalarViewType::rank) == 1,
1357 "Second template parameter ImplScalarViewType must have "
1359 static_assert (std::is_same<
1360 typename GlobalIndicesViewType::non_const_value_type,
1362 "First template parameter GlobalIndicesViewType must "
1363 "contain values of type global_ordinal_type.");
1364 static_assert (std::is_same<
1365 typename ImplScalarViewType::non_const_value_type,
1367 "Second template parameter ImplScalarViewType must "
1368 "contain values of type impl_scalar_type.");
1369 typedef LocalOrdinal LO;
1370 const LO numInputEnt = inputInds.extent (0);
1371 if (static_cast<LO> (inputVals.extent (0)) != numInputEnt) {
1372 return Teuchos::OrdinalTraits<LO>::invalid ();
1374 const Scalar*
const inVals =
1375 reinterpret_cast<const Scalar*
> (inputVals.data ());
1385 const Teuchos::ArrayView<const GlobalOrdinal>& cols,
1386 const Teuchos::ArrayView<const Scalar>& vals)
const;
1405 const LocalOrdinal numEnt,
1406 const Scalar vals[],
1407 const GlobalOrdinal cols[])
const;
1424 const LocalOrdinal inds[],
1426 const LocalOrdinal numElts)
const;
1464 template<
class LocalIndicesViewType,
1465 class ImplScalarViewType>
1468 const typename UnmanagedView<LocalIndicesViewType>::type& inputInds,
1469 const typename UnmanagedView<ImplScalarViewType>::type& inputVals)
const
1477 static_assert (Kokkos::is_view<LocalIndicesViewType>::value,
1478 "First template parameter LocalIndicesViewType must be "
1480 static_assert (Kokkos::is_view<ImplScalarViewType>::value,
1481 "Second template parameter ImplScalarViewType must be a "
1483 static_assert (static_cast<int> (LocalIndicesViewType::rank) == 1,
1484 "First template parameter LocalIndicesViewType must "
1486 static_assert (static_cast<int> (ImplScalarViewType::rank) == 1,
1487 "Second template parameter ImplScalarViewType must have "
1489 static_assert (std::is_same<
1490 typename LocalIndicesViewType::non_const_value_type,
1492 "First template parameter LocalIndicesViewType must "
1493 "contain values of type local_ordinal_type.");
1494 static_assert (std::is_same<
1495 typename ImplScalarViewType::non_const_value_type,
1497 "Second template parameter ImplScalarViewType must "
1498 "contain values of type impl_scalar_type.");
1500 typedef LocalOrdinal LO;
1501 const LO numInputEnt = inputInds.extent (0);
1502 if (numInputEnt != inputVals.extent (0)) {
1503 return Teuchos::OrdinalTraits<LO>::invalid ();
1505 const Scalar*
const inVals =
1506 reinterpret_cast<const Scalar*
> (inputVals.data ());
1508 inVals, inputInds.data ());
1516 const Teuchos::ArrayView<const LocalOrdinal>& cols,
1517 const Teuchos::ArrayView<const Scalar>& vals)
const;
1538 const LocalOrdinal numEnt,
1539 const Scalar inputVals[],
1540 const LocalOrdinal inputCols[])
const;
1547 static const bool useAtomicUpdatesByDefault =
1548 #ifdef KOKKOS_ENABLE_SERIAL
1549 ! std::is_same<execution_space, Kokkos::Serial>::value;
1552 #endif // KOKKOS_ENABLE_SERIAL
1581 const GlobalOrdinal inds[],
1583 const LocalOrdinal numElts,
1584 const bool atomic = useAtomicUpdatesByDefault)
const;
1625 const Teuchos::ArrayView<const GlobalOrdinal>& cols,
1626 const Teuchos::ArrayView<const Scalar>& vals,
1627 const bool atomic = useAtomicUpdatesByDefault);
1653 const LocalOrdinal numEnt,
1654 const Scalar vals[],
1655 const GlobalOrdinal cols[],
1656 const bool atomic = useAtomicUpdatesByDefault);
1675 const LocalOrdinal inds[],
1677 const LocalOrdinal numElts,
1678 const bool atomic = useAtomicUpdatesByDefault)
const;
1717 template<
class LocalIndicesViewType,
1718 class ImplScalarViewType>
1721 const typename UnmanagedView<LocalIndicesViewType>::type& inputInds,
1722 const typename UnmanagedView<ImplScalarViewType>::type& inputVals,
1723 const bool atomic = useAtomicUpdatesByDefault)
const
1731 static_assert (Kokkos::is_view<LocalIndicesViewType>::value,
1732 "First template parameter LocalIndicesViewType must be "
1734 static_assert (Kokkos::is_view<ImplScalarViewType>::value,
1735 "Second template parameter ImplScalarViewType must be a "
1737 static_assert (static_cast<int> (LocalIndicesViewType::rank) == 1,
1738 "First template parameter LocalIndicesViewType must "
1740 static_assert (static_cast<int> (ImplScalarViewType::rank) == 1,
1741 "Second template parameter ImplScalarViewType must have "
1743 static_assert (std::is_same<
1744 typename LocalIndicesViewType::non_const_value_type,
1746 "First template parameter LocalIndicesViewType must "
1747 "contain values of type local_ordinal_type.");
1748 static_assert (std::is_same<
1749 typename ImplScalarViewType::non_const_value_type,
1751 "Second template parameter ImplScalarViewType must "
1752 "contain values of type impl_scalar_type.");
1753 typedef LocalOrdinal LO;
1754 const LO numInputEnt = inputInds.extent (0);
1755 if (static_cast<LO> (inputVals.extent (0)) != numInputEnt) {
1756 return Teuchos::OrdinalTraits<LO>::invalid ();
1760 reinterpret_cast<const Scalar*> (inputVals.data ()),
1796 const Teuchos::ArrayView<const LocalOrdinal>& cols,
1797 const Teuchos::ArrayView<const Scalar>& vals,
1798 const bool atomic = useAtomicUpdatesByDefault)
const;
1823 const LocalOrdinal numEnt,
1824 const Scalar vals[],
1825 const LocalOrdinal cols[],
1826 const bool atomic = useAtomicUpdatesByDefault)
const;
1863 const LocalOrdinal inds[],
1865 const LocalOrdinal numElts,
1867 const bool atomic = useAtomicUpdatesByDefault)
const;
1903 const GlobalOrdinal inds[],
1905 const LocalOrdinal numElts,
1907 const bool atomic = useAtomicUpdatesByDefault)
const;
1936 transformLocalValues (
const LocalOrdinal lclRow,
1937 const LocalOrdinal numInputEnt,
1939 const LocalOrdinal inputCols[],
1941 const bool atomic = useAtomicUpdatesByDefault)
const;
1970 transformGlobalValues (
const GlobalOrdinal gblRow,
1971 const LocalOrdinal numInputEnt,
1973 const GlobalOrdinal inputCols[],
1975 const bool atomic = useAtomicUpdatesByDefault)
const;
2021 template<
class LocalIndicesViewType,
2022 class ImplScalarViewType,
2023 class BinaryFunction>
2026 const typename UnmanagedView<LocalIndicesViewType>::type& inputInds,
2027 const typename UnmanagedView<ImplScalarViewType>::type& inputVals,
2029 const bool atomic = useAtomicUpdatesByDefault)
const
2037 static_assert (Kokkos::is_view<LocalIndicesViewType>::value,
2038 "First template parameter LocalIndicesViewType must be "
2040 static_assert (Kokkos::is_view<ImplScalarViewType>::value,
2041 "Second template parameter ImplScalarViewType must be a "
2043 static_assert (static_cast<int> (LocalIndicesViewType::rank) == 1,
2044 "First template parameter LocalIndicesViewType must "
2046 static_assert (static_cast<int> (ImplScalarViewType::rank) == 1,
2047 "Second template parameter ImplScalarViewType must have "
2049 static_assert (std::is_same<
2050 typename LocalIndicesViewType::non_const_value_type,
2052 "First template parameter LocalIndicesViewType must "
2053 "contain values of type local_ordinal_type.");
2054 static_assert (std::is_same<
2055 typename ImplScalarViewType::non_const_value_type,
2057 "Second template parameter ImplScalarViewType must "
2058 "contain values of type impl_scalar_type.");
2059 typedef LocalOrdinal LO;
2060 const LO numInputEnt = inputInds.extent (0);
2061 if (static_cast<LO> (inputVals.extent (0)) != numInputEnt) {
2062 return Teuchos::OrdinalTraits<LO>::invalid ();
2064 return this->transformLocalValues (lclRow,
2113 template<
class BinaryFunction,
class InputMemorySpace>
2116 const Kokkos::View<
const GlobalOrdinal*,
2118 Kokkos::MemoryUnmanaged>& inputInds,
2121 Kokkos::MemoryUnmanaged>& inputVals,
2123 const bool atomic = useAtomicUpdatesByDefault)
const
2125 typedef LocalOrdinal LO;
2126 const LO numInputEnt = inputInds.extent (0);
2127 if (static_cast<LO> (inputVals.extent (0)) != numInputEnt) {
2128 return Teuchos::OrdinalTraits<LO>::invalid ();
2130 return this->transformGlobalValues (gblRow,
2142 void scale (
const Scalar& alpha);
2168 setAllValues (
const typename local_matrix_type::row_map_type& ptr,
2169 const typename local_graph_type::entries_type::non_const_type& ind,
2170 const typename local_matrix_type::values_type& val);
2197 const Teuchos::ArrayRCP<LocalOrdinal>& ind,
2198 const Teuchos::ArrayRCP<Scalar>& val);
2201 getAllValues (Teuchos::ArrayRCP<const size_t>& rowPointers,
2202 Teuchos::ArrayRCP<const LocalOrdinal>& columnIndices,
2203 Teuchos::ArrayRCP<const Scalar>& values)
const;
2252 void resumeFill (
const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
2312 fillComplete (
const Teuchos::RCP<const map_type>& domainMap,
2313 const Teuchos::RCP<const map_type>& rangeMap,
2314 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
2343 fillComplete (
const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
2373 const Teuchos::RCP<const map_type>& rangeMap,
2374 const Teuchos::RCP<const import_type>& importer = Teuchos::null,
2375 const Teuchos::RCP<const export_type>& exporter = Teuchos::null,
2376 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
2388 replaceColMap (
const Teuchos::RCP<const map_type>& newColMap);
2473 const Teuchos::RCP<const map_type>& newColMap,
2474 const Teuchos::RCP<const import_type>& newImport = Teuchos::null,
2475 const bool sortEachRow =
true);
2491 Teuchos::RCP<const import_type>& newImporter);
2514 Teuchos::RCP<const Teuchos::Comm<int> >
getComm()
const override;
2516 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
2517 TPETRA_DEPRECATED Teuchos::RCP<node_type> getNode ()
const override;
2519 #endif // TPETRA_ENABLE_DEPRECATED_CODE
2522 Teuchos::RCP<const map_type>
getRowMap ()
const override;
2525 Teuchos::RCP<const map_type>
getColMap ()
const override;
2528 Teuchos::RCP<const RowGraph<LocalOrdinal, GlobalOrdinal, Node> >
2532 Teuchos::RCP<const crs_graph_type>
getCrsGraph ()
const;
2646 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
2663 size_t TPETRA_DEPRECATED getNodeNumDiags ()
const override;
2689 size_t getNodeNumDiagsImpl ()
const override;
2701 bool TPETRA_DEPRECATED isLowerTriangular ()
const override;
2713 bool TPETRA_DEPRECATED isUpperTriangular ()
const override;
2726 bool isLowerTriangularImpl ()
const override;
2739 bool isUpperTriangularImpl ()
const override;
2740 #endif // TPETRA_ENABLE_DEPRECATED_CODE
2916 const Teuchos::ArrayView<GlobalOrdinal>& Indices,
2917 const Teuchos::ArrayView<Scalar>& Values,
2918 size_t& NumEntries)
const override;
2937 const Teuchos::ArrayView<LocalOrdinal>& colInds,
2938 const Teuchos::ArrayView<Scalar>& vals,
2939 size_t& numEntries)
const override;
2955 Teuchos::ArrayView<const GlobalOrdinal>& indices,
2956 Teuchos::ArrayView<const Scalar>& values)
const override;
2972 Teuchos::ArrayView<const LocalOrdinal>& indices,
2973 Teuchos::ArrayView<const Scalar>& values)
const override;
3001 LocalOrdinal& numEnt,
3002 const LocalOrdinal*& lclColInds,
3003 const Scalar*& vals)
const override;
3030 LocalOrdinal& numEnt,
3032 const LocalOrdinal*& ind)
const;
3041 template<
class OutputScalarType>
3042 typename std::enable_if<! std::is_same<OutputScalarType, impl_scalar_type>::value &&
3043 std::is_convertible<impl_scalar_type, OutputScalarType>::value,
3046 LocalOrdinal& numEnt,
3047 const OutputScalarType*& val,
3048 const LocalOrdinal*& ind)
const
3051 const LocalOrdinal err = this->
getLocalRowView (lclRow, numEnt, valTmp, ind);
3054 val =
reinterpret_cast<const OutputScalarType*
> (valTmp);
3136 Kokkos::MemoryUnmanaged>& offsets)
const;
3162 const Teuchos::ArrayView<const size_t>& offsets)
const;
3230 template <
class DomainScalar,
class RangeScalar>
3234 Teuchos::ETransp mode,
3236 RangeScalar beta)
const
3238 using Teuchos::NO_TRANS;
3242 typedef typename MultiVector<RangeScalar, LocalOrdinal, GlobalOrdinal,
3244 #ifdef HAVE_TPETRA_DEBUG
3245 const char tfecfFuncName[] =
"localMultiply: ";
3246 #endif // HAVE_TPETRA_DEBUG
3248 const range_impl_scalar_type theAlpha =
static_cast<range_impl_scalar_type
> (alpha);
3249 const range_impl_scalar_type theBeta =
static_cast<range_impl_scalar_type
> (beta);
3250 const bool conjugate = (mode == Teuchos::CONJ_TRANS);
3251 const bool transpose = (mode != Teuchos::NO_TRANS);
3252 auto X_lcl = X.template getLocalView<device_type> ();
3253 auto Y_lcl = Y.template getLocalView<device_type> ();
3255 #ifdef HAVE_TPETRA_DEBUG
3256 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
3258 "X.getNumVectors() = " << X.
getNumVectors () <<
" != Y.getNumVectors() = "
3260 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
3262 std::runtime_error,
"NO_TRANS case: X has the wrong number of local rows. "
3263 "X.getLocalLength() = " << X.
getLocalLength () <<
" != getColMap()->"
3264 "getNodeNumElements() = " <<
getColMap ()->getNodeNumElements () <<
".");
3265 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
3267 std::runtime_error,
"NO_TRANS case: Y has the wrong number of local rows. "
3268 "Y.getLocalLength() = " << Y.
getLocalLength () <<
" != getRowMap()->"
3269 "getNodeNumElements() = " <<
getRowMap ()->getNodeNumElements () <<
".");
3270 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
3272 std::runtime_error,
"TRANS or CONJ_TRANS case: X has the wrong number of "
3273 "local rows. X.getLocalLength() = " << X.
getLocalLength () <<
" != "
3274 "getRowMap()->getNodeNumElements() = "
3275 <<
getRowMap ()->getNodeNumElements () <<
".");
3276 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
3278 std::runtime_error,
"TRANS or CONJ_TRANS case: X has the wrong number of "
3279 "local rows. Y.getLocalLength() = " << Y.
getLocalLength () <<
" != "
3280 "getColMap()->getNodeNumElements() = "
3281 <<
getColMap ()->getNodeNumElements () <<
".");
3282 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
3283 (!
isFillComplete (), std::runtime_error,
"The matrix is not fill "
3284 "complete. You must call fillComplete() (possibly with domain and range "
3285 "Map arguments) without an intervening resumeFill() call before you may "
3286 "call this method.");
3287 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
3289 "X and Y must be constant stride.");
3292 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
3293 X_lcl.data () == Y_lcl.data () &&
3294 X_lcl.data () != NULL,
3295 std::runtime_error,
"X and Y may not alias one another.");
3296 #endif // HAVE_TPETRA_DEBUG
3300 KokkosSparse::spmv (conjugate ? KokkosSparse::ConjugateTranspose : KokkosSparse::Transpose,
3303 X.template getLocalView<device_type> (),
3305 Y.template getLocalView<device_type> ());
3308 KokkosSparse::spmv (KokkosSparse::NoTranspose,
3311 X.template getLocalView<device_type> (),
3313 Y.template getLocalView<device_type> ());
3351 const Teuchos::ETransp mode = Teuchos::NO_TRANS,
3352 const Scalar& alpha = Teuchos::ScalarTraits<Scalar>::one (),
3353 const Scalar& beta = Teuchos::ScalarTraits<Scalar>::zero ())
const;
3379 template <
class DomainScalar,
class RangeScalar>
3384 const RangeScalar& dampingFactor,
3387 typedef LocalOrdinal LO;
3388 typedef GlobalOrdinal GO;
3391 typedef typename Node::device_type::memory_space dev_mem_space;
3392 typedef typename MMV::dual_view_type::t_host::device_type host_mem_space;
3394 typedef typename k_local_graph_type::size_type offset_type;
3395 const char prefix[] =
"Tpetra::CrsMatrix::localGaussSeidel: ";
3397 TEUCHOS_TEST_FOR_EXCEPTION
3399 prefix <<
"The matrix is not fill complete.");
3402 TEUCHOS_TEST_FOR_EXCEPTION
3404 prefix <<
"B.getNumVectors() = " << numVecs <<
" != "
3406 TEUCHOS_TEST_FOR_EXCEPTION
3409 <<
" != this->getNodeNumRows() = " << lclNumRows <<
".");
3414 const_cast<DMV&
> (B).sync_host ();
3417 const_cast<MMV&
> (D).sync_host ();
3419 auto B_lcl = B.template getLocalView<host_mem_space> ();
3420 auto X_lcl = X.template getLocalView<host_mem_space> ();
3421 auto D_lcl = D.template getLocalView<host_mem_space> ();
3423 offset_type B_stride[8], X_stride[8], D_stride[8];
3424 B_lcl.stride (B_stride);
3425 X_lcl.stride (X_stride);
3426 D_lcl.stride (D_stride);
3429 k_local_graph_type lclGraph = lclMatrix.graph;
3430 typename local_matrix_type::row_map_type ptr = lclGraph.row_map;
3431 typename local_matrix_type::index_type ind = lclGraph.entries;
3432 typename local_matrix_type::values_type val = lclMatrix.values;
3433 const offset_type*
const ptrRaw = ptr.data ();
3434 const LO*
const indRaw = ind.data ();
3437 const std::string dir ((direction == Forward) ?
"F" :
"B");
3443 KokkosSparse::Impl::Sequential::gaussSeidel (static_cast<LO> (lclNumRows),
3444 static_cast<LO> (numVecs),
3445 ptrRaw, indRaw, valRaw,
3446 B_lcl.data (), B_stride[1],
3447 X_lcl.data (), X_stride[1],
3451 const_cast<DMV&
> (B).
template sync<dev_mem_space> ();
3452 X.template sync<dev_mem_space> ();
3453 const_cast<MMV&
> (D).
template sync<dev_mem_space> ();
3482 template <
class DomainScalar,
class RangeScalar>
3487 const Teuchos::ArrayView<LocalOrdinal>& rowIndices,
3488 const RangeScalar& dampingFactor,
3491 typedef LocalOrdinal LO;
3492 typedef GlobalOrdinal GO;
3495 typedef typename Node::device_type::memory_space dev_mem_space;
3496 typedef typename MMV::dual_view_type::t_host::device_type host_mem_space;
3498 typedef typename k_local_graph_type::size_type offset_type;
3499 const char prefix[] =
"Tpetra::CrsMatrix::reorderedLocalGaussSeidel: ";
3501 TEUCHOS_TEST_FOR_EXCEPTION
3503 prefix <<
"The matrix is not fill complete.");
3506 TEUCHOS_TEST_FOR_EXCEPTION
3508 prefix <<
"B.getNumVectors() = " << numVecs <<
" != "
3510 TEUCHOS_TEST_FOR_EXCEPTION
3513 <<
" != this->getNodeNumRows() = " << lclNumRows <<
".");
3514 TEUCHOS_TEST_FOR_EXCEPTION
3515 (static_cast<size_t> (rowIndices.size ()) < lclNumRows,
3516 std::invalid_argument, prefix <<
"rowIndices.size() = "
3517 << rowIndices.size () <<
" < this->getNodeNumRows() = "
3518 << lclNumRows <<
".");
3523 const_cast<DMV&
> (B).sync_host ();
3526 const_cast<MMV&
> (D).sync_host ();
3528 auto B_lcl = B.template getLocalView<host_mem_space> ();
3529 auto X_lcl = X.template getLocalView<host_mem_space> ();
3530 auto D_lcl = D.template getLocalView<host_mem_space> ();
3532 offset_type B_stride[8], X_stride[8], D_stride[8];
3533 B_lcl.stride (B_stride);
3534 X_lcl.stride (X_stride);
3535 D_lcl.stride (D_stride);
3539 typename local_matrix_type::index_type ind = lclGraph.entries;
3540 typename local_matrix_type::row_map_type ptr = lclGraph.row_map;
3541 typename local_matrix_type::values_type val = lclMatrix.values;
3542 const offset_type*
const ptrRaw = ptr.data ();
3543 const LO*
const indRaw = ind.data ();
3546 const std::string dir = (direction == Forward) ?
"F" :
"B";
3551 KokkosSparse::Impl::Sequential::reorderedGaussSeidel (static_cast<LO> (lclNumRows),
3552 static_cast<LO> (numVecs),
3553 ptrRaw, indRaw, valRaw,
3559 rowIndices.getRawPtr (),
3560 static_cast<LO
> (lclNumRows),
3561 static_cast<impl_scalar_type> (dampingFactor),
3563 const_cast<DMV&
> (B).
template sync<dev_mem_space> ();
3564 X.template sync<dev_mem_space> ();
3565 const_cast<MMV&
> (D).
template sync<dev_mem_space> ();
3571 Teuchos::RCP<CrsMatrix<T, LocalOrdinal, GlobalOrdinal, Node> >
3591 Teuchos::ETransp mode = Teuchos::NO_TRANS,
3592 Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
3593 Scalar beta = Teuchos::ScalarTraits<Scalar>::zero())
const override;
3605 Teuchos::RCP<const map_type>
getDomainMap ()
const override;
3613 Teuchos::RCP<const map_type>
getRangeMap ()
const override;
3687 const Scalar& dampingFactor,
3689 const int numSweeps)
const;
3761 const Teuchos::ArrayView<LocalOrdinal>& rowIndices,
3762 const Scalar& dampingFactor,
3764 const int numSweeps)
const;
3798 const Scalar& dampingFactor,
3800 const int numSweeps,
3801 const bool zeroInitialGuess)
const;
3836 const Teuchos::ArrayView<LocalOrdinal>& rowIndices,
3837 const Scalar& dampingFactor,
3839 const int numSweeps,
3840 const bool zeroInitialGuess)
const;
3852 virtual Teuchos::RCP<RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
3853 add (
const Scalar& alpha,
3858 const Teuchos::RCP<Teuchos::ParameterList>& params)
const override;
3870 describe (Teuchos::FancyOStream& out,
3871 const Teuchos::EVerbosityLevel verbLevel =
3872 Teuchos::Describable::verbLevel_default)
const override;
3882 typedef typename DistObject<Scalar, LocalOrdinal, GlobalOrdinal,
3891 const size_t numSameIDs,
3892 const LocalOrdinal permuteToLIDs[],
3893 const LocalOrdinal permuteFromLIDs[],
3894 const size_t numPermutes);
3897 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
3899 #else // TPETRA_ENABLE_DEPRECATED_CODE
3901 #endif // TPETRA_ENABLE_DEPRECATED_CODE
3903 const size_t numSameIDs,
3904 const Kokkos::DualView<
3907 const Kokkos::DualView<
3912 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
3914 #else // TPETRA_ENABLE_DEPRECATED_CODE
3916 #endif // TPETRA_ENABLE_DEPRECATED_CODE
3918 const Kokkos::DualView<
3921 Kokkos::DualView<char*, buffer_device_type>& exports,
3922 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
3923 size_t& constantNumPackets,
3932 const Kokkos::DualView<
const char*,
3934 const Kokkos::DualView<
const size_t*,
3936 const size_t constantNumPackets,
3939 const bool atomic = useAtomicUpdatesByDefault);
3946 const Kokkos::DualView<
const char*,
3948 const Kokkos::DualView<
const size_t*,
3950 const size_t constantNumPackets,
3965 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
3967 #else // TPETRA_ENABLE_DEPRECATED_CODE
3969 #endif // TPETRA_ENABLE_DEPRECATED_CODE
3970 (
const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& importLIDs,
3971 Kokkos::DualView<char*, buffer_device_type> imports,
3972 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
3973 const size_t constantNumPackets,
4085 packNew (
const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& exportLIDs,
4086 Kokkos::DualView<char*, buffer_device_type>& exports,
4087 const Kokkos::DualView<size_t*, buffer_device_type>& numPacketsPerLID,
4088 size_t& constantNumPackets,
4099 packNonStaticNew (
const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& exportLIDs,
4100 Kokkos::DualView<char*, buffer_device_type>& exports,
4101 const Kokkos::DualView<size_t*, buffer_device_type>& numPacketsPerLID,
4102 size_t& constantNumPackets,
4135 packRow (
char exports[],
4136 const size_t offset,
4137 const size_t numEnt,
4138 const GlobalOrdinal gidsIn[],
4140 const size_t numBytesPerValue)
const;
4166 packRowStatic (
char*
const numEntOut,
4169 const size_t numEnt,
4170 const LocalOrdinal lclRow)
const;
4198 unpackRow (GlobalOrdinal gidsOut[],
4200 const char imports[],
4201 const size_t offset,
4202 const size_t numBytes,
4203 const size_t numEnt,
4204 const size_t numBytesPerValue);
4215 allocatePackSpaceNew (Kokkos::DualView<char*, buffer_device_type>& exports,
4216 size_t& totalNumEntries,
4229 template<
class CrsMatrixType>
4230 friend Teuchos::RCP<CrsMatrixType>
4232 const Import<
typename CrsMatrixType::local_ordinal_type,
4233 typename CrsMatrixType::global_ordinal_type,
4234 typename CrsMatrixType::node_type>& importer,
4235 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4236 typename CrsMatrixType::global_ordinal_type,
4237 typename CrsMatrixType::node_type> >& domainMap,
4238 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4239 typename CrsMatrixType::global_ordinal_type,
4240 typename CrsMatrixType::node_type> >& rangeMap,
4241 const Teuchos::RCP<Teuchos::ParameterList>& params);
4244 template<
class CrsMatrixType>
4245 friend Teuchos::RCP<CrsMatrixType>
4247 const Import<
typename CrsMatrixType::local_ordinal_type,
4248 typename CrsMatrixType::global_ordinal_type,
4249 typename CrsMatrixType::node_type>& rowImporter,
4250 const Import<
typename CrsMatrixType::local_ordinal_type,
4251 typename CrsMatrixType::global_ordinal_type,
4252 typename CrsMatrixType::node_type>& domainImporter,
4253 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4254 typename CrsMatrixType::global_ordinal_type,
4255 typename CrsMatrixType::node_type> >& domainMap,
4256 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4257 typename CrsMatrixType::global_ordinal_type,
4258 typename CrsMatrixType::node_type> >& rangeMap,
4259 const Teuchos::RCP<Teuchos::ParameterList>& params);
4263 template<
class CrsMatrixType>
4264 friend Teuchos::RCP<CrsMatrixType>
4266 const Export<
typename CrsMatrixType::local_ordinal_type,
4267 typename CrsMatrixType::global_ordinal_type,
4268 typename CrsMatrixType::node_type>& exporter,
4269 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4270 typename CrsMatrixType::global_ordinal_type,
4271 typename CrsMatrixType::node_type> >& domainMap,
4272 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4273 typename CrsMatrixType::global_ordinal_type,
4274 typename CrsMatrixType::node_type> >& rangeMap,
4275 const Teuchos::RCP<Teuchos::ParameterList>& params);
4278 template<
class CrsMatrixType>
4279 friend Teuchos::RCP<CrsMatrixType>
4281 const Export<
typename CrsMatrixType::local_ordinal_type,
4282 typename CrsMatrixType::global_ordinal_type,
4283 typename CrsMatrixType::node_type>& rowExporter,
4284 const Export<
typename CrsMatrixType::local_ordinal_type,
4285 typename CrsMatrixType::global_ordinal_type,
4286 typename CrsMatrixType::node_type>& domainExporter,
4287 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4288 typename CrsMatrixType::global_ordinal_type,
4289 typename CrsMatrixType::node_type> >& domainMap,
4290 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4291 typename CrsMatrixType::global_ordinal_type,
4292 typename CrsMatrixType::node_type> >& rangeMap,
4293 const Teuchos::RCP<Teuchos::ParameterList>& params);
4314 const Teuchos::RCP<const map_type>& domainMap,
4315 const Teuchos::RCP<const map_type>& rangeMap,
4316 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
4337 const Teuchos::RCP<const map_type>& domainMap,
4338 const Teuchos::RCP<const map_type>& rangeMap,
4339 const Teuchos::RCP<Teuchos::ParameterList>& params)
const;
4360 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
4361 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
4362 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
4383 const Teuchos::RCP<const map_type>& domainMap,
4384 const Teuchos::RCP<const map_type>& rangeMap,
4385 const Teuchos::RCP<Teuchos::ParameterList>& params)
const;
4411 const ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node>& rowTransfer,
4412 const Teuchos::RCP<const ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node> > & domainTransfer,
4413 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
4414 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
4415 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
4431 const GlobalOrdinal gblColInds[],
4433 const size_t numInputEnt);
4445 insertGlobalValuesFiltered (
const GlobalOrdinal globalRow,
4446 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
4447 const Teuchos::ArrayView<const Scalar>& values);
4461 combineGlobalValues (
const GlobalOrdinal globalRowIndex,
4462 const Teuchos::ArrayView<const GlobalOrdinal>& columnIndices,
4463 const Teuchos::ArrayView<const Scalar>& values,
4484 combineGlobalValuesRaw (
const LocalOrdinal lclRow,
4485 const LocalOrdinal numEnt,
4487 const GlobalOrdinal cols[],
4501 template<
class BinaryFunction>
4503 transformGlobalValues (
const GlobalOrdinal globalRow,
4504 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
4505 const Teuchos::ArrayView<const Scalar>& values,
4507 const bool atomic = useAtomicUpdatesByDefault)
const
4510 typedef LocalOrdinal LO;
4511 typedef GlobalOrdinal GO;
4513 const LO numInputEnt =
static_cast<LO
> (indices.size ());
4514 if (static_cast<LO> (values.size ()) != numInputEnt) {
4515 return Teuchos::OrdinalTraits<LO>::invalid ();
4518 const GO*
const inputCols = indices.getRawPtr ();
4519 const IST*
const inputVals =
4520 reinterpret_cast<const IST*
> (values.getRawPtr ());
4521 return this->transformGlobalValues (globalRow, numInputEnt, inputVals,
4522 inputCols, f, atomic);
4532 insertNonownedGlobalValues (
const GlobalOrdinal globalRow,
4533 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
4534 const Teuchos::ArrayView<const Scalar>& values);
4581 const typename crs_graph_type::SLocalGlobalViews& newInds,
4582 const Teuchos::ArrayView<impl_scalar_type>& oldRowVals,
4583 const Teuchos::ArrayView<const impl_scalar_type>& newRowVals,
4584 const ELocalGlobal lg,
4585 const ELocalGlobal I);
4588 typedef DistObject<char, LocalOrdinal, GlobalOrdinal, Node> dist_object_type;
4592 typedef Teuchos::OrdinalTraits<LocalOrdinal> OTL;
4593 typedef Kokkos::Details::ArithTraits<impl_scalar_type> STS;
4594 typedef Kokkos::Details::ArithTraits<mag_type> STM;
4595 typedef MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> MV;
4596 typedef Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> V;
4600 enum GraphAllocationStatus {
4601 GraphAlreadyAllocated,
4602 GraphNotYetAllocated
4609 Teuchos::ArrayRCP<Teuchos::Array<impl_scalar_type> >
4610 allocateValues2D ();
4629 void allocateValues (ELocalGlobal lg, GraphAllocationStatus gas);
4642 const RowInfo& rowInfo);
4733 const bool force =
false)
const;
4758 const bool force =
false)
const;
4771 const Teuchos::ETransp mode,
4797 LocalOrdinal& numEnt,
4798 const RowInfo& rowinfo)
const;
4820 LocalOrdinal& numEnt,
4821 const RowInfo& rowinfo)
const;
4830 Teuchos::ArrayView<const impl_scalar_type>
getView (
RowInfo rowinfo)
const;
4843 Teuchos::ArrayView<impl_scalar_type>
4854 Kokkos::View<const impl_scalar_type*, execution_space, Kokkos::MemoryUnmanaged>
4855 getRowView (
const RowInfo& rowInfo)
const;
4868 Kokkos::View<impl_scalar_type*, execution_space, Kokkos::MemoryUnmanaged>
4869 getRowViewNonConst (
const RowInfo& rowInfo)
const;
4875 friend class Tpetra::crsMatrix_Swap_Tester<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
4890 void fillLocalMatrix (
const Teuchos::RCP<Teuchos::ParameterList>& params);
4914 Teuchos::RCP<const Graph> staticGraph_;
4915 Teuchos::RCP< Graph> myGraph_;
4934 typename local_matrix_type::values_type k_values1D_;
4935 Teuchos::ArrayRCP<Teuchos::Array<impl_scalar_type> > values2D_;
4979 std::map<GlobalOrdinal, std::pair<Teuchos::Array<GlobalOrdinal>,
4994 template<
class ViewType,
class OffsetViewType>
4995 struct pack_functor {
4999 OffsetViewType src_offset_;
5000 OffsetViewType dst_offset_;
5001 typedef typename OffsetViewType::non_const_value_type scalar_index_type;
5003 pack_functor (ViewType dst, ViewType src,
5004 OffsetViewType dst_offset, OffsetViewType src_offset) :
5007 src_offset_ (src_offset),
5008 dst_offset_ (dst_offset)
5011 KOKKOS_INLINE_FUNCTION
5012 void operator () (
const LocalOrdinal row)
const {
5013 scalar_index_type srcPos = src_offset_(row);
5014 const scalar_index_type dstEnd = dst_offset_(row+1);
5015 scalar_index_type dstPos = dst_offset_(row);
5016 for ( ; dstPos < dstEnd; ++dstPos, ++srcPos) {
5017 dst_(dstPos) = src_(srcPos);
5031 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
5032 Teuchos::RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
5034 size_t maxNumEntriesPerRow = 0,
5035 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
5038 return Teuchos::rcp (
new matrix_type (map, maxNumEntriesPerRow,
5039 DynamicProfile, params));
5042 template<
class CrsMatrixType>
5043 Teuchos::RCP<CrsMatrixType>
5045 const Import<
typename CrsMatrixType::local_ordinal_type,
5046 typename CrsMatrixType::global_ordinal_type,
5047 typename CrsMatrixType::node_type>& importer,
5048 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
5049 typename CrsMatrixType::global_ordinal_type,
5050 typename CrsMatrixType::node_type> >& domainMap,
5051 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
5052 typename CrsMatrixType::global_ordinal_type,
5053 typename CrsMatrixType::node_type> >& rangeMap,
5054 const Teuchos::RCP<Teuchos::ParameterList>& params)
5056 Teuchos::RCP<CrsMatrixType> destMatrix;
5057 sourceMatrix->importAndFillComplete (destMatrix, importer, domainMap, rangeMap, params);
5061 template<
class CrsMatrixType>
5062 Teuchos::RCP<CrsMatrixType>
5064 const Import<
typename CrsMatrixType::local_ordinal_type,
5065 typename CrsMatrixType::global_ordinal_type,
5066 typename CrsMatrixType::node_type>& rowImporter,
5067 const Import<
typename CrsMatrixType::local_ordinal_type,
5068 typename CrsMatrixType::global_ordinal_type,
5069 typename CrsMatrixType::node_type>& domainImporter,
5070 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
5071 typename CrsMatrixType::global_ordinal_type,
5072 typename CrsMatrixType::node_type> >& domainMap,
5073 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
5074 typename CrsMatrixType::global_ordinal_type,
5075 typename CrsMatrixType::node_type> >& rangeMap,
5076 const Teuchos::RCP<Teuchos::ParameterList>& params)
5078 Teuchos::RCP<CrsMatrixType> destMatrix;
5079 sourceMatrix->importAndFillComplete (destMatrix, rowImporter, domainImporter, domainMap, rangeMap, params);
5083 template<
class CrsMatrixType>
5084 Teuchos::RCP<CrsMatrixType>
5086 const Export<
typename CrsMatrixType::local_ordinal_type,
5087 typename CrsMatrixType::global_ordinal_type,
5088 typename CrsMatrixType::node_type>& exporter,
5089 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
5090 typename CrsMatrixType::global_ordinal_type,
5091 typename CrsMatrixType::node_type> >& domainMap,
5092 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
5093 typename CrsMatrixType::global_ordinal_type,
5094 typename CrsMatrixType::node_type> >& rangeMap,
5095 const Teuchos::RCP<Teuchos::ParameterList>& params)
5097 Teuchos::RCP<CrsMatrixType> destMatrix;
5098 sourceMatrix->exportAndFillComplete (destMatrix, exporter, domainMap, rangeMap, params);
5102 template<
class CrsMatrixType>
5103 Teuchos::RCP<CrsMatrixType>
5105 const Export<
typename CrsMatrixType::local_ordinal_type,
5106 typename CrsMatrixType::global_ordinal_type,
5107 typename CrsMatrixType::node_type>& rowExporter,
5108 const Export<
typename CrsMatrixType::local_ordinal_type,
5109 typename CrsMatrixType::global_ordinal_type,
5110 typename CrsMatrixType::node_type>& domainExporter,
5111 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
5112 typename CrsMatrixType::global_ordinal_type,
5113 typename CrsMatrixType::node_type> >& domainMap,
5114 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
5115 typename CrsMatrixType::global_ordinal_type,
5116 typename CrsMatrixType::node_type> >& rangeMap,
5117 const Teuchos::RCP<Teuchos::ParameterList>& params)
5119 Teuchos::RCP<CrsMatrixType> destMatrix;
5120 sourceMatrix->exportAndFillComplete (destMatrix, rowExporter, domainExporter, domainMap, rangeMap, params);
5132 #endif // TPETRA_CRSMATRIX_DECL_HPP
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.
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.
bool isConstantStride() const
Whether this multivector has constant stride between columns.
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.
local_matrix_type lclMatrix_
The local sparse matrix.
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.
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.
CrsMatrix & operator=(const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &)=delete
Copy assignment (forbidden).
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.
local_matrix_type getLocalMatrix() const
The local sparse matrix.
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.
void localMultiply(const MultiVector< DomainScalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< RangeScalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode, RangeScalar alpha, RangeScalar beta) const
Compute a sparse matrix-MultiVector product local to each process.
A read-only, row-oriented interface to a 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.