42 #ifndef TPETRA_CRSMATRIX_DECL_HPP 43 #define TPETRA_CRSMATRIX_DECL_HPP 53 #include "Tpetra_ConfigDefs.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" 63 #include "Kokkos_Sparse.hpp" 68 #include "Kokkos_Sparse_impl_sor.hpp" 187 class GlobalOrdinal = ::Tpetra::Details::DefaultTypes::global_ordinal_type,
189 const bool classic = Node::classic>
191 public RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>,
192 public DistObject<char, LocalOrdinal, GlobalOrdinal, Node, classic>
228 typedef typename Kokkos::Details::ArithTraits<impl_scalar_type>::mag_type
mag_type;
255 typedef typename local_graph_type::entries_type::non_const_type t_LocalOrdinal_1D
TPETRA_DEPRECATED;
283 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
284 size_t maxNumEntriesPerRow,
286 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
305 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
306 const Teuchos::ArrayRCP<const size_t>& NumEntriesPerRowToAlloc,
308 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
332 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
333 const Teuchos::RCP<const map_type>& colMap,
334 size_t maxNumEntriesPerRow,
336 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
360 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
361 const Teuchos::RCP<const map_type>& colMap,
362 const Teuchos::ArrayRCP<const size_t>& NumEntriesPerRowToAlloc,
364 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
390 explicit CrsMatrix (
const Teuchos::RCP<const crs_graph_type>& graph,
391 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
416 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
417 const Teuchos::RCP<const map_type>& colMap,
418 const typename local_matrix_type::row_map_type& rowPointers,
419 const typename local_graph_type::entries_type::non_const_type& columnIndices,
420 const typename local_matrix_type::values_type& values,
421 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
446 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
447 const Teuchos::RCP<const map_type>& colMap,
448 const Teuchos::ArrayRCP<size_t>& rowPointers,
449 const Teuchos::ArrayRCP<LocalOrdinal>& columnIndices,
450 const Teuchos::ArrayRCP<Scalar>& values,
451 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
473 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
474 const Teuchos::RCP<const map_type>& colMap,
475 const local_matrix_type& lclMatrix,
476 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
479 template <
class S2,
class LO2,
class GO2,
class N2, const
bool isClassic>
506 template <
class Node2>
507 Teuchos::RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node2, Node2::classic> >
508 clone (
const Teuchos::RCP<Node2>& node2,
509 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const 511 using Teuchos::Array;
512 using Teuchos::ArrayRCP;
513 using Teuchos::ArrayView;
515 using Teuchos::ParameterList;
518 using Teuchos::sublist;
521 const char tfecfFuncName[] =
"clone";
524 bool fillCompleteClone =
true;
525 bool useLocalIndices = this->
hasColMap ();
527 if (! params.is_null ()) {
528 fillCompleteClone = params->get (
"fillComplete clone", fillCompleteClone);
529 useLocalIndices = params->get (
"Locally indexed clone", useLocalIndices);
531 bool staticProfileClone =
true;
532 staticProfileClone = params->get (
"Static profile clone", staticProfileClone);
536 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
537 ! this->
hasColMap () && useLocalIndices, std::runtime_error,
538 ": You requested that the returned clone have local indices, but the " 539 "the source matrix does not have a column Map yet.");
541 RCP<const Map2> clonedRowMap = this->
getRowMap ()->template clone<Node2> (node2);
544 RCP<CrsMatrix2> clonedMatrix;
545 ArrayRCP<const size_t> numEntriesPerRow;
546 size_t numEntriesForAll = 0;
547 bool boundSameForAllLocalRows =
false;
548 staticGraph_->getNumEntriesPerLocalRowUpperBound (numEntriesPerRow,
550 boundSameForAllLocalRows);
551 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
552 numEntriesForAll != 0 &&
553 static_cast<size_t> (numEntriesPerRow.size ()) != 0,
554 std::logic_error,
": getNumEntriesPerLocalRowUpperBound returned a " 555 "nonzero numEntriesForAll = " << numEntriesForAll <<
" , as well as a " 556 "numEntriesPerRow array of nonzero length " << numEntriesPerRow.size ()
557 <<
". This should never happen. Please report this bug to the Tpetra " 559 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
560 numEntriesForAll != 0 && ! boundSameForAllLocalRows,
561 std::logic_error,
": getNumEntriesPerLocalRowUpperBound returned a " 562 "nonzero numEntriesForAll = " << numEntriesForAll <<
" , but claims " 563 "(via its third output value) that the upper bound is not the same for " 564 "all rows. This should never happen. Please report this bug to the " 565 "Tpetra developers.");
566 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
567 numEntriesPerRow.size () != 0 && boundSameForAllLocalRows,
568 std::logic_error,
": getNumEntriesPerLocalRowUpperBound returned a " 569 "numEntriesPerRow array of nonzero length " << numEntriesPerRow.size ()
570 <<
", but claims (via its third output value) that the upper bound is " 571 "not the same for all rows. This should never happen. Please report " 572 "this bug to the Tpetra developers.");
574 RCP<ParameterList> matParams =
575 params.is_null () ? null : sublist (params,
"CrsMatrix");
576 if (useLocalIndices) {
577 RCP<const Map2> clonedColMap =
578 this->
getColMap ()->template clone<Node2> (node2);
579 if (numEntriesPerRow.is_null ()) {
580 clonedMatrix = rcp (
new CrsMatrix2 (clonedRowMap, clonedColMap,
581 numEntriesForAll, pftype,
585 clonedMatrix = rcp (
new CrsMatrix2 (clonedRowMap, clonedColMap,
586 numEntriesPerRow, pftype,
591 if (numEntriesPerRow.is_null ()) {
592 clonedMatrix = rcp (
new CrsMatrix2 (clonedRowMap, numEntriesForAll,
596 clonedMatrix = rcp (
new CrsMatrix2 (clonedRowMap, numEntriesPerRow,
601 numEntriesPerRow = Teuchos::null;
602 numEntriesForAll = 0;
604 if (useLocalIndices) {
605 clonedMatrix->allocateValues (LocalIndices,
606 CrsMatrix2::GraphNotYetAllocated);
608 ArrayView<const LocalOrdinal> linds;
609 ArrayView<const Scalar> vals;
610 for (LocalOrdinal lrow = clonedRowMap->getMinLocalIndex ();
611 lrow <= clonedRowMap->getMaxLocalIndex ();
615 clonedMatrix->insertLocalValues (lrow, linds, vals);
620 Array<LocalOrdinal> linds;
622 for (LocalOrdinal lrow = clonedRowMap->getMinLocalIndex ();
623 lrow <= clonedRowMap->getMaxLocalIndex ();
626 if (theNumEntries > static_cast<size_t> (linds.size ())) {
627 linds.resize (theNumEntries);
629 if (theNumEntries > static_cast<size_t> (vals.size ())) {
630 vals.resize (theNumEntries);
633 linds (), vals (), theNumEntries);
634 if (theNumEntries != 0) {
635 clonedMatrix->insertLocalValues (lrow, linds (0, theNumEntries),
636 vals (0, theNumEntries));
642 clonedMatrix->allocateValues (GlobalIndices,
643 CrsMatrix2::GraphNotYetAllocated);
645 ArrayView<const GlobalOrdinal> ginds;
646 ArrayView<const Scalar> vals;
647 for (GlobalOrdinal grow = clonedRowMap->getMinGlobalIndex ();
648 grow <= clonedRowMap->getMaxGlobalIndex ();
651 if (ginds.size () > 0) {
652 clonedMatrix->insertGlobalValues (grow, ginds, vals);
657 Array<GlobalOrdinal> ginds;
659 for (GlobalOrdinal grow = clonedRowMap->getMinGlobalIndex ();
660 grow <= clonedRowMap->getMaxGlobalIndex ();
663 if (theNumEntries > static_cast<size_t> (ginds.size ())) {
664 ginds.resize (theNumEntries);
666 if (theNumEntries > static_cast<size_t> (vals.size ())) {
667 vals.resize (theNumEntries);
670 if (theNumEntries != 0) {
671 clonedMatrix->insertGlobalValues (grow, ginds (0, theNumEntries),
672 vals (0, theNumEntries));
678 if (fillCompleteClone) {
679 RCP<const Map2> clonedRangeMap;
680 RCP<const Map2> clonedDomainMap;
684 clonedRangeMap = this->
getRangeMap ()->template clone<Node2> (node2);
687 clonedRangeMap = clonedRowMap;
691 clonedDomainMap = this->
getDomainMap ()->template clone<Node2> (node2);
694 clonedDomainMap = clonedRowMap;
697 catch (std::exception &e) {
698 const bool caughtExceptionOnClone =
true;
699 TEUCHOS_TEST_FOR_EXCEPTION
700 (caughtExceptionOnClone, std::runtime_error,
701 Teuchos::typeName (*
this) <<
"::clone: Caught the following " 702 "exception while cloning range and domain Maps on a clone of " 703 "type " << Teuchos::typeName (*clonedMatrix) <<
": " << e.what ());
706 RCP<ParameterList> fillparams =
707 params.is_null () ? Teuchos::null : sublist (params,
"fillComplete");
709 clonedMatrix->fillComplete (clonedDomainMap, clonedRangeMap,
712 catch (std::exception &e) {
713 const bool caughtExceptionOnClone =
true;
714 TEUCHOS_TEST_FOR_EXCEPTION(
715 caughtExceptionOnClone, std::runtime_error,
716 Teuchos::typeName (*
this) <<
"::clone: Caught the following " 717 "exception while calling fillComplete() on a clone of type " 718 << Teuchos::typeName (*clonedMatrix) <<
": " << e.what ());
802 const Teuchos::ArrayView<const GlobalOrdinal>& cols,
803 const Teuchos::ArrayView<const Scalar>& vals);
821 const LocalOrdinal numEnt,
823 const GlobalOrdinal inds[]);
867 const Teuchos::ArrayView<const LocalOrdinal> &cols,
868 const Teuchos::ArrayView<const Scalar> &vals);
886 const LocalOrdinal numEnt,
888 const LocalOrdinal cols[]);
926 template<
class GlobalIndicesViewType,
927 class ImplScalarViewType>
930 const typename UnmanagedView<GlobalIndicesViewType>::type& inputInds,
931 const typename UnmanagedView<ImplScalarViewType>::type& inputVals)
const 939 static_assert (Kokkos::is_view<GlobalIndicesViewType>::value,
940 "First template parameter GlobalIndicesViewType must be " 942 static_assert (Kokkos::is_view<ImplScalarViewType>::value,
943 "Second template parameter ImplScalarViewType must be a " 945 static_assert (static_cast<int> (GlobalIndicesViewType::rank) == 1,
946 "First template parameter GlobalIndicesViewType must " 948 static_assert (static_cast<int> (ImplScalarViewType::rank) == 1,
949 "Second template parameter ImplScalarViewType must have " 951 static_assert (std::is_same<
952 typename GlobalIndicesViewType::non_const_value_type,
953 global_ordinal_type>::value,
954 "First template parameter GlobalIndicesViewType must " 955 "contain values of type global_ordinal_type.");
956 static_assert (std::is_same<
957 typename ImplScalarViewType::non_const_value_type,
958 impl_scalar_type>::value,
959 "Second template parameter ImplScalarViewType must " 960 "contain values of type impl_scalar_type.");
962 typedef LocalOrdinal LO;
963 typedef ImplScalarViewType ISVT;
964 typedef GlobalIndicesViewType GIVT;
968 return Teuchos::OrdinalTraits<LO>::invalid ();
970 const RowInfo rowInfo = staticGraph_->getRowInfoFromGlobalRowIndex (globalRow);
971 if (rowInfo.localRow == Teuchos::OrdinalTraits<size_t>::invalid ()) {
974 return static_cast<LO
> (0);
977 auto curVals = this->getRowViewNonConst (rowInfo);
979 typedef typename std::decay<decltype (curVals)>::type OSVT;
980 return staticGraph_->template replaceGlobalValues<OSVT, GIVT, ISVT> (rowInfo,
991 const Teuchos::ArrayView<const GlobalOrdinal>& cols,
992 const Teuchos::ArrayView<const Scalar>& vals)
const;
1011 const LocalOrdinal numEnt,
1012 const Scalar vals[],
1013 const GlobalOrdinal cols[])
const;
1050 template<
class LocalIndicesViewType,
1051 class ImplScalarViewType>
1054 const typename UnmanagedView<LocalIndicesViewType>::type& inputInds,
1055 const typename UnmanagedView<ImplScalarViewType>::type& inputVals)
const 1063 static_assert (Kokkos::is_view<LocalIndicesViewType>::value,
1064 "First template parameter LocalIndicesViewType must be " 1066 static_assert (Kokkos::is_view<ImplScalarViewType>::value,
1067 "Second template parameter ImplScalarViewType must be a " 1069 static_assert (static_cast<int> (LocalIndicesViewType::rank) == 1,
1070 "First template parameter LocalIndicesViewType must " 1072 static_assert (static_cast<int> (ImplScalarViewType::rank) == 1,
1073 "Second template parameter ImplScalarViewType must have " 1075 static_assert (std::is_same<
1076 typename LocalIndicesViewType::non_const_value_type,
1077 local_ordinal_type>::value,
1078 "First template parameter LocalIndicesViewType must " 1079 "contain values of type local_ordinal_type.");
1080 static_assert (std::is_same<
1081 typename ImplScalarViewType::non_const_value_type,
1082 impl_scalar_type>::value,
1083 "Second template parameter ImplScalarViewType must " 1084 "contain values of type impl_scalar_type.");
1086 typedef LocalOrdinal LO;
1090 return Teuchos::OrdinalTraits<LO>::invalid ();
1093 const RowInfo rowInfo = staticGraph_->getRowInfo (localRow);
1094 if (rowInfo.localRow == Teuchos::OrdinalTraits<size_t>::invalid ()) {
1097 return static_cast<LO
> (0);
1100 auto curVals = this->getRowViewNonConst (rowInfo);
1101 typedef typename std::decay<decltype (curVals) >::type OSVT;
1102 typedef typename UnmanagedView<LocalIndicesViewType>::type LIVT;
1103 typedef typename UnmanagedView<ImplScalarViewType>::type ISVT;
1104 return staticGraph_->template replaceLocalValues<OSVT, LIVT, ISVT> (rowInfo,
1115 const Teuchos::ArrayView<const LocalOrdinal>& cols,
1116 const Teuchos::ArrayView<const Scalar>& vals)
const;
1137 const LocalOrdinal numEnt,
1138 const Scalar inputVals[],
1139 const LocalOrdinal inputCols[])
const;
1146 static const bool useAtomicUpdatesByDefault =
1147 #ifdef KOKKOS_HAVE_SERIAL 1148 ! std::is_same<execution_space, Kokkos::Serial>::value;
1151 #endif // KOKKOS_HAVE_SERIAL 1192 const Teuchos::ArrayView<const GlobalOrdinal>& cols,
1193 const Teuchos::ArrayView<const Scalar>& vals,
1194 const bool atomic = useAtomicUpdatesByDefault);
1220 const LocalOrdinal numEnt,
1221 const Scalar vals[],
1222 const GlobalOrdinal cols[],
1223 const bool atomic = useAtomicUpdatesByDefault);
1261 template<
class LocalIndicesViewType,
1262 class ImplScalarViewType>
1265 const typename UnmanagedView<LocalIndicesViewType>::type& inputInds,
1266 const typename UnmanagedView<ImplScalarViewType>::type& inputVals,
1267 const bool atomic = useAtomicUpdatesByDefault)
const 1275 static_assert (Kokkos::is_view<LocalIndicesViewType>::value,
1276 "First template parameter LocalIndicesViewType must be " 1278 static_assert (Kokkos::is_view<ImplScalarViewType>::value,
1279 "Second template parameter ImplScalarViewType must be a " 1281 static_assert (static_cast<int> (LocalIndicesViewType::rank) == 1,
1282 "First template parameter LocalIndicesViewType must " 1284 static_assert (static_cast<int> (ImplScalarViewType::rank) == 1,
1285 "Second template parameter ImplScalarViewType must have " 1287 static_assert (std::is_same<
1288 typename LocalIndicesViewType::non_const_value_type,
1289 local_ordinal_type>::value,
1290 "First template parameter LocalIndicesViewType must " 1291 "contain values of type local_ordinal_type.");
1292 static_assert (std::is_same<
1293 typename ImplScalarViewType::non_const_value_type,
1294 impl_scalar_type>::value,
1295 "Second template parameter ImplScalarViewType must " 1296 "contain values of type impl_scalar_type.");
1298 typedef LocalOrdinal LO;
1300 if (! this->
isFillActive () || this->staticGraph_.is_null ()) {
1302 return Teuchos::OrdinalTraits<LO>::invalid ();
1305 const RowInfo rowInfo = this->staticGraph_->getRowInfo (localRow);
1306 if (rowInfo.localRow == Teuchos::OrdinalTraits<size_t>::invalid ()) {
1309 return static_cast<LO
> (0);
1312 auto curVals = this->getRowViewNonConst (rowInfo);
1313 typedef typename std::remove_const<typename std::remove_reference<decltype (curVals)>::type>::type OSVT;
1314 typedef typename UnmanagedView<LocalIndicesViewType>::type LIVT;
1315 typedef typename UnmanagedView<ImplScalarViewType>::type ISVT;
1316 return staticGraph_->template sumIntoLocalValues<OSVT, LIVT, ISVT> (rowInfo,
1354 const Teuchos::ArrayView<const LocalOrdinal>& cols,
1355 const Teuchos::ArrayView<const Scalar>& vals,
1356 const bool atomic = useAtomicUpdatesByDefault)
const;
1381 const LocalOrdinal numEnt,
1382 const Scalar vals[],
1383 const LocalOrdinal cols[],
1384 const bool atomic = useAtomicUpdatesByDefault)
const;
1429 template<
class LocalIndicesViewType,
1430 class ImplScalarViewType,
1431 class BinaryFunction>
1434 const typename UnmanagedView<LocalIndicesViewType>::type& inputInds,
1435 const typename UnmanagedView<ImplScalarViewType>::type& inputVals,
1437 const bool atomic = useAtomicUpdatesByDefault)
const 1445 static_assert (Kokkos::is_view<LocalIndicesViewType>::value,
1446 "First template parameter LocalIndicesViewType must be " 1448 static_assert (Kokkos::is_view<ImplScalarViewType>::value,
1449 "Second template parameter ImplScalarViewType must be a " 1451 static_assert (static_cast<int> (LocalIndicesViewType::rank) == 1,
1452 "First template parameter LocalIndicesViewType must " 1454 static_assert (static_cast<int> (ImplScalarViewType::rank) == 1,
1455 "Second template parameter ImplScalarViewType must have " 1457 static_assert (std::is_same<
1458 typename LocalIndicesViewType::non_const_value_type,
1459 local_ordinal_type>::value,
1460 "First template parameter LocalIndicesViewType must " 1461 "contain values of type local_ordinal_type.");
1462 static_assert (std::is_same<
1463 typename ImplScalarViewType::non_const_value_type,
1464 impl_scalar_type>::value,
1465 "Second template parameter ImplScalarViewType must " 1466 "contain values of type impl_scalar_type.");
1468 typedef LocalOrdinal LO;
1469 typedef BinaryFunction BF;
1473 return Teuchos::OrdinalTraits<LO>::invalid ();
1476 const RowInfo rowInfo = staticGraph_->getRowInfo (localRow);
1477 if (rowInfo.localRow == Teuchos::OrdinalTraits<size_t>::invalid ()) {
1480 return static_cast<LO
> (0);
1483 auto curRowVals = this->getRowViewNonConst (rowInfo);
1484 typedef typename std::decay<decltype (curRowVals) >::type OSVT;
1485 typedef typename UnmanagedView<LocalIndicesViewType>::type LIVT;
1486 typedef typename UnmanagedView<ImplScalarViewType>::type ISVT;
1487 return staticGraph_->template transformLocalValues<OSVT, LIVT, ISVT, BF> (rowInfo,
1531 template<
class BinaryFunction,
class InputMemorySpace>
1534 const Kokkos::View<
const GlobalOrdinal*,
1536 Kokkos::MemoryUnmanaged>& inputInds,
1537 const Kokkos::View<
const impl_scalar_type*,
1539 Kokkos::MemoryUnmanaged>& inputVals,
1541 const bool atomic = useAtomicUpdatesByDefault)
const 1543 using Kokkos::MemoryUnmanaged;
1545 typedef impl_scalar_type ST;
1546 typedef BinaryFunction BF;
1547 typedef device_type DD;
1548 typedef InputMemorySpace ID;
1552 return Teuchos::OrdinalTraits<LocalOrdinal>::invalid ();
1556 staticGraph_->getRowInfoFromGlobalRowIndex (globalRow);
1557 if (rowInfo.localRow == Teuchos::OrdinalTraits<size_t>::invalid ()) {
1560 return static_cast<LocalOrdinal
> (0);
1562 auto curRowVals = this->getRowViewNonConst (rowInfo);
1564 return staticGraph_->template transformGlobalValues<ST, BF, ID, DD> (rowInfo,
1575 void scale (
const Scalar& alpha);
1601 setAllValues (
const typename local_matrix_type::row_map_type& ptr,
1602 const typename local_graph_type::entries_type::non_const_type& ind,
1603 const typename local_matrix_type::values_type& val);
1630 const Teuchos::ArrayRCP<LocalOrdinal>& ind,
1631 const Teuchos::ArrayRCP<Scalar>& val);
1634 getAllValues (Teuchos::ArrayRCP<const size_t>& rowPointers,
1635 Teuchos::ArrayRCP<const LocalOrdinal>& columnIndices,
1636 Teuchos::ArrayRCP<const Scalar>& values)
const;
1685 void resumeFill (
const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
1745 fillComplete (
const Teuchos::RCP<const map_type>& domainMap,
1746 const Teuchos::RCP<const map_type>& rangeMap,
1747 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
1776 fillComplete (
const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
1806 const Teuchos::RCP<const map_type>& rangeMap,
1807 const Teuchos::RCP<const import_type>& importer = Teuchos::null,
1808 const Teuchos::RCP<const export_type>& exporter = Teuchos::null,
1809 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
1821 replaceColMap (
const Teuchos::RCP<const map_type>& newColMap);
1906 const Teuchos::RCP<const map_type>& newColMap,
1907 const Teuchos::RCP<const import_type>& newImport = Teuchos::null,
1908 const bool sortEachRow =
true);
1924 Teuchos::RCP<const import_type>& newImporter);
1947 Teuchos::RCP<const Teuchos::Comm<int> >
getComm()
const;
1950 Teuchos::RCP<node_type>
getNode ()
const;
1953 Teuchos::RCP<const map_type>
getRowMap ()
const;
1956 Teuchos::RCP<const map_type>
getColMap ()
const;
1959 Teuchos::RCP<const RowGraph<LocalOrdinal, GlobalOrdinal, Node> >
getGraph ()
const;
1962 Teuchos::RCP<const crs_graph_type>
getCrsGraph ()
const;
1975 const crs_graph_type& getCrsGraphRef ()
const;
2252 const Teuchos::ArrayView<GlobalOrdinal>& Indices,
2253 const Teuchos::ArrayView<Scalar>& Values,
2254 size_t& NumEntries)
const;
2275 const Teuchos::ArrayView<LocalOrdinal>& colInds,
2276 const Teuchos::ArrayView<Scalar>& vals,
2277 size_t& numEntries)
const;
2294 Teuchos::ArrayView<const GlobalOrdinal>& indices,
2295 Teuchos::ArrayView<const Scalar>& values)
const;
2312 Teuchos::ArrayView<const LocalOrdinal>& indices,
2313 Teuchos::ArrayView<const Scalar>& values)
const;
2343 LocalOrdinal& numEnt,
2344 const LocalOrdinal*& lclColInds,
2345 const Scalar*& vals)
const;
2374 LocalOrdinal& numEnt,
2375 const impl_scalar_type*& val,
2376 const LocalOrdinal*& ind)
const;
2385 template<
class OutputScalarType>
2386 typename std::enable_if<! std::is_same<OutputScalarType, impl_scalar_type>::value &&
2387 std::is_convertible<impl_scalar_type, OutputScalarType>::value,
2390 LocalOrdinal& numEnt,
2391 const OutputScalarType*& val,
2392 const LocalOrdinal*& ind)
const 2394 const impl_scalar_type* valTmp = NULL;
2395 const LocalOrdinal err = this->
getLocalRowView (lclRow, numEnt, valTmp, ind);
2398 val =
reinterpret_cast<const OutputScalarType*
> (valTmp);
2479 const Kokkos::View<
const size_t*, device_type,
2480 Kokkos::MemoryUnmanaged>& offsets)
const;
2506 const Teuchos::ArrayView<const size_t>& offsets)
const;
2568 template <
class DomainScalar,
class RangeScalar>
2572 Teuchos::ETransp mode,
2574 RangeScalar beta)
const 2576 using Teuchos::NO_TRANS;
2580 typedef typename MultiVector<RangeScalar, LocalOrdinal, GlobalOrdinal,
2582 #ifdef HAVE_TPETRA_DEBUG 2583 const char tfecfFuncName[] =
"localMultiply: ";
2584 #endif // HAVE_TPETRA_DEBUG 2586 const range_impl_scalar_type theAlpha =
static_cast<range_impl_scalar_type
> (alpha);
2587 const range_impl_scalar_type theBeta =
static_cast<range_impl_scalar_type
> (beta);
2588 const bool conjugate = (mode == Teuchos::CONJ_TRANS);
2589 const bool transpose = (mode != Teuchos::NO_TRANS);
2590 auto X_lcl = X.template getLocalView<device_type> ();
2591 auto Y_lcl = Y.template getLocalView<device_type> ();
2593 #ifdef HAVE_TPETRA_DEBUG 2594 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2596 "X.getNumVectors() = " << X.
getNumVectors () <<
" != Y.getNumVectors() = " 2598 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2600 std::runtime_error,
"NO_TRANS case: X has the wrong number of local rows. " 2601 "X.getLocalLength() = " << X.
getLocalLength () <<
" != getColMap()->" 2602 "getNodeNumElements() = " <<
getColMap ()->getNodeNumElements () <<
".");
2603 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2605 std::runtime_error,
"NO_TRANS case: Y has the wrong number of local rows. " 2606 "Y.getLocalLength() = " << Y.
getLocalLength () <<
" != getRowMap()->" 2607 "getNodeNumElements() = " <<
getRowMap ()->getNodeNumElements () <<
".");
2608 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2610 std::runtime_error,
"TRANS or CONJ_TRANS case: X has the wrong number of " 2611 "local rows. X.getLocalLength() = " << X.
getLocalLength () <<
" != " 2612 "getRowMap()->getNodeNumElements() = " 2613 <<
getRowMap ()->getNodeNumElements () <<
".");
2614 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2616 std::runtime_error,
"TRANS or CONJ_TRANS case: X has the wrong number of " 2617 "local rows. Y.getLocalLength() = " << Y.
getLocalLength () <<
" != " 2618 "getColMap()->getNodeNumElements() = " 2619 <<
getColMap ()->getNodeNumElements () <<
".");
2620 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2621 (! isFillComplete (), std::runtime_error,
"The matrix is not fill " 2622 "complete. You must call fillComplete() (possibly with domain and range " 2623 "Map arguments) without an intervening resumeFill() call before you may " 2624 "call this method.");
2625 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2627 "X and Y must be constant stride.");
2630 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
2631 X_lcl.ptr_on_device () == Y_lcl.ptr_on_device () &&
2632 X_lcl.ptr_on_device () != NULL,
2633 std::runtime_error,
"X and Y may not alias one another.");
2634 #endif // HAVE_TPETRA_DEBUG 2638 KokkosSparse::spmv (conjugate ? KokkosSparse::ConjugateTranspose : KokkosSparse::Transpose,
2641 X.template getLocalView<device_type> (),
2643 Y.template getLocalView<device_type> ());
2646 KokkosSparse::spmv (KokkosSparse::NoTranspose,
2649 X.template getLocalView<device_type> (),
2651 Y.template getLocalView<device_type> ());
2690 const Teuchos::ETransp mode = Teuchos::NO_TRANS,
2691 const Scalar& alpha = Teuchos::ScalarTraits<Scalar>::one (),
2692 const Scalar& beta = Teuchos::ScalarTraits<Scalar>::zero ())
const;
2720 template <
class DomainScalar,
class RangeScalar>
2725 const RangeScalar& dampingFactor,
2726 const KokkosClassic::ESweepDirection direction)
const 2728 typedef LocalOrdinal LO;
2729 typedef GlobalOrdinal GO;
2733 typedef typename DMV::dual_view_type::host_mirror_space HMDT ;
2735 typedef typename k_local_graph_type::size_type offset_type;
2736 const char prefix[] =
"Tpetra::CrsMatrix::localGaussSeidel: ";
2738 TEUCHOS_TEST_FOR_EXCEPTION
2739 (! this->isFillComplete (), std::runtime_error,
2740 prefix <<
"The matrix is not fill complete.");
2743 TEUCHOS_TEST_FOR_EXCEPTION
2745 prefix <<
"B.getNumVectors() = " << numVecs <<
" != " 2747 TEUCHOS_TEST_FOR_EXCEPTION
2750 <<
" != this->getNodeNumRows() = " << lclNumRows <<
".");
2752 typename DMV::dual_view_type::t_host B_lcl = B.template getLocalView<HMDT> ();
2753 typename RMV::dual_view_type::t_host X_lcl = X.template getLocalView<HMDT> ();
2754 typename MMV::dual_view_type::t_host D_lcl = D.template getLocalView<HMDT> ();
2756 offset_type B_stride[8], X_stride[8], D_stride[8];
2757 B_lcl.stride (B_stride);
2758 X_lcl.stride (X_stride);
2759 D_lcl.stride (D_stride);
2762 k_local_graph_type lclGraph = lclMatrix.graph;
2763 typename local_matrix_type::row_map_type ptr = lclGraph.row_map;
2764 typename local_matrix_type::index_type ind = lclGraph.entries;
2765 typename local_matrix_type::values_type val = lclMatrix.values;
2766 const offset_type*
const ptrRaw = ptr.ptr_on_device ();
2767 const LO*
const indRaw = ind.ptr_on_device ();
2768 const impl_scalar_type*
const valRaw = val.ptr_on_device ();
2770 const std::string dir ((direction == KokkosClassic::Forward) ?
"F" :
"B");
2771 KokkosSparse::Impl::Sequential::gaussSeidel (static_cast<LO> (lclNumRows),
2772 static_cast<LO> (numVecs),
2773 ptrRaw, indRaw, valRaw,
2774 B_lcl.ptr_on_device (), B_stride[1],
2775 X_lcl.ptr_on_device (), X_stride[1],
2776 D_lcl.ptr_on_device (),
2777 static_cast<impl_scalar_type
> (dampingFactor),
2807 template <
class DomainScalar,
class RangeScalar>
2812 const Teuchos::ArrayView<LocalOrdinal>& rowIndices,
2813 const RangeScalar& dampingFactor,
2814 const KokkosClassic::ESweepDirection direction)
const 2816 typedef LocalOrdinal LO;
2817 typedef GlobalOrdinal GO;
2821 typedef typename DMV::dual_view_type::host_mirror_space HMDT ;
2823 typedef typename k_local_graph_type::size_type offset_type;
2824 const char prefix[] =
"Tpetra::CrsMatrix::reorderedLocalGaussSeidel: ";
2826 TEUCHOS_TEST_FOR_EXCEPTION
2827 (! this->isFillComplete (), std::runtime_error,
2828 prefix <<
"The matrix is not fill complete.");
2831 TEUCHOS_TEST_FOR_EXCEPTION
2833 prefix <<
"B.getNumVectors() = " << numVecs <<
" != " 2835 TEUCHOS_TEST_FOR_EXCEPTION
2838 <<
" != this->getNodeNumRows() = " << lclNumRows <<
".");
2839 TEUCHOS_TEST_FOR_EXCEPTION
2840 (static_cast<size_t> (rowIndices.size ()) < lclNumRows,
2841 std::invalid_argument, prefix <<
"rowIndices.size() = " 2842 << rowIndices.size () <<
" < this->getNodeNumRows() = " 2843 << lclNumRows <<
".");
2845 typename DMV::dual_view_type::t_host B_lcl = B.template getLocalView<HMDT> ();
2846 typename RMV::dual_view_type::t_host X_lcl = X.template getLocalView<HMDT> ();
2847 typename MMV::dual_view_type::t_host D_lcl = D.template getLocalView<HMDT> ();
2849 offset_type B_stride[8], X_stride[8], D_stride[8];
2850 B_lcl.stride (B_stride);
2851 X_lcl.stride (X_stride);
2852 D_lcl.stride (D_stride);
2856 typename local_matrix_type::index_type ind = lclGraph.entries;
2857 typename local_matrix_type::row_map_type ptr = lclGraph.row_map;
2858 typename local_matrix_type::values_type val = lclMatrix.values;
2859 const offset_type*
const ptrRaw = ptr.ptr_on_device ();
2860 const LO*
const indRaw = ind.ptr_on_device ();
2861 const impl_scalar_type*
const valRaw = val.ptr_on_device ();
2863 const std::string dir = (direction == KokkosClassic::Forward) ?
"F" :
"B";
2864 KokkosSparse::Impl::Sequential::reorderedGaussSeidel (static_cast<LO> (lclNumRows),
2865 static_cast<LO> (numVecs),
2866 ptrRaw, indRaw, valRaw,
2867 B_lcl.ptr_on_device (),
2869 X_lcl.ptr_on_device (),
2871 D_lcl.ptr_on_device (),
2872 rowIndices.getRawPtr (),
2873 static_cast<LO
> (lclNumRows),
2874 static_cast<impl_scalar_type> (dampingFactor),
2896 template <
class DomainScalar,
class RangeScalar>
2900 Teuchos::ETransp mode)
const 2902 using Teuchos::CONJ_TRANS;
2903 using Teuchos::NO_TRANS;
2904 using Teuchos::TRANS;
2905 const char tfecfFuncName[] =
"localSolve: ";
2907 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2908 (! isFillComplete (), std::runtime_error,
2909 "The matrix is not fill complete.");
2910 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2912 "X and Y must be constant stride.");
2914 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2915 (
getNodeNumRows()>0 && ! isUpperTriangular () && ! isLowerTriangular (), std::runtime_error,
2916 "The matrix is neither upper triangular or lower triangular. " 2917 "You may only call this method if the matrix is triangular. " 2918 "Remember that this is a local (per MPI process) property, and that " 2919 "Tpetra only knows how to do a local (per process) triangular solve.");
2921 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2922 (STS::isComplex && mode == TRANS, std::logic_error,
"This method does " 2923 "not currently support non-conjugated transposed solve (mode == " 2924 "Teuchos::TRANS) for complex scalar types.");
2948 const std::string trans = (mode == Teuchos::CONJ_TRANS) ?
"C" :
2949 (mode == Teuchos::TRANS ?
"T" :
"N");
2950 const std::string diag =
2954 X.template modify<device_type> ();
2957 auto X_lcl = X.template getLocalView<device_type> ();
2958 auto Y_lcl = Y.template getLocalView<device_type> ();
2959 KokkosSparse::trsv (uplo.c_str (), trans.c_str (), diag.c_str (),
2960 A_lcl, Y_lcl, X_lcl);
2964 for (
size_t j = 0; j < numVecs; ++j) {
2967 auto X_lcl = X_j->template getLocalView<device_type> ();
2968 auto Y_lcl = Y_j->template getLocalView<device_type> ();
2969 KokkosSparse::trsv (uplo.c_str (), trans.c_str (),
2970 diag.c_str (), A_lcl, Y_lcl, X_lcl);
2978 Teuchos::RCP<CrsMatrix<T, LocalOrdinal, GlobalOrdinal, Node, classic> >
2998 Teuchos::ETransp mode = Teuchos::NO_TRANS,
2999 Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
3000 Scalar beta = Teuchos::ScalarTraits<Scalar>::zero())
const;
3019 Teuchos::RCP<const map_type>
getRangeMap ()
const;
3093 const Scalar& dampingFactor,
3095 const int numSweeps)
const;
3167 const Teuchos::ArrayView<LocalOrdinal>& rowIndices,
3168 const Scalar& dampingFactor,
3170 const int numSweeps)
const;
3204 const Scalar& dampingFactor,
3206 const int numSweeps,
3207 const bool zeroInitialGuess)
const;
3242 const Teuchos::ArrayView<LocalOrdinal>& rowIndices,
3243 const Scalar& dampingFactor,
3245 const int numSweeps,
3246 const bool zeroInitialGuess)
const;
3258 virtual Teuchos::RCP<RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
3259 add (
const Scalar& alpha,
3264 const Teuchos::RCP<Teuchos::ParameterList>& params)
const;
3275 describe (Teuchos::FancyOStream &out,
3276 const Teuchos::EVerbosityLevel verbLevel =
3277 Teuchos::Describable::verbLevel_default)
const;
3289 const Teuchos::ArrayView<const LocalOrdinal>& permuteToLIDs,
3290 const Teuchos::ArrayView<const LocalOrdinal>& permuteFromLIDs);
3294 const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs,
3295 Teuchos::Array<char>& exports,
3296 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
3297 size_t& constantNumPackets,
3304 unpackAndCombineImpl (
const Teuchos::ArrayView<const LocalOrdinal>& importLIDs,
3305 const Teuchos::ArrayView<const char>& imports,
3306 const Teuchos::ArrayView<const size_t>& numPacketsPerLID,
3307 size_t constantNumPackets,
3310 const bool atomic = useAtomicUpdatesByDefault);
3312 unpackAndCombineImplNonStatic (
3313 const Teuchos::ArrayView<const LocalOrdinal>& importLIDs,
3314 const Teuchos::ArrayView<const char>& imports,
3315 const Teuchos::ArrayView<const size_t>& numPacketsPerLID,
3316 size_t constantNumPackets,
3331 unpackAndCombine (
const Teuchos::ArrayView<const LocalOrdinal> &importLIDs,
3332 const Teuchos::ArrayView<const char> &imports,
3333 const Teuchos::ArrayView<size_t> &numPacketsPerLID,
3334 size_t constantNumPackets,
3459 pack (
const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs,
3460 Teuchos::Array<char>& exports,
3461 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
3462 size_t& constantNumPackets,
3465 packNonStatic (
const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs,
3466 Teuchos::Array<char>& exports,
3467 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
3468 size_t& constantNumPackets,
3490 packRow (
char*
const numEntOut,
3493 const size_t numEnt,
3494 const LocalOrdinal lclRow)
const;
3520 packRowStatic (
char*
const numEntOut,
3523 const size_t numEnt,
3524 const LocalOrdinal lclRow)
const;
3549 unpackRow (impl_scalar_type*
const valInTmp,
3550 GlobalOrdinal*
const indInTmp,
3551 const size_t tmpNumEnt,
3552 const char*
const valIn,
3553 const char*
const indIn,
3554 const size_t numEnt,
3555 const LocalOrdinal lclRow,
3564 allocatePackSpace (Teuchos::Array<char>& exports,
3565 size_t& totalNumEntries,
3566 const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs)
const;
3577 template<
class CrsMatrixType>
3578 friend Teuchos::RCP<CrsMatrixType>
3580 const Import<
typename CrsMatrixType::local_ordinal_type,
3581 typename CrsMatrixType::global_ordinal_type,
3582 typename CrsMatrixType::node_type>& importer,
3583 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3584 typename CrsMatrixType::global_ordinal_type,
3585 typename CrsMatrixType::node_type> >& domainMap,
3586 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3587 typename CrsMatrixType::global_ordinal_type,
3588 typename CrsMatrixType::node_type> >& rangeMap,
3589 const Teuchos::RCP<Teuchos::ParameterList>& params);
3592 template<
class CrsMatrixType>
3593 friend Teuchos::RCP<CrsMatrixType>
3595 const Import<
typename CrsMatrixType::local_ordinal_type,
3596 typename CrsMatrixType::global_ordinal_type,
3597 typename CrsMatrixType::node_type>& rowImporter,
3598 const Import<
typename CrsMatrixType::local_ordinal_type,
3599 typename CrsMatrixType::global_ordinal_type,
3600 typename CrsMatrixType::node_type>& domainImporter,
3601 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3602 typename CrsMatrixType::global_ordinal_type,
3603 typename CrsMatrixType::node_type> >& domainMap,
3604 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3605 typename CrsMatrixType::global_ordinal_type,
3606 typename CrsMatrixType::node_type> >& rangeMap,
3607 const Teuchos::RCP<Teuchos::ParameterList>& params);
3611 template<
class CrsMatrixType>
3612 friend Teuchos::RCP<CrsMatrixType>
3614 const Export<
typename CrsMatrixType::local_ordinal_type,
3615 typename CrsMatrixType::global_ordinal_type,
3616 typename CrsMatrixType::node_type>& exporter,
3617 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3618 typename CrsMatrixType::global_ordinal_type,
3619 typename CrsMatrixType::node_type> >& domainMap,
3620 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3621 typename CrsMatrixType::global_ordinal_type,
3622 typename CrsMatrixType::node_type> >& rangeMap,
3623 const Teuchos::RCP<Teuchos::ParameterList>& params);
3626 template<
class CrsMatrixType>
3627 friend Teuchos::RCP<CrsMatrixType>
3629 const Export<
typename CrsMatrixType::local_ordinal_type,
3630 typename CrsMatrixType::global_ordinal_type,
3631 typename CrsMatrixType::node_type>& rowExporter,
3632 const Export<
typename CrsMatrixType::local_ordinal_type,
3633 typename CrsMatrixType::global_ordinal_type,
3634 typename CrsMatrixType::node_type>& domainExporter,
3635 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3636 typename CrsMatrixType::global_ordinal_type,
3637 typename CrsMatrixType::node_type> >& domainMap,
3638 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3639 typename CrsMatrixType::global_ordinal_type,
3640 typename CrsMatrixType::node_type> >& rangeMap,
3641 const Teuchos::RCP<Teuchos::ParameterList>& params);
3661 const import_type& importer,
3662 const Teuchos::RCP<const map_type>& domainMap,
3663 const Teuchos::RCP<const map_type>& rangeMap,
3664 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
3683 const import_type& rowImporter,
3684 const import_type& domainImporter,
3685 const Teuchos::RCP<const map_type>& domainMap,
3686 const Teuchos::RCP<const map_type>& rangeMap,
3687 const Teuchos::RCP<Teuchos::ParameterList>& params)
const;
3707 const export_type& exporter,
3708 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
3709 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
3710 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
3729 const export_type& rowExporter,
3730 const export_type& domainExporter,
3731 const Teuchos::RCP<const map_type>& domainMap,
3732 const Teuchos::RCP<const map_type>& rangeMap,
3733 const Teuchos::RCP<Teuchos::ParameterList>& params)
const;
3759 const ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node>& rowTransfer,
3760 const Teuchos::RCP<const ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node> > & domainTransfer,
3761 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
3762 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
3763 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
3783 insertGlobalValuesFiltered (
const GlobalOrdinal globalRow,
3784 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3785 const Teuchos::ArrayView<const Scalar>& values);
3797 insertLocalValuesFiltered (
const LocalOrdinal localRow,
3798 const Teuchos::ArrayView<const LocalOrdinal>& indices,
3799 const Teuchos::ArrayView<const Scalar>& values);
3813 combineGlobalValues (
const GlobalOrdinal globalRowIndex,
3814 const Teuchos::ArrayView<const GlobalOrdinal>& columnIndices,
3815 const Teuchos::ArrayView<const Scalar>& values,
3836 combineGlobalValuesRaw (
const LocalOrdinal lclRow,
3837 const LocalOrdinal numEnt,
3838 const impl_scalar_type vals[],
3839 const GlobalOrdinal cols[],
3853 template<
class BinaryFunction>
3856 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3857 const Teuchos::ArrayView<const Scalar>& values,
3859 const bool atomic = useAtomicUpdatesByDefault)
const 3861 using Kokkos::MemoryUnmanaged;
3863 typedef impl_scalar_type ST;
3864 typedef BinaryFunction BF;
3865 typedef GlobalOrdinal GO;
3866 typedef device_type DD;
3867 typedef typename View<GO*, DD>::HostMirror::device_type HD;
3871 const ST*
const rawInputVals =
3872 reinterpret_cast<const ST*
> (values.getRawPtr ());
3873 View<const ST*, HD, MemoryUnmanaged> inputValsK (rawInputVals,
3875 View<const GO*, HD, MemoryUnmanaged> inputIndsK (indices.getRawPtr (),
3877 return this->
template transformGlobalValues<BF, HD> (globalRow,
3891 insertNonownedGlobalValues (
const GlobalOrdinal globalRow,
3892 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3893 const Teuchos::ArrayView<const Scalar>& values);
3900 typedef Teuchos::OrdinalTraits<LocalOrdinal> OTL;
3901 typedef Kokkos::Details::ArithTraits<impl_scalar_type> STS;
3902 typedef Kokkos::Details::ArithTraits<mag_type> STM;
3905 typedef crs_graph_type
Graph;
3908 enum GraphAllocationStatus {
3909 GraphAlreadyAllocated,
3910 GraphNotYetAllocated
3929 void allocateValues (ELocalGlobal lg, GraphAllocationStatus gas);
4034 const bool force =
false)
const;
4059 const bool force =
false)
const;
4072 const Teuchos::ETransp mode,
4098 LocalOrdinal& numEnt,
4099 const RowInfo& rowinfo)
const;
4121 LocalOrdinal& numEnt,
4122 const RowInfo& rowinfo)
const;
4131 Teuchos::ArrayView<const impl_scalar_type>
getView (
RowInfo rowinfo)
const;
4154 Kokkos::View<const impl_scalar_type*, execution_space, Kokkos::MemoryUnmanaged>
4155 getRowView (
const RowInfo& rowInfo)
const;
4168 Kokkos::View<impl_scalar_type*, execution_space, Kokkos::MemoryUnmanaged>
4169 getRowViewNonConst (
const RowInfo& rowInfo)
const;
4178 void fillLocalMatrix (
const Teuchos::RCP<Teuchos::ParameterList>& params);
4202 Teuchos::RCP<const Graph> staticGraph_;
4203 Teuchos::RCP< Graph> myGraph_;
4222 typename local_matrix_type::values_type k_values1D_;
4223 Teuchos::ArrayRCP<Teuchos::Array<impl_scalar_type> > values2D_;
4267 std::map<GlobalOrdinal, std::pair<Teuchos::Array<GlobalOrdinal>,
4282 template<
class ViewType,
class OffsetViewType>
4283 struct pack_functor {
4287 OffsetViewType src_offset_;
4288 OffsetViewType dst_offset_;
4289 typedef typename OffsetViewType::non_const_value_type scalar_index_type;
4291 pack_functor (ViewType dst, ViewType src,
4292 OffsetViewType dst_offset, OffsetViewType src_offset) :
4295 src_offset_ (src_offset),
4296 dst_offset_ (dst_offset)
4299 KOKKOS_INLINE_FUNCTION
4300 void operator () (
const LocalOrdinal row)
const {
4301 scalar_index_type srcPos = src_offset_(row);
4302 const scalar_index_type dstEnd = dst_offset_(row+1);
4303 scalar_index_type dstPos = dst_offset_(row);
4304 for ( ; dstPos < dstEnd; ++dstPos, ++srcPos) {
4305 dst_(dstPos) = src_(srcPos);
4320 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node, const
bool classic = Node::
classic>
4321 Teuchos::RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
4323 size_t maxNumEntriesPerRow = 0,
4324 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
4327 return Teuchos::rcp (
new matrix_type (map, maxNumEntriesPerRow,
4382 template<
class CrsMatrixType>
4383 Teuchos::RCP<CrsMatrixType>
4385 const Import<
typename CrsMatrixType::local_ordinal_type,
4386 typename CrsMatrixType::global_ordinal_type,
4387 typename CrsMatrixType::node_type>& importer,
4388 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4389 typename CrsMatrixType::global_ordinal_type,
4390 typename CrsMatrixType::node_type> >& domainMap = Teuchos::null,
4391 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4392 typename CrsMatrixType::global_ordinal_type,
4393 typename CrsMatrixType::node_type> >& rangeMap = Teuchos::null,
4394 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
4396 Teuchos::RCP<CrsMatrixType> destMatrix;
4397 sourceMatrix->importAndFillComplete (destMatrix,importer,domainMap, rangeMap, params);
4454 template<
class CrsMatrixType>
4455 Teuchos::RCP<CrsMatrixType>
4457 const Import<
typename CrsMatrixType::local_ordinal_type,
4458 typename CrsMatrixType::global_ordinal_type,
4459 typename CrsMatrixType::node_type>& rowImporter,
4460 const Import<
typename CrsMatrixType::local_ordinal_type,
4461 typename CrsMatrixType::global_ordinal_type,
4462 typename CrsMatrixType::node_type>& domainImporter,
4463 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4464 typename CrsMatrixType::global_ordinal_type,
4465 typename CrsMatrixType::node_type> >& domainMap,
4466 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4467 typename CrsMatrixType::global_ordinal_type,
4468 typename CrsMatrixType::node_type> >& rangeMap,
4469 const Teuchos::RCP<Teuchos::ParameterList>& params)
4471 Teuchos::RCP<CrsMatrixType> destMatrix;
4472 sourceMatrix->importAndFillComplete (destMatrix,rowImporter,domainImporter, domainMap, rangeMap, params);
4509 template<
class CrsMatrixType>
4510 Teuchos::RCP<CrsMatrixType>
4512 const Export<
typename CrsMatrixType::local_ordinal_type,
4513 typename CrsMatrixType::global_ordinal_type,
4514 typename CrsMatrixType::node_type>& exporter,
4515 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4516 typename CrsMatrixType::global_ordinal_type,
4517 typename CrsMatrixType::node_type> >& domainMap = Teuchos::null,
4518 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4519 typename CrsMatrixType::global_ordinal_type,
4520 typename CrsMatrixType::node_type> >& rangeMap = Teuchos::null,
4521 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
4523 Teuchos::RCP<CrsMatrixType> destMatrix;
4524 sourceMatrix->exportAndFillComplete (destMatrix,exporter,domainMap, rangeMap, params);
4561 template<
class CrsMatrixType>
4562 Teuchos::RCP<CrsMatrixType>
4564 const Export<
typename CrsMatrixType::local_ordinal_type,
4565 typename CrsMatrixType::global_ordinal_type,
4566 typename CrsMatrixType::node_type>& rowExporter,
4567 const Export<
typename CrsMatrixType::local_ordinal_type,
4568 typename CrsMatrixType::global_ordinal_type,
4569 typename CrsMatrixType::node_type>& domainExporter,
4570 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4571 typename CrsMatrixType::global_ordinal_type,
4572 typename CrsMatrixType::node_type> >& domainMap,
4573 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4574 typename CrsMatrixType::global_ordinal_type,
4575 typename CrsMatrixType::node_type> >& rangeMap,
4576 const Teuchos::RCP<Teuchos::ParameterList>& params)
4578 Teuchos::RCP<CrsMatrixType> destMatrix;
4579 sourceMatrix->exportAndFillComplete (destMatrix,rowExporter,domainExporter,domainMap, rangeMap, params);
4591 #endif // TPETRA_CRSMATRIX_DECL_HPP ProfileType getProfileType() const
Returns true if the matrix was allocated with static data structures.
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.
void getGlobalRowView(GlobalOrdinal GlobalRow, Teuchos::ArrayView< const GlobalOrdinal > &indices, Teuchos::ArrayView< const Scalar > &values) const
Get a constant, nonpersisting view of a row of this matrix, using global row and column indices...
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
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...
Namespace Tpetra contains the class and methods constituting the Tpetra library.
void localMultiply(const MultiVector< DomainScalar, LocalOrdinal, GlobalOrdinal, Node, classic > &X, MultiVector< RangeScalar, LocalOrdinal, GlobalOrdinal, Node, classic > &Y, Teuchos::ETransp mode, RangeScalar alpha, RangeScalar beta) const
Compute a sparse matrix-MultiVector product local to each process.
size_t getNodeMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
Sparse matrix that presents a row-oriented interface that lets users read or modify entries...
std::string description() const
A one-line description of this object.
mag_type getFrobeniusNorm() const
Compute and return the Frobenius norm of the matrix.
LocalOrdinal local_ordinal_type
This class' second template parameter; the type of local indices.
size_t getNodeNumEntries() const
The local number of entries in this matrix.
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to alpha.
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.
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 RowGraph< LocalOrdinal, GlobalOrdinal, Node > > getGraph() const
This matrix's graph, as a RowGraph.
global_size_t getGlobalNumDiags() const
Returns the number of global diagonal entries, based on global row/column index comparisons.
bool isFillActive() const
Whether the matrix is not fill complete.
KokkosClassic::DefaultNode::DefaultNodeType node_type
Default value of Node template parameter.
Teuchos::RCP< CrsMatrix< T, LocalOrdinal, GlobalOrdinal, Node, classic > > convert() const
Return another CrsMatrix with the same entries, but converted to a different Scalar type T...
virtual void copyAndPermute(const SrcDistObject &source, size_t numSameIDs, const Teuchos::ArrayView< const LocalOrdinal > &permuteToLIDs, const Teuchos::ArrayView< const LocalOrdinal > &permuteFromLIDs)
Perform copies and permutations that are local to this process.
size_t getNodeNumDiags() const
Returns the number of local diagonal entries, based on global row/column index comparisons.
void resumeFill(const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Resume operations that may change the values or structure of the matrix.
Teuchos::ArrayView< const impl_scalar_type > getView(RowInfo rowinfo) const
Constant view of all entries (including extra space) in the given row.
global_size_t getGlobalNumEntries() const
The global number of entries in this matrix.
local_matrix_type getLocalMatrix() const
The local sparse matrix.
void gaussSeidelCopy(MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &B, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &D, const Scalar &dampingFactor, const ESweepDirection direction, const int numSweeps, const bool zeroInitialGuess) const
Version of gaussSeidel(), with fewer requirements on X.
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &x)
Details::EStorageStatus storageStatus_
Status of the matrix's storage, when not in a fill-complete state.
Teuchos::ArrayView< impl_scalar_type > getViewNonConst(const RowInfo &rowinfo) const
Nonconst view of all entries (including extra space) in the given row.
size_t getNodeNumCols() const
The number of columns connected to the locally owned rows of this matrix.
Teuchos::RCP< const map_type > getRowMap() const
The Map that describes the row distribution in this matrix.
bool hasColMap() const
Indicates whether the matrix has a well-defined column map.
void localGaussSeidel(const MultiVector< DomainScalar, LocalOrdinal, GlobalOrdinal, Node, classic > &B, MultiVector< RangeScalar, LocalOrdinal, GlobalOrdinal, Node, classic > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &D, const RangeScalar &dampingFactor, const KokkosClassic::ESweepDirection direction) const
Gauss-Seidel or SOR on .
One or more distributed dense vectors.
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries on this node in the specified global row.
Teuchos::RCP< node_type > getNode() const
The Kokkos Node instance.
GlobalOrdinal global_ordinal_type
This class' third template parameter; the type of global indices.
void localSolve(const MultiVector< RangeScalar, LocalOrdinal, GlobalOrdinal, Node, classic > &Y, MultiVector< DomainScalar, LocalOrdinal, GlobalOrdinal, Node, classic > &X, Teuchos::ETransp mode) const
Solves a linear system when the underlying matrix is locally triangular.
Teuchos::RCP< const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > > getVector(const size_t j) const
Return a Vector which is a const view of column j.
Teuchos::RCP< MV > getColumnMapMultiVector(const MV &X_domainMap, const bool force=false) const
Create a (or fetch a cached) column Map MultiVector.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
void apply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const
Compute a sparse matrix-MultiVector multiply.
Teuchos::RCP< CrsMatrixType > importAndFillCompleteCrsMatrix(const Teuchos::RCP< const CrsMatrixType > &sourceMatrix, const Import< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &rowImporter, const Import< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &domainImporter, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &domainMap, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Nonmember CrsMatrix constructor that fuses Import and fillComplete().
void replaceColMap(const Teuchos::RCP< const map_type > &newColMap)
Replace the matrix's column Map with the given Map.
LocalOrdinal transformGlobalValues(const GlobalOrdinal globalRow, 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 bool checkSizes(const SrcDistObject &source)
Compare the source and target (this) objects for compatibility.
Node node_type
This class' fourth template parameter; the Kokkos device type.
bool fillComplete_
Whether the matrix is fill complete.
bool isLowerTriangular() const
Indicates whether the matrix is lower triangular.
Node::device_type device_type
The Kokkos device type.
Allocation information for a locally owned row in a CrsGraph or CrsMatrix.
Import< LocalOrdinal, GlobalOrdinal, Node > import_type
The Import specialization suitable for this CrsMatrix specialization.
int local_ordinal_type
Default value of LocalOrdinal template parameter.
local_matrix_type::row_map_type t_RowPtrs TPETRA_DEPRECATED
DEPRECATED; use local_matrix_type::row_map_type instead.
virtual bool supportsRowViews() const
Return true if getLocalRowView() and getGlobalRowView() are valid for this object.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &diag) const
Get a copy of the diagonal entries of the matrix.
virtual void removeEmptyProcessesInPlace(const Teuchos::RCP< const map_type > &newMap)
Remove processes owning zero rows from the Maps and their communicator.
device_type::execution_space execution_space
The Kokkos execution space.
mag_type frobNorm_
Cached Frobenius norm of the (global) matrix.
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 fillLocalMatrix(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Fill data into the local matrix.
Teuchos::RCP< CrsMatrixType > importAndFillCompleteCrsMatrix(const Teuchos::RCP< const CrsMatrixType > &sourceMatrix, const Import< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &importer, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Nonmember CrsMatrix constructor that fuses Import and fillComplete().
size_t global_size_t
Global size_t object.
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.
Kokkos::StaticCrsGraph< LocalOrdinal, Kokkos::LayoutLeft, execution_space > local_graph_type
The type of the part of the sparse graph on each MPI process.
void exportAndFillComplete(Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > > &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.
global_size_t getGlobalNumCols() const
The number of global columns in the matrix.
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
bool isConstantStride() const
Whether this multivector has constant stride between columns.
void applyTranspose(const MV &X_in, MV &Y_in, const Teuchos::ETransp mode, Scalar alpha, Scalar beta) const
Special case of apply() for mode != Teuchos::NO_TRANS.
size_t getLocalLength() const
Local number of rows on the calling process.
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) const
Get offsets of the diagonal entries in the matrix.
local_matrix_type::values_type t_ValuesType TPETRA_DEPRECATED
DEPRECATED; use local_matrix_type::values_type instead.
bool isFillComplete() const
Whether the matrix is fill complete.
global_size_t getGlobalNumRows() const
Number of global elements in the row map of this matrix.
ESweepDirection
Sweep direction for Gauss-Seidel or Successive Over-Relaxation (SOR).
void allocateValues(ELocalGlobal lg, GraphAllocationStatus gas)
Allocate values (and optionally indices) using the Node.
local_matrix_type::values_type getLocalValuesView() const
Get the Kokkos local values.
Communication plan for data redistribution from a (possibly) multiply-owned to a uniquely-owned distr...
local_matrix_type::row_map_type::non_const_type t_RowPtrsNC TPETRA_DEPRECATED
DEPRECATED; use local_matrix_type::row_map_type::non_const_type instead.
void scale(const Scalar &alpha)
Scale the matrix's values: this := alpha*this.
LocalOrdinal transformLocalValues(const LocalOrdinal localRow, 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...
Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node2, Node2::classic > > clone(const Teuchos::RCP< Node2 > &node2, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null) const
Create a deep copy of this CrsMatrix, where the copy may have a different Node type.
void unpackAndCombine(const Teuchos::ArrayView< const LocalOrdinal > &importLIDs, const Teuchos::ArrayView< const char > &imports, const Teuchos::ArrayView< size_t > &numPacketsPerLID, size_t constantNumPackets, Distributor &distor, CombineMode combineMode)
Unpack the imported column indices and values, and combine into matrix.
Sets up and executes a communication plan for a Tpetra DistObject.
bool isStorageOptimized() const
Returns true if storage has been optimized.
CombineMode
Rule for combining data in an Import or Export.
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.
LocalOrdinal getLocalRowViewRaw(const LocalOrdinal lclRow, LocalOrdinal &numEnt, const LocalOrdinal *&lclColInds, const Scalar *&vals) const
Get a constant, nonpersisting, locally indexed view of the given row of the matrix, using "raw" pointers instead of Teuchos::ArrayView.
bool isUpperTriangular() const
Indicates whether the matrix is upper triangular.
bool isStaticGraph() const
Indicates that the graph is static, so that new entries cannot be added to this matrix.
KokkosSparse::CrsMatrix< impl_scalar_type, LocalOrdinal, 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...
virtual ~CrsMatrix()
Destructor.
void getLocalRowView(LocalOrdinal LocalRow, Teuchos::ArrayView< const LocalOrdinal > &indices, Teuchos::ArrayView< const Scalar > &values) const
Get a constant, nonpersisting view of a row of this matrix, using local row and column indices...
Abstract base class for objects that can be the source of an Import or Export operation.
crs_graph_type::local_graph_type local_graph_type
The part of the sparse matrix's graph on each MPI process.
double scalar_type
Default value of Scalar template parameter.
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local 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.
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 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 computeGlobalConstants()
Compute matrix properties that require collectives.
bool hasTransposeApply() const
Whether apply() allows applying the transpose or conjugate transpose.
void reorderedGaussSeidel(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &B, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &D, const Teuchos::ArrayView< LocalOrdinal > &rowIndices, const Scalar &dampingFactor, const ESweepDirection direction, const int numSweeps) const
Reordered "Hybrid" Jacobi + (Gauss-Seidel or SOR) on .
void importAndFillComplete(Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > > &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 getGlobalRowCopy(GlobalOrdinal GlobalRow, const Teuchos::ArrayView< GlobalOrdinal > &Indices, const Teuchos::ArrayView< Scalar > &Values, size_t &NumEntries) const
Fill given arrays with a deep copy of the locally owned entries of the matrix in a given row...
void getLocalRowCopy(LocalOrdinal localRow, const Teuchos::ArrayView< LocalOrdinal > &colInds, const Teuchos::ArrayView< Scalar > &vals, size_t &numEntries) const
Fill given arrays with a deep copy of the locally owned entries of the matrix in a given row...
Kokkos::Details::ArithTraits< impl_scalar_type >::mag_type mag_type
Type of a norm result.
size_t getNodeNumRows() const
The number of matrix rows owned by the calling process.
Scalar scalar_type
This class' first template parameter; the type of each entry in the matrix.
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &x)
local_matrix_type k_local_matrix_type TPETRA_DEPRECATED
DEPRECATED; use local_matrix_type instead.
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
Teuchos::RCP< MV > importMV_
Column Map MultiVector used in apply() and gaussSeidel().
void checkInternalState() const
Check that this object's state is sane; throw if it's not.
void reorderedGaussSeidelCopy(MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &B, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &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.
local_graph_type::entries_type::non_const_type t_LocalOrdinal_1D TPETRA_DEPRECATED
DEPRECATED; use local_graph_type::entries_type::non_const_type instead.
A parallel distribution of indices over processes.
void applyNonTranspose(const MV &X_in, MV &Y_in, Scalar alpha, Scalar beta) const
Special case of apply() for mode == Teuchos::NO_TRANS.
size_t getNumVectors() const
Number of columns in the multivector.
A read-only, row-oriented interface to a sparse matrix.
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
std::map< GlobalOrdinal, std::pair< Teuchos::Array< GlobalOrdinal >, Teuchos::Array< Scalar > > > nonlocals_
Nonlocal data added using insertGlobalValues().
size_t mergeRowIndicesAndValues(crs_graph_type &graph, const RowInfo &rowInfo)
Merge duplicate row indices in the given row, along with their corresponding values.
A distributed dense vector.
bool isGloballyIndexed() const
Whether the matrix is globally indexed on the calling process.
Teuchos::RCP< CrsMatrixType > exportAndFillCompleteCrsMatrix(const Teuchos::RCP< const CrsMatrixType > &sourceMatrix, const Export< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &rowExporter, const Export< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &domainExporter, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &domainMap, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Nonmember CrsMatrix constructor that fuses Export and fillComplete().
void gaussSeidel(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &B, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &D, const Scalar &dampingFactor, const ESweepDirection direction, const int numSweeps) const
"Hybrid" Jacobi + (Gauss-Seidel or SOR) on .
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().
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.
Teuchos::RCP< const map_type > getColMap() const
The Map that describes the column distribution in this matrix.
Teuchos::RCP< const map_type > getDomainMap() const
The domain Map of this matrix.
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...
CrsGraph< LocalOrdinal, GlobalOrdinal, Node, classic > crs_graph_type
The CrsGraph specialization suitable for this CrsMatrix specialization.
void globalAssemble()
Communicate nonlocal contributions to other processes.
Kokkos::Details::ArithTraits< Scalar >::val_type impl_scalar_type
The type used internally in place of Scalar.
Teuchos::RCP< MV > exportMV_
Row Map MultiVector used in apply().
Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > > 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.
Teuchos::RCP< MV > getRowMapMultiVector(const MV &Y_rangeMap, const bool force=false) const
Create a (or fetch a cached) row Map MultiVector.
Map< LocalOrdinal, GlobalOrdinal, Node > map_type
The Map specialization suitable for this CrsMatrix specialization.
Teuchos::RCP< const map_type > getRangeMap() const
The range Map of this matrix.
Export< LocalOrdinal, GlobalOrdinal, Node > export_type
The Export specialization suitable for this CrsMatrix specialization.
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.
Base class for distributed Tpetra objects that support data redistribution.
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
Implementation of RowMatrix::add: return alpha*A + beta*this.
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...
Teuchos::RCP< const crs_graph_type > getCrsGraph() const
This matrix's graph, as a CrsGraph.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
The communicator over which the matrix is distributed.
void reorderedLocalGaussSeidel(const MultiVector< DomainScalar, LocalOrdinal, GlobalOrdinal, Node, classic > &B, MultiVector< RangeScalar, LocalOrdinal, GlobalOrdinal, Node, classic > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &D, const Teuchos::ArrayView< LocalOrdinal > &rowIndices, const RangeScalar &dampingFactor, const KokkosClassic::ESweepDirection direction) const
Reordered Gauss-Seidel or SOR on .
void clearGlobalConstants()
Clear matrix properties that require collectives.
EStorageStatus
Status of the graph's or matrix's storage, when not in a fill-complete state.
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.
virtual void pack(const Teuchos::ArrayView< const LocalOrdinal > &exportLIDs, Teuchos::Array< char > &exports, const Teuchos::ArrayView< size_t > &numPacketsPerLID, size_t &constantNumPackets, Distributor &distor) const
Pack this object's data for an Import or Export.
bool isLocallyIndexed() const
Whether the matrix is locally indexed on the calling process.
local_matrix_type lclMatrix_
The local sparse matrix.
void fillLocalGraphAndMatrix(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Fill data into the local graph and matrix.
GlobalOrdinal getIndexBase() const
The index base for global indices for this matrix.