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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
1539 Kokkos::MemoryUnmanaged>& inputVals,
1541 const bool atomic = useAtomicUpdatesByDefault)
const 1543 using Kokkos::MemoryUnmanaged;
1546 typedef BinaryFunction BF;
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;
2230 const Teuchos::ArrayView<GlobalOrdinal>& Indices,
2231 const Teuchos::ArrayView<Scalar>& Values,
2232 size_t& NumEntries)
const;
2253 const Teuchos::ArrayView<LocalOrdinal>& colInds,
2254 const Teuchos::ArrayView<Scalar>& vals,
2255 size_t& numEntries)
const;
2272 Teuchos::ArrayView<const GlobalOrdinal>& indices,
2273 Teuchos::ArrayView<const Scalar>& values)
const;
2290 Teuchos::ArrayView<const LocalOrdinal>& indices,
2291 Teuchos::ArrayView<const Scalar>& values)
const;
2321 LocalOrdinal& numEnt,
2322 const LocalOrdinal*& lclColInds,
2323 const Scalar*& vals)
const;
2352 LocalOrdinal& numEnt,
2354 const LocalOrdinal*& ind)
const;
2363 template<
class OutputScalarType>
2364 typename std::enable_if<! std::is_same<OutputScalarType, impl_scalar_type>::value &&
2365 std::is_convertible<impl_scalar_type, OutputScalarType>::value,
2368 LocalOrdinal& numEnt,
2369 const OutputScalarType*& val,
2370 const LocalOrdinal*& ind)
const 2373 const LocalOrdinal err = this->
getLocalRowView (lclRow, numEnt, valTmp, ind);
2376 val =
reinterpret_cast<const OutputScalarType*
> (valTmp);
2457 Kokkos::MemoryUnmanaged>& offsets)
const;
2483 const Teuchos::ArrayView<const size_t>& offsets)
const;
2545 template <
class DomainScalar,
class RangeScalar>
2549 Teuchos::ETransp mode,
2551 RangeScalar beta)
const 2553 using Teuchos::NO_TRANS;
2557 typedef typename MultiVector<RangeScalar, LocalOrdinal, GlobalOrdinal,
2559 #ifdef HAVE_TPETRA_DEBUG 2560 const char tfecfFuncName[] =
"localMultiply: ";
2561 #endif // HAVE_TPETRA_DEBUG 2563 const range_impl_scalar_type theAlpha =
static_cast<range_impl_scalar_type
> (alpha);
2564 const range_impl_scalar_type theBeta =
static_cast<range_impl_scalar_type
> (beta);
2565 const bool conjugate = (mode == Teuchos::CONJ_TRANS);
2566 const bool transpose = (mode != Teuchos::NO_TRANS);
2567 auto X_lcl = X.template getLocalView<device_type> ();
2568 auto Y_lcl = Y.template getLocalView<device_type> ();
2570 #ifdef HAVE_TPETRA_DEBUG 2571 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2573 "X.getNumVectors() = " << X.
getNumVectors () <<
" != Y.getNumVectors() = " 2575 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2577 std::runtime_error,
"NO_TRANS case: X has the wrong number of local rows. " 2578 "X.getLocalLength() = " << X.
getLocalLength () <<
" != getColMap()->" 2579 "getNodeNumElements() = " <<
getColMap ()->getNodeNumElements () <<
".");
2580 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2582 std::runtime_error,
"NO_TRANS case: Y has the wrong number of local rows. " 2583 "Y.getLocalLength() = " << Y.
getLocalLength () <<
" != getRowMap()->" 2584 "getNodeNumElements() = " <<
getRowMap ()->getNodeNumElements () <<
".");
2585 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2587 std::runtime_error,
"TRANS or CONJ_TRANS case: X has the wrong number of " 2588 "local rows. X.getLocalLength() = " << X.
getLocalLength () <<
" != " 2589 "getRowMap()->getNodeNumElements() = " 2590 <<
getRowMap ()->getNodeNumElements () <<
".");
2591 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2593 std::runtime_error,
"TRANS or CONJ_TRANS case: X has the wrong number of " 2594 "local rows. Y.getLocalLength() = " << Y.
getLocalLength () <<
" != " 2595 "getColMap()->getNodeNumElements() = " 2596 <<
getColMap ()->getNodeNumElements () <<
".");
2597 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2598 (!
isFillComplete (), std::runtime_error,
"The matrix is not fill " 2599 "complete. You must call fillComplete() (possibly with domain and range " 2600 "Map arguments) without an intervening resumeFill() call before you may " 2601 "call this method.");
2602 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2604 "X and Y must be constant stride.");
2607 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
2608 X_lcl.ptr_on_device () == Y_lcl.ptr_on_device () &&
2609 X_lcl.ptr_on_device () != NULL,
2610 std::runtime_error,
"X and Y may not alias one another.");
2611 #endif // HAVE_TPETRA_DEBUG 2615 KokkosSparse::spmv (conjugate ? KokkosSparse::ConjugateTranspose : KokkosSparse::Transpose,
2618 X.template getLocalView<device_type> (),
2620 Y.template getLocalView<device_type> ());
2623 KokkosSparse::spmv (KokkosSparse::NoTranspose,
2626 X.template getLocalView<device_type> (),
2628 Y.template getLocalView<device_type> ());
2656 template <
class DomainScalar,
class RangeScalar>
2661 const RangeScalar& dampingFactor,
2662 const KokkosClassic::ESweepDirection direction)
const 2664 typedef LocalOrdinal LO;
2665 typedef GlobalOrdinal GO;
2669 typedef typename DMV::dual_view_type::host_mirror_space HMDT ;
2671 typedef typename k_local_graph_type::size_type offset_type;
2672 const char prefix[] =
"Tpetra::CrsMatrix::localGaussSeidel: ";
2674 TEUCHOS_TEST_FOR_EXCEPTION
2676 prefix <<
"The matrix is not fill complete.");
2679 TEUCHOS_TEST_FOR_EXCEPTION
2681 prefix <<
"B.getNumVectors() = " << numVecs <<
" != " 2683 TEUCHOS_TEST_FOR_EXCEPTION
2686 <<
" != this->getNodeNumRows() = " << lclNumRows <<
".");
2688 typename DMV::dual_view_type::t_host B_lcl = B.template getLocalView<HMDT> ();
2689 typename RMV::dual_view_type::t_host X_lcl = X.template getLocalView<HMDT> ();
2690 typename MMV::dual_view_type::t_host D_lcl = D.template getLocalView<HMDT> ();
2692 offset_type B_stride[8], X_stride[8], D_stride[8];
2693 B_lcl.stride (B_stride);
2694 X_lcl.stride (X_stride);
2695 D_lcl.stride (D_stride);
2698 k_local_graph_type lclGraph = lclMatrix.graph;
2699 typename local_matrix_type::row_map_type ptr = lclGraph.row_map;
2700 typename local_matrix_type::index_type ind = lclGraph.entries;
2701 typename local_matrix_type::values_type val = lclMatrix.values;
2702 const offset_type*
const ptrRaw = ptr.ptr_on_device ();
2703 const LO*
const indRaw = ind.ptr_on_device ();
2706 const std::string dir ((direction == KokkosClassic::Forward) ?
"F" :
"B");
2707 KokkosSparse::Impl::Sequential::gaussSeidel (static_cast<LO> (lclNumRows),
2708 static_cast<LO> (numVecs),
2709 ptrRaw, indRaw, valRaw,
2710 B_lcl.ptr_on_device (), B_stride[1],
2711 X_lcl.ptr_on_device (), X_stride[1],
2712 D_lcl.ptr_on_device (),
2743 template <
class DomainScalar,
class RangeScalar>
2748 const Teuchos::ArrayView<LocalOrdinal>& rowIndices,
2749 const RangeScalar& dampingFactor,
2750 const KokkosClassic::ESweepDirection direction)
const 2752 typedef LocalOrdinal LO;
2753 typedef GlobalOrdinal GO;
2757 typedef typename DMV::dual_view_type::host_mirror_space HMDT ;
2759 typedef typename k_local_graph_type::size_type offset_type;
2760 const char prefix[] =
"Tpetra::CrsMatrix::reorderedLocalGaussSeidel: ";
2762 TEUCHOS_TEST_FOR_EXCEPTION
2764 prefix <<
"The matrix is not fill complete.");
2767 TEUCHOS_TEST_FOR_EXCEPTION
2769 prefix <<
"B.getNumVectors() = " << numVecs <<
" != " 2771 TEUCHOS_TEST_FOR_EXCEPTION
2774 <<
" != this->getNodeNumRows() = " << lclNumRows <<
".");
2775 TEUCHOS_TEST_FOR_EXCEPTION
2776 (static_cast<size_t> (rowIndices.size ()) < lclNumRows,
2777 std::invalid_argument, prefix <<
"rowIndices.size() = " 2778 << rowIndices.size () <<
" < this->getNodeNumRows() = " 2779 << lclNumRows <<
".");
2781 typename DMV::dual_view_type::t_host B_lcl = B.template getLocalView<HMDT> ();
2782 typename RMV::dual_view_type::t_host X_lcl = X.template getLocalView<HMDT> ();
2783 typename MMV::dual_view_type::t_host D_lcl = D.template getLocalView<HMDT> ();
2785 offset_type B_stride[8], X_stride[8], D_stride[8];
2786 B_lcl.stride (B_stride);
2787 X_lcl.stride (X_stride);
2788 D_lcl.stride (D_stride);
2792 typename local_matrix_type::index_type ind = lclGraph.entries;
2793 typename local_matrix_type::row_map_type ptr = lclGraph.row_map;
2794 typename local_matrix_type::values_type val = lclMatrix.values;
2795 const offset_type*
const ptrRaw = ptr.ptr_on_device ();
2796 const LO*
const indRaw = ind.ptr_on_device ();
2799 const std::string dir = (direction == KokkosClassic::Forward) ?
"F" :
"B";
2800 KokkosSparse::Impl::Sequential::reorderedGaussSeidel (static_cast<LO> (lclNumRows),
2801 static_cast<LO> (numVecs),
2802 ptrRaw, indRaw, valRaw,
2803 B_lcl.ptr_on_device (),
2805 X_lcl.ptr_on_device (),
2807 D_lcl.ptr_on_device (),
2808 rowIndices.getRawPtr (),
2809 static_cast<LO
> (lclNumRows),
2810 static_cast<impl_scalar_type> (dampingFactor),
2832 template <
class DomainScalar,
class RangeScalar>
2836 Teuchos::ETransp mode)
const 2838 using Teuchos::CONJ_TRANS;
2839 using Teuchos::NO_TRANS;
2840 using Teuchos::TRANS;
2841 const char tfecfFuncName[] =
"localSolve: ";
2843 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2845 "The matrix is not fill complete.");
2846 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2848 "X and Y must be constant stride.");
2850 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2852 "The matrix is neither upper triangular or lower triangular. " 2853 "You may only call this method if the matrix is triangular. " 2854 "Remember that this is a local (per MPI process) property, and that " 2855 "Tpetra only knows how to do a local (per process) triangular solve.");
2857 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2858 (STS::isComplex && mode == TRANS, std::logic_error,
"This method does " 2859 "not currently support non-conjugated transposed solve (mode == " 2860 "Teuchos::TRANS) for complex scalar types.");
2884 const std::string trans = (mode == Teuchos::CONJ_TRANS) ?
"C" :
2885 (mode == Teuchos::TRANS ?
"T" :
"N");
2886 const std::string diag =
2890 X.template modify<device_type> ();
2893 auto X_lcl = X.template getLocalView<device_type> ();
2894 auto Y_lcl = Y.template getLocalView<device_type> ();
2895 KokkosSparse::trsv (uplo.c_str (), trans.c_str (), diag.c_str (),
2896 A_lcl, Y_lcl, X_lcl);
2900 for (
size_t j = 0; j < numVecs; ++j) {
2903 auto X_lcl = X_j->template getLocalView<device_type> ();
2904 auto Y_lcl = Y_j->template getLocalView<device_type> ();
2905 KokkosSparse::trsv (uplo.c_str (), trans.c_str (),
2906 diag.c_str (), A_lcl, Y_lcl, X_lcl);
2914 Teuchos::RCP<CrsMatrix<T, LocalOrdinal, GlobalOrdinal, Node, classic> >
2934 Teuchos::ETransp mode = Teuchos::NO_TRANS,
2935 Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
2936 Scalar beta = Teuchos::ScalarTraits<Scalar>::zero())
const;
2955 Teuchos::RCP<const map_type>
getRangeMap ()
const;
3029 const Scalar& dampingFactor,
3031 const int numSweeps)
const;
3103 const Teuchos::ArrayView<LocalOrdinal>& rowIndices,
3104 const Scalar& dampingFactor,
3106 const int numSweeps)
const;
3140 const Scalar& dampingFactor,
3142 const int numSweeps,
3143 const bool zeroInitialGuess)
const;
3178 const Teuchos::ArrayView<LocalOrdinal>& rowIndices,
3179 const Scalar& dampingFactor,
3181 const int numSweeps,
3182 const bool zeroInitialGuess)
const;
3194 virtual Teuchos::RCP<RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
3195 add (
const Scalar& alpha,
3200 const Teuchos::RCP<Teuchos::ParameterList>& params)
const;
3211 describe (Teuchos::FancyOStream &out,
3212 const Teuchos::EVerbosityLevel verbLevel =
3213 Teuchos::Describable::verbLevel_default)
const;
3225 const Teuchos::ArrayView<const LocalOrdinal>& permuteToLIDs,
3226 const Teuchos::ArrayView<const LocalOrdinal>& permuteFromLIDs);
3230 const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs,
3231 Teuchos::Array<char>& exports,
3232 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
3233 size_t& constantNumPackets,
3240 unpackAndCombineImpl (
const Teuchos::ArrayView<const LocalOrdinal>& importLIDs,
3241 const Teuchos::ArrayView<const char>& imports,
3242 const Teuchos::ArrayView<const size_t>& numPacketsPerLID,
3243 size_t constantNumPackets,
3258 unpackAndCombine (
const Teuchos::ArrayView<const LocalOrdinal> &importLIDs,
3259 const Teuchos::ArrayView<const char> &imports,
3260 const Teuchos::ArrayView<size_t> &numPacketsPerLID,
3261 size_t constantNumPackets,
3386 pack (
const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs,
3387 Teuchos::Array<char>& exports,
3388 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
3389 size_t& constantNumPackets,
3411 packRow (
char*
const numEntOut,
3414 const size_t numEnt,
3415 const LocalOrdinal lclRow)
const;
3440 unpackRow (Scalar*
const valInTmp,
3441 GlobalOrdinal*
const indInTmp,
3442 const size_t tmpNumEnt,
3443 const char*
const valIn,
3444 const char*
const indIn,
3445 const size_t numEnt,
3446 const LocalOrdinal lclRow,
3455 allocatePackSpace (Teuchos::Array<char>& exports,
3456 size_t& totalNumEntries,
3457 const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs)
const;
3468 template<
class CrsMatrixType>
3469 friend Teuchos::RCP<CrsMatrixType>
3471 const Import<
typename CrsMatrixType::local_ordinal_type,
3472 typename CrsMatrixType::global_ordinal_type,
3473 typename CrsMatrixType::node_type>& importer,
3474 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3475 typename CrsMatrixType::global_ordinal_type,
3476 typename CrsMatrixType::node_type> >& domainMap,
3477 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3478 typename CrsMatrixType::global_ordinal_type,
3479 typename CrsMatrixType::node_type> >& rangeMap,
3480 const Teuchos::RCP<Teuchos::ParameterList>& params);
3483 template<
class CrsMatrixType>
3484 friend Teuchos::RCP<CrsMatrixType>
3486 const Import<
typename CrsMatrixType::local_ordinal_type,
3487 typename CrsMatrixType::global_ordinal_type,
3488 typename CrsMatrixType::node_type>& rowImporter,
3489 const Import<
typename CrsMatrixType::local_ordinal_type,
3490 typename CrsMatrixType::global_ordinal_type,
3491 typename CrsMatrixType::node_type>& domainImporter,
3492 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3493 typename CrsMatrixType::global_ordinal_type,
3494 typename CrsMatrixType::node_type> >& domainMap,
3495 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3496 typename CrsMatrixType::global_ordinal_type,
3497 typename CrsMatrixType::node_type> >& rangeMap,
3498 const Teuchos::RCP<Teuchos::ParameterList>& params);
3502 template<
class CrsMatrixType>
3503 friend Teuchos::RCP<CrsMatrixType>
3505 const Export<
typename CrsMatrixType::local_ordinal_type,
3506 typename CrsMatrixType::global_ordinal_type,
3507 typename CrsMatrixType::node_type>& exporter,
3508 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3509 typename CrsMatrixType::global_ordinal_type,
3510 typename CrsMatrixType::node_type> >& domainMap,
3511 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3512 typename CrsMatrixType::global_ordinal_type,
3513 typename CrsMatrixType::node_type> >& rangeMap,
3514 const Teuchos::RCP<Teuchos::ParameterList>& params);
3517 template<
class CrsMatrixType>
3518 friend Teuchos::RCP<CrsMatrixType>
3520 const Export<
typename CrsMatrixType::local_ordinal_type,
3521 typename CrsMatrixType::global_ordinal_type,
3522 typename CrsMatrixType::node_type>& rowExporter,
3523 const Export<
typename CrsMatrixType::local_ordinal_type,
3524 typename CrsMatrixType::global_ordinal_type,
3525 typename CrsMatrixType::node_type>& domainExporter,
3526 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3527 typename CrsMatrixType::global_ordinal_type,
3528 typename CrsMatrixType::node_type> >& domainMap,
3529 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3530 typename CrsMatrixType::global_ordinal_type,
3531 typename CrsMatrixType::node_type> >& rangeMap,
3532 const Teuchos::RCP<Teuchos::ParameterList>& params);
3553 const Teuchos::RCP<const map_type>& domainMap,
3554 const Teuchos::RCP<const map_type>& rangeMap,
3555 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
3576 const Teuchos::RCP<const map_type>& domainMap,
3577 const Teuchos::RCP<const map_type>& rangeMap,
3578 const Teuchos::RCP<Teuchos::ParameterList>& params)
const;
3599 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
3600 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
3601 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
3622 const Teuchos::RCP<const map_type>& domainMap,
3623 const Teuchos::RCP<const map_type>& rangeMap,
3624 const Teuchos::RCP<Teuchos::ParameterList>& params)
const;
3650 const ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node>& rowTransfer,
3651 const Teuchos::RCP<const ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node> > & domainTransfer,
3652 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
3653 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
3654 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
3674 insertGlobalValuesFiltered (
const GlobalOrdinal globalRow,
3675 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3676 const Teuchos::ArrayView<const Scalar>& values);
3688 insertLocalValuesFiltered (
const LocalOrdinal localRow,
3689 const Teuchos::ArrayView<const LocalOrdinal>& indices,
3690 const Teuchos::ArrayView<const Scalar>& values);
3704 combineGlobalValues (
const GlobalOrdinal globalRowIndex,
3705 const Teuchos::ArrayView<const GlobalOrdinal>& columnIndices,
3706 const Teuchos::ArrayView<const Scalar>& values,
3720 template<
class BinaryFunction>
3723 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3724 const Teuchos::ArrayView<const Scalar>& values,
3726 const bool atomic = useAtomicUpdatesByDefault)
const 3728 using Kokkos::MemoryUnmanaged;
3731 typedef BinaryFunction BF;
3732 typedef GlobalOrdinal GO;
3734 typedef typename View<GO*, DD>::HostMirror::device_type HD;
3738 const ST*
const rawInputVals =
3739 reinterpret_cast<const ST*
> (values.getRawPtr ());
3740 View<const ST*, HD, MemoryUnmanaged> inputValsK (rawInputVals,
3742 View<const GO*, HD, MemoryUnmanaged> inputIndsK (indices.getRawPtr (),
3744 return this->
template transformGlobalValues<BF, HD> (globalRow,
3758 insertNonownedGlobalValues (
const GlobalOrdinal globalRow,
3759 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3760 const Teuchos::ArrayView<const Scalar>& values);
3763 typedef DistObject<char, LocalOrdinal, GlobalOrdinal, Node, classic> dist_object_type;
3767 typedef Teuchos::OrdinalTraits<LocalOrdinal> OTL;
3768 typedef Kokkos::Details::ArithTraits<impl_scalar_type> STS;
3769 typedef Kokkos::Details::ArithTraits<mag_type> STM;
3770 typedef MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> MV;
3771 typedef Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> V;
3775 enum GraphAllocationStatus {
3776 GraphAlreadyAllocated,
3777 GraphNotYetAllocated
3796 void allocateValues (ELocalGlobal lg, GraphAllocationStatus gas);
3880 const bool force =
false)
const;
3905 const bool force =
false)
const;
3918 const Teuchos::ETransp mode,
3944 LocalOrdinal& numEnt,
3945 const RowInfo& rowinfo)
const;
3967 LocalOrdinal& numEnt,
3968 const RowInfo& rowinfo)
const;
3977 Teuchos::ArrayView<const impl_scalar_type>
getView (
RowInfo rowinfo)
const;
4000 Kokkos::View<const impl_scalar_type*, execution_space, Kokkos::MemoryUnmanaged>
4001 getRowView (
const RowInfo& rowInfo)
const;
4014 Kokkos::View<impl_scalar_type*, execution_space, Kokkos::MemoryUnmanaged>
4015 getRowViewNonConst (
const RowInfo& rowInfo)
const;
4024 void fillLocalMatrix (
const Teuchos::RCP<Teuchos::ParameterList>& params);
4048 Teuchos::RCP<const Graph> staticGraph_;
4049 Teuchos::RCP< Graph> myGraph_;
4068 typename local_matrix_type::values_type k_values1D_;
4069 Teuchos::ArrayRCP<Teuchos::Array<impl_scalar_type> > values2D_;
4113 std::map<GlobalOrdinal, std::pair<Teuchos::Array<GlobalOrdinal>,
4128 template<
class ViewType,
class OffsetViewType>
4129 struct pack_functor {
4133 OffsetViewType src_offset_;
4134 OffsetViewType dst_offset_;
4135 typedef typename OffsetViewType::non_const_value_type scalar_index_type;
4137 pack_functor (ViewType dst, ViewType src,
4138 OffsetViewType dst_offset, OffsetViewType src_offset) :
4141 src_offset_ (src_offset),
4142 dst_offset_ (dst_offset)
4145 KOKKOS_INLINE_FUNCTION
4146 void operator () (
const LocalOrdinal row)
const {
4147 scalar_index_type srcPos = src_offset_(row);
4148 const scalar_index_type dstEnd = dst_offset_(row+1);
4149 scalar_index_type dstPos = dst_offset_(row);
4150 for ( ; dstPos < dstEnd; ++dstPos, ++srcPos) {
4151 dst_(dstPos) = src_(srcPos);
4166 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node, const
bool classic = Node::
classic>
4167 Teuchos::RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
4169 size_t maxNumEntriesPerRow = 0,
4170 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
4173 return Teuchos::rcp (
new matrix_type (map, maxNumEntriesPerRow,
4228 template<
class CrsMatrixType>
4229 Teuchos::RCP<CrsMatrixType>
4231 const Import<
typename CrsMatrixType::local_ordinal_type,
4232 typename CrsMatrixType::global_ordinal_type,
4233 typename CrsMatrixType::node_type>& importer,
4234 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4235 typename CrsMatrixType::global_ordinal_type,
4236 typename CrsMatrixType::node_type> >& domainMap = Teuchos::null,
4237 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4238 typename CrsMatrixType::global_ordinal_type,
4239 typename CrsMatrixType::node_type> >& rangeMap = Teuchos::null,
4240 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
4242 Teuchos::RCP<CrsMatrixType> destMatrix;
4243 sourceMatrix->importAndFillComplete (destMatrix,importer,domainMap, rangeMap, params);
4300 template<
class CrsMatrixType>
4301 Teuchos::RCP<CrsMatrixType>
4303 const Import<
typename CrsMatrixType::local_ordinal_type,
4304 typename CrsMatrixType::global_ordinal_type,
4305 typename CrsMatrixType::node_type>& rowImporter,
4306 const Import<
typename CrsMatrixType::local_ordinal_type,
4307 typename CrsMatrixType::global_ordinal_type,
4308 typename CrsMatrixType::node_type>& domainImporter,
4309 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4310 typename CrsMatrixType::global_ordinal_type,
4311 typename CrsMatrixType::node_type> >& domainMap,
4312 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4313 typename CrsMatrixType::global_ordinal_type,
4314 typename CrsMatrixType::node_type> >& rangeMap,
4315 const Teuchos::RCP<Teuchos::ParameterList>& params)
4317 Teuchos::RCP<CrsMatrixType> destMatrix;
4318 sourceMatrix->importAndFillComplete (destMatrix,rowImporter,domainImporter, domainMap, rangeMap, params);
4355 template<
class CrsMatrixType>
4356 Teuchos::RCP<CrsMatrixType>
4358 const Export<
typename CrsMatrixType::local_ordinal_type,
4359 typename CrsMatrixType::global_ordinal_type,
4360 typename CrsMatrixType::node_type>& exporter,
4361 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4362 typename CrsMatrixType::global_ordinal_type,
4363 typename CrsMatrixType::node_type> >& domainMap = Teuchos::null,
4364 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4365 typename CrsMatrixType::global_ordinal_type,
4366 typename CrsMatrixType::node_type> >& rangeMap = Teuchos::null,
4367 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
4369 Teuchos::RCP<CrsMatrixType> destMatrix;
4370 sourceMatrix->exportAndFillComplete (destMatrix,exporter,domainMap, rangeMap, params);
4407 template<
class CrsMatrixType>
4408 Teuchos::RCP<CrsMatrixType>
4410 const Export<
typename CrsMatrixType::local_ordinal_type,
4411 typename CrsMatrixType::global_ordinal_type,
4412 typename CrsMatrixType::node_type>& rowExporter,
4413 const Export<
typename CrsMatrixType::local_ordinal_type,
4414 typename CrsMatrixType::global_ordinal_type,
4415 typename CrsMatrixType::node_type>& domainExporter,
4416 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4417 typename CrsMatrixType::global_ordinal_type,
4418 typename CrsMatrixType::node_type> >& domainMap,
4419 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4420 typename CrsMatrixType::global_ordinal_type,
4421 typename CrsMatrixType::node_type> >& rangeMap,
4422 const Teuchos::RCP<Teuchos::ParameterList>& params)
4424 Teuchos::RCP<CrsMatrixType> destMatrix;
4425 sourceMatrix->exportAndFillComplete (destMatrix,rowExporter,domainExporter,domainMap, rangeMap, params);
4437 #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...
Kokkos::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...
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.
void sortEntries()
Sort the entries of each row by their column indices.
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 mergeRedundantEntries()
Merge entries in each row with the same column 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 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.
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.
Describes a parallel distribution of objects over processes.
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.
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().
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.
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< 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.