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" 60 #include "KokkosCompat_ClassicNodeAPI_Wrapper.hpp" 64 #include "Kokkos_Sparse.hpp" 69 #include "Kokkos_Sparse_impl_sor.hpp" 187 class GlobalOrdinal = 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 = 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<ParameterList>& params = 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 = 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 = null)
const 511 using Teuchos::ArrayRCP;
513 using Teuchos::ParameterList;
516 using Teuchos::sublist;
519 const char tfecfFuncName[] =
"clone";
522 bool fillCompleteClone =
true;
523 bool useLocalIndices = this->
hasColMap ();
525 if (! params.is_null ()) {
526 fillCompleteClone = params->get (
"fillComplete clone", fillCompleteClone);
527 useLocalIndices = params->get (
"Locally indexed clone", useLocalIndices);
529 bool staticProfileClone =
true;
530 staticProfileClone = params->get (
"Static profile clone", staticProfileClone);
534 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
535 ! this->
hasColMap () && useLocalIndices, std::runtime_error,
536 ": You requested that the returned clone have local indices, but the " 537 "the source matrix does not have a column Map yet.");
539 RCP<const Map2> clonedRowMap = this->
getRowMap ()->template clone<Node2> (node2);
542 RCP<CrsMatrix2> clonedMatrix;
543 ArrayRCP<const size_t> numEntriesPerRow;
544 size_t numEntriesForAll = 0;
545 bool boundSameForAllLocalRows =
false;
546 staticGraph_->getNumEntriesPerLocalRowUpperBound (numEntriesPerRow,
548 boundSameForAllLocalRows);
549 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
550 numEntriesForAll != 0 &&
551 static_cast<size_t> (numEntriesPerRow.size ()) != 0,
552 std::logic_error,
": getNumEntriesPerLocalRowUpperBound returned a " 553 "nonzero numEntriesForAll = " << numEntriesForAll <<
" , as well as a " 554 "numEntriesPerRow array of nonzero length " << numEntriesPerRow.size ()
555 <<
". This should never happen. Please report this bug to the Tpetra " 557 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
558 numEntriesForAll != 0 && ! boundSameForAllLocalRows,
559 std::logic_error,
": getNumEntriesPerLocalRowUpperBound returned a " 560 "nonzero numEntriesForAll = " << numEntriesForAll <<
" , but claims " 561 "(via its third output value) that the upper bound is not the same for " 562 "all rows. This should never happen. Please report this bug to the " 563 "Tpetra developers.");
564 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
565 numEntriesPerRow.size () != 0 && boundSameForAllLocalRows,
566 std::logic_error,
": getNumEntriesPerLocalRowUpperBound returned a " 567 "numEntriesPerRow array of nonzero length " << numEntriesPerRow.size ()
568 <<
", but claims (via its third output value) that the upper bound is " 569 "not the same for all rows. This should never happen. Please report " 570 "this bug to the Tpetra developers.");
572 RCP<ParameterList> matParams =
573 params.is_null () ? null : sublist (params,
"CrsMatrix");
574 if (useLocalIndices) {
575 RCP<const Map2> clonedColMap =
576 this->
getColMap ()->template clone<Node2> (node2);
577 if (numEntriesPerRow.is_null ()) {
578 clonedMatrix = rcp (
new CrsMatrix2 (clonedRowMap, clonedColMap,
579 numEntriesForAll, pftype,
583 clonedMatrix = rcp (
new CrsMatrix2 (clonedRowMap, clonedColMap,
584 numEntriesPerRow, pftype,
589 if (numEntriesPerRow.is_null ()) {
590 clonedMatrix = rcp (
new CrsMatrix2 (clonedRowMap, numEntriesForAll,
594 clonedMatrix = rcp (
new CrsMatrix2 (clonedRowMap, numEntriesPerRow,
599 numEntriesPerRow = Teuchos::null;
600 numEntriesForAll = 0;
602 if (useLocalIndices) {
603 clonedMatrix->allocateValues (LocalIndices,
604 CrsMatrix2::GraphNotYetAllocated);
606 ArrayView<const LocalOrdinal> linds;
607 ArrayView<const Scalar> vals;
608 for (LocalOrdinal lrow = clonedRowMap->getMinLocalIndex ();
609 lrow <= clonedRowMap->getMaxLocalIndex ();
613 clonedMatrix->insertLocalValues (lrow, linds, vals);
618 Array<LocalOrdinal> linds;
620 for (LocalOrdinal lrow = clonedRowMap->getMinLocalIndex ();
621 lrow <= clonedRowMap->getMaxLocalIndex ();
624 if (theNumEntries > static_cast<size_t> (linds.size ())) {
625 linds.resize (theNumEntries);
627 if (theNumEntries > static_cast<size_t> (vals.size ())) {
628 vals.resize (theNumEntries);
631 linds (), vals (), theNumEntries);
632 if (theNumEntries != 0) {
633 clonedMatrix->insertLocalValues (lrow, linds (0, theNumEntries),
634 vals (0, theNumEntries));
640 clonedMatrix->allocateValues (GlobalIndices,
641 CrsMatrix2::GraphNotYetAllocated);
643 ArrayView<const GlobalOrdinal> ginds;
644 ArrayView<const Scalar> vals;
645 for (GlobalOrdinal grow = clonedRowMap->getMinGlobalIndex ();
646 grow <= clonedRowMap->getMaxGlobalIndex ();
649 if (ginds.size () > 0) {
650 clonedMatrix->insertGlobalValues (grow, ginds, vals);
655 Array<GlobalOrdinal> ginds;
657 for (GlobalOrdinal grow = clonedRowMap->getMinGlobalIndex ();
658 grow <= clonedRowMap->getMaxGlobalIndex ();
661 if (theNumEntries > static_cast<size_t> (ginds.size ())) {
662 ginds.resize (theNumEntries);
664 if (theNumEntries > static_cast<size_t> (vals.size ())) {
665 vals.resize (theNumEntries);
668 if (theNumEntries != 0) {
669 clonedMatrix->insertGlobalValues (grow, ginds (0, theNumEntries),
670 vals (0, theNumEntries));
676 if (fillCompleteClone) {
677 RCP<const Map2> clonedRangeMap;
678 RCP<const Map2> clonedDomainMap;
682 clonedRangeMap = this->
getRangeMap ()->template clone<Node2> (node2);
685 clonedRangeMap = clonedRowMap;
689 clonedDomainMap = this->
getDomainMap ()->template clone<Node2> (node2);
692 clonedDomainMap = clonedRowMap;
695 catch (std::exception &e) {
696 const bool caughtExceptionOnClone =
true;
697 TEUCHOS_TEST_FOR_EXCEPTION
698 (caughtExceptionOnClone, std::runtime_error,
699 Teuchos::typeName (*
this) <<
"::clone: Caught the following " 700 "exception while cloning range and domain Maps on a clone of " 701 "type " << Teuchos::typeName (*clonedMatrix) <<
": " << e.what ());
704 RCP<ParameterList> fillparams =
705 params.is_null () ? Teuchos::null : sublist (params,
"fillComplete");
707 clonedMatrix->fillComplete (clonedDomainMap, clonedRangeMap,
710 catch (std::exception &e) {
711 const bool caughtExceptionOnClone =
true;
712 TEUCHOS_TEST_FOR_EXCEPTION(
713 caughtExceptionOnClone, std::runtime_error,
714 Teuchos::typeName (*
this) <<
"::clone: Caught the following " 715 "exception while calling fillComplete() on a clone of type " 716 << Teuchos::typeName (*clonedMatrix) <<
": " << e.what ());
799 const Teuchos::ArrayView<const GlobalOrdinal>& cols,
800 const Teuchos::ArrayView<const Scalar>& vals);
843 const ArrayView<const LocalOrdinal> &cols,
844 const ArrayView<const Scalar> &vals);
882 const ArrayView<const GlobalOrdinal>& cols,
883 const ArrayView<const Scalar>& vals);
917 const ArrayView<const LocalOrdinal>& cols,
918 const ArrayView<const Scalar>& vals);
954 const ArrayView<const GlobalOrdinal> &cols,
955 const ArrayView<const Scalar> &vals);
973 const ArrayView<const LocalOrdinal>& cols,
974 const ArrayView<const Scalar>& vals);
980 void scale (
const Scalar &alpha);
991 setAllValues (
const typename local_matrix_type::row_map_type& rowPointers,
992 const typename local_graph_type::entries_type::non_const_type& columnIndices,
993 const typename local_matrix_type::values_type& values);
1008 setAllValues (
const Teuchos::ArrayRCP<size_t>& rowPointers,
1009 const Teuchos::ArrayRCP<LocalOrdinal>& columnIndices,
1010 const Teuchos::ArrayRCP<Scalar>& values);
1013 getAllValues (Teuchos::ArrayRCP<const size_t>& rowPointers,
1014 Teuchos::ArrayRCP<const LocalOrdinal>& columnIndices,
1015 Teuchos::ArrayRCP<const Scalar>& values)
const;
1064 void resumeFill (
const RCP<ParameterList>& params = null);
1101 const RCP<const map_type>& rangeMap,
1102 const RCP<ParameterList>& params = null);
1116 void fillComplete (
const RCP<ParameterList>& params = null);
1131 const RCP<const map_type>& rangeMap,
1132 const RCP<const import_type>& importer = Teuchos::null,
1133 const RCP<const export_type>& exporter = Teuchos::null,
1134 const RCP<ParameterList>& params = Teuchos::null);
1146 replaceColMap (
const Teuchos::RCP<const map_type>& newColMap);
1231 const Teuchos::RCP<const map_type>& newColMap,
1232 const Teuchos::RCP<const import_type>& newImport = Teuchos::null,
1233 const bool sortEachRow =
true);
1249 Teuchos::RCP<const import_type>& newImporter);
1272 Teuchos::RCP<const Teuchos::Comm<int> >
getComm()
const;
1275 Teuchos::RCP<node_type>
getNode ()
const;
1278 Teuchos::RCP<const map_type>
getRowMap ()
const;
1281 Teuchos::RCP<const map_type>
getColMap ()
const;
1284 Teuchos::RCP<const RowGraph<LocalOrdinal, GlobalOrdinal, Node> >
getGraph ()
const;
1287 Teuchos::RCP<const crs_graph_type>
getCrsGraph ()
const;
1555 const Teuchos::ArrayView<GlobalOrdinal>& Indices,
1556 const Teuchos::ArrayView<Scalar>& Values,
1557 size_t& NumEntries)
const;
1578 const Teuchos::ArrayView<LocalOrdinal>& colInds,
1579 const Teuchos::ArrayView<Scalar>& vals,
1580 size_t& numEntries)
const;
1597 Teuchos::ArrayView<const GlobalOrdinal>& indices,
1598 Teuchos::ArrayView<const Scalar>& values)
const;
1615 Teuchos::ArrayView<const LocalOrdinal>& indices,
1616 Teuchos::ArrayView<const Scalar>& values)
const;
1684 const Teuchos::ArrayView<const size_t>& offsets)
const;
1748 template <
class DomainScalar,
class RangeScalar>
1752 Teuchos::ETransp mode,
1754 RangeScalar beta)
const 1756 using Teuchos::NO_TRANS;
1760 typedef typename MultiVector<RangeScalar, LocalOrdinal, GlobalOrdinal,
1762 #ifdef HAVE_TPETRA_DEBUG 1763 const char tfecfFuncName[] =
"localMultiply: ";
1764 #endif // HAVE_TPETRA_DEBUG 1766 const range_impl_scalar_type theAlpha =
static_cast<range_impl_scalar_type
> (alpha);
1767 const range_impl_scalar_type theBeta =
static_cast<range_impl_scalar_type
> (beta);
1768 const bool conjugate = (mode == Teuchos::CONJ_TRANS);
1769 const bool transpose = (mode != Teuchos::NO_TRANS);
1771 #ifdef HAVE_TPETRA_DEBUG 1772 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
1774 "X.getNumVectors() = " << X.
getNumVectors () <<
" != Y.getNumVectors() = " 1776 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
1778 std::runtime_error,
"NO_TRANS case: X has the wrong number of local rows. " 1779 "X.getLocalLength() = " << X.
getLocalLength () <<
" != getColMap()->" 1780 "getNodeNumElements() = " <<
getColMap ()->getNodeNumElements () <<
".");
1781 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
1783 std::runtime_error,
"NO_TRANS case: Y has the wrong number of local rows. " 1784 "Y.getLocalLength() = " << Y.
getLocalLength () <<
" != getRowMap()->" 1785 "getNodeNumElements() = " <<
getRowMap ()->getNodeNumElements () <<
".");
1786 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
1788 std::runtime_error,
"TRANS or CONJ_TRANS case: X has the wrong number of " 1789 "local rows. X.getLocalLength() = " << X.
getLocalLength () <<
" != " 1790 "getRowMap()->getNodeNumElements() = " 1791 <<
getRowMap ()->getNodeNumElements () <<
".");
1792 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
1794 std::runtime_error,
"TRANS or CONJ_TRANS case: X has the wrong number of " 1795 "local rows. Y.getLocalLength() = " << Y.
getLocalLength () <<
" != " 1796 "getColMap()->getNodeNumElements() = " 1797 <<
getColMap ()->getNodeNumElements () <<
".");
1798 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
1799 (! isFillComplete (), std::runtime_error,
"The matrix is not fill " 1800 "complete. You must call fillComplete() (possibly with domain and range " 1801 "Map arguments) without an intervening resumeFill() call before you may " 1802 "call this method.");
1803 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
1805 "X and Y must be constant stride.");
1808 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
1811 std::runtime_error,
"X and Y may not alias one another.");
1812 #endif // HAVE_TPETRA_DEBUG 1816 KokkosSparse::spmv (conjugate ? KokkosSparse::ConjugateTranspose : KokkosSparse::Transpose,
1819 X.template getLocalView<device_type> (),
1821 Y.template getLocalView<device_type> ());
1824 KokkosSparse::spmv (KokkosSparse::NoTranspose,
1827 X.template getLocalView<device_type> (),
1829 Y.template getLocalView<device_type> ());
1857 template <
class DomainScalar,
class RangeScalar>
1862 const RangeScalar& dampingFactor,
1863 const KokkosClassic::ESweepDirection direction)
const 1865 typedef LocalOrdinal LO;
1866 typedef GlobalOrdinal GO;
1870 typedef typename DMV::dual_view_type::host_mirror_space HMDT ;
1872 typedef typename k_local_graph_type::size_type offset_type;
1873 const char prefix[] =
"Tpetra::CrsMatrix::localGaussSeidel: ";
1875 TEUCHOS_TEST_FOR_EXCEPTION
1876 (! this->isFillComplete (), std::runtime_error,
1877 prefix <<
"The matrix is not fill complete.");
1880 TEUCHOS_TEST_FOR_EXCEPTION
1882 prefix <<
"B.getNumVectors() = " << numVecs <<
" != " 1884 TEUCHOS_TEST_FOR_EXCEPTION
1887 <<
" != this->getNodeNumRows() = " << lclNumRows <<
".");
1889 typename DMV::dual_view_type::t_host B_lcl = B.template getLocalView<HMDT> ();
1890 typename RMV::dual_view_type::t_host X_lcl = X.template getLocalView<HMDT> ();
1891 typename MMV::dual_view_type::t_host D_lcl = D.template getLocalView<HMDT> ();
1893 offset_type B_stride[8], X_stride[8], D_stride[8];
1894 B_lcl.stride (B_stride);
1895 X_lcl.stride (X_stride);
1896 D_lcl.stride (D_stride);
1899 k_local_graph_type lclGraph = lclMatrix.graph;
1900 typename local_matrix_type::row_map_type ptr = lclGraph.row_map;
1901 typename local_matrix_type::index_type ind = lclGraph.entries;
1902 typename local_matrix_type::values_type val = lclMatrix.values;
1903 const offset_type*
const ptrRaw = ptr.ptr_on_device ();
1904 const LO*
const indRaw = ind.ptr_on_device ();
1905 const impl_scalar_type*
const valRaw = val.ptr_on_device ();
1907 const std::string dir ((direction == KokkosClassic::Forward) ?
"F" :
"B");
1908 KokkosSparse::Impl::Sequential::gaussSeidel (static_cast<LO> (lclNumRows),
1909 static_cast<LO> (numVecs),
1910 ptrRaw, indRaw, valRaw,
1911 B_lcl.ptr_on_device (), B_stride[1],
1912 X_lcl.ptr_on_device (), X_stride[1],
1913 D_lcl.ptr_on_device (),
1914 static_cast<impl_scalar_type
> (dampingFactor),
1944 template <
class DomainScalar,
class RangeScalar>
1949 const Teuchos::ArrayView<LocalOrdinal>& rowIndices,
1950 const RangeScalar& dampingFactor,
1951 const KokkosClassic::ESweepDirection direction)
const 1953 typedef LocalOrdinal LO;
1954 typedef GlobalOrdinal GO;
1958 typedef typename DMV::dual_view_type::host_mirror_space HMDT ;
1960 typedef typename k_local_graph_type::size_type offset_type;
1961 const char prefix[] =
"Tpetra::CrsMatrix::reorderedLocalGaussSeidel: ";
1963 TEUCHOS_TEST_FOR_EXCEPTION
1964 (! this->isFillComplete (), std::runtime_error,
1965 prefix <<
"The matrix is not fill complete.");
1968 TEUCHOS_TEST_FOR_EXCEPTION
1970 prefix <<
"B.getNumVectors() = " << numVecs <<
" != " 1972 TEUCHOS_TEST_FOR_EXCEPTION
1975 <<
" != this->getNodeNumRows() = " << lclNumRows <<
".");
1976 TEUCHOS_TEST_FOR_EXCEPTION
1977 (static_cast<size_t> (rowIndices.size ()) < lclNumRows,
1978 std::invalid_argument, prefix <<
"rowIndices.size() = " 1979 << rowIndices.size () <<
" < this->getNodeNumRows() = " 1980 << lclNumRows <<
".");
1982 typename DMV::dual_view_type::t_host B_lcl = B.template getLocalView<HMDT> ();
1983 typename RMV::dual_view_type::t_host X_lcl = X.template getLocalView<HMDT> ();
1984 typename MMV::dual_view_type::t_host D_lcl = D.template getLocalView<HMDT> ();
1986 offset_type B_stride[8], X_stride[8], D_stride[8];
1987 B_lcl.stride (B_stride);
1988 X_lcl.stride (X_stride);
1989 D_lcl.stride (D_stride);
1993 typename local_matrix_type::index_type ind = lclGraph.entries;
1994 typename local_matrix_type::row_map_type ptr = lclGraph.row_map;
1995 typename local_matrix_type::values_type val = lclMatrix.values;
1996 const offset_type*
const ptrRaw = ptr.ptr_on_device ();
1997 const LO*
const indRaw = ind.ptr_on_device ();
1998 const impl_scalar_type*
const valRaw = val.ptr_on_device ();
2000 const std::string dir = (direction == KokkosClassic::Forward) ?
"F" :
"B";
2001 KokkosSparse::Impl::Sequential::reorderedGaussSeidel (static_cast<LO> (lclNumRows),
2002 static_cast<LO> (numVecs),
2003 ptrRaw, indRaw, valRaw,
2004 B_lcl.ptr_on_device (),
2006 X_lcl.ptr_on_device (),
2008 D_lcl.ptr_on_device (),
2009 rowIndices.getRawPtr (),
2010 static_cast<LO
> (lclNumRows),
2011 static_cast<impl_scalar_type> (dampingFactor),
2033 template <
class DomainScalar,
class RangeScalar>
2037 Teuchos::ETransp mode)
const 2039 using Teuchos::CONJ_TRANS;
2040 using Teuchos::NO_TRANS;
2041 using Teuchos::TRANS;
2042 typedef LocalOrdinal LO;
2043 typedef GlobalOrdinal GO;
2046 typedef typename DMV::dual_view_type::host_mirror_space HMDT ;
2048 const char tfecfFuncName[] =
"localSolve: ";
2050 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2051 (! isFillComplete (), std::runtime_error,
2052 "The matrix is not fill complete.");
2053 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2055 "X and Y must be constant stride.");
2056 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2057 (! isUpperTriangular () && ! isLowerTriangular (), std::runtime_error,
2058 "The matrix is neither upper triangular or lower triangular. " 2059 "You may only call this method if the matrix is triangular. " 2060 "Remember that this is a local (per MPI process) property, and that " 2061 "Tpetra only knows how to do a local (per process) triangular solve.");
2062 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
2063 (STS::isComplex && mode == TRANS, std::logic_error,
"This method does " 2064 "not currently support non-conjugated transposed solve (mode == " 2065 "Teuchos::TRANS) for complex scalar types.");
2082 const std::string trans = (mode == Teuchos::CONJ_TRANS) ?
"C" :
2083 (mode == Teuchos::TRANS ?
"T" :
"N");
2084 const std::string diag =
2097 typename DMV::dual_view_type::t_host X_lcl = X.template getLocalView<HMDT> ();
2098 typename RMV::dual_view_type::t_host Y_lcl = Y.template getLocalView<HMDT> ();
2099 KokkosSparse::trsv (uplo.c_str (), trans.c_str (), diag.c_str (), A_lcl, Y_lcl, X_lcl);
2103 for (
size_t j = 0; j < numVecs; ++j) {
2106 auto X_lcl = X_j->template getLocalView<HMDT> ();
2107 auto Y_lcl = Y_j->template getLocalView<HMDT> ();
2108 KokkosSparse::trsv (uplo.c_str (), trans.c_str (), diag.c_str (), A_lcl, Y_lcl, X_lcl);
2116 Teuchos::RCP<CrsMatrix<T, LocalOrdinal, GlobalOrdinal, Node, classic> >
2136 Teuchos::ETransp mode = Teuchos::NO_TRANS,
2137 Scalar alpha = ScalarTraits<Scalar>::one(),
2138 Scalar beta = ScalarTraits<Scalar>::zero())
const;
2157 Teuchos::RCP<const map_type>
getRangeMap ()
const;
2231 const Scalar& dampingFactor,
2233 const int numSweeps)
const;
2305 const Teuchos::ArrayView<LocalOrdinal>& rowIndices,
2306 const Scalar& dampingFactor,
2308 const int numSweeps)
const;
2342 const Scalar& dampingFactor,
2344 const int numSweeps,
2345 const bool zeroInitialGuess)
const;
2380 const Teuchos::ArrayView<LocalOrdinal>& rowIndices,
2381 const Scalar& dampingFactor,
2383 const int numSweeps,
2384 const bool zeroInitialGuess)
const;
2396 virtual Teuchos::RCP<RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
2397 add (
const Scalar& alpha,
2402 const Teuchos::RCP<Teuchos::ParameterList>& params)
const;
2413 describe (Teuchos::FancyOStream &out,
2414 const Teuchos::EVerbosityLevel verbLevel =
2415 Teuchos::Describable::verbLevel_default)
const;
2427 const Teuchos::ArrayView<const LocalOrdinal>& permuteToLIDs,
2428 const Teuchos::ArrayView<const LocalOrdinal>& permuteFromLIDs);
2432 const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs,
2433 Teuchos::Array<char>& exports,
2434 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
2435 size_t& constantNumPackets,
2442 unpackAndCombineImpl (
const Teuchos::ArrayView<const LocalOrdinal> &importLIDs,
2443 const Teuchos::ArrayView<const char> &imports,
2444 const Teuchos::ArrayView<size_t> &numPacketsPerLID,
2445 size_t constantNumPackets,
2460 unpackAndCombine (
const Teuchos::ArrayView<const LocalOrdinal> &importLIDs,
2461 const Teuchos::ArrayView<const char> &imports,
2462 const Teuchos::ArrayView<size_t> &numPacketsPerLID,
2463 size_t constantNumPackets,
2588 pack (
const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs,
2589 Teuchos::Array<char>& exports,
2590 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
2591 size_t& constantNumPackets,
2613 packRow (
char*
const numEntOut,
2616 const size_t numEnt,
2617 const LocalOrdinal lclRow)
const;
2642 unpackRow (Scalar*
const valInTmp,
2643 GlobalOrdinal*
const indInTmp,
2644 const size_t tmpNumEnt,
2645 const char*
const valIn,
2646 const char*
const indIn,
2647 const size_t numEnt,
2648 const LocalOrdinal lclRow,
2657 allocatePackSpace (Teuchos::Array<char>& exports,
2658 size_t& totalNumEntries,
2659 const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs)
const;
2670 template<
class CrsMatrixType>
2671 friend Teuchos::RCP<CrsMatrixType>
2673 const Import<
typename CrsMatrixType::local_ordinal_type,
2674 typename CrsMatrixType::global_ordinal_type,
2675 typename CrsMatrixType::node_type>& importer,
2676 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
2677 typename CrsMatrixType::global_ordinal_type,
2678 typename CrsMatrixType::node_type> >& domainMap,
2679 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
2680 typename CrsMatrixType::global_ordinal_type,
2681 typename CrsMatrixType::node_type> >& rangeMap,
2682 const Teuchos::RCP<Teuchos::ParameterList>& params);
2685 template<
class CrsMatrixType>
2686 friend Teuchos::RCP<CrsMatrixType>
2688 const Export<
typename CrsMatrixType::local_ordinal_type,
2689 typename CrsMatrixType::global_ordinal_type,
2690 typename CrsMatrixType::node_type>& exporter,
2691 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
2692 typename CrsMatrixType::global_ordinal_type,
2693 typename CrsMatrixType::node_type> >& domainMap,
2694 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
2695 typename CrsMatrixType::global_ordinal_type,
2696 typename CrsMatrixType::node_type> >& rangeMap,
2697 const Teuchos::RCP<Teuchos::ParameterList>& params);
2717 const import_type& importer,
2718 const Teuchos::RCP<const map_type>& domainMap,
2719 const Teuchos::RCP<const map_type>& rangeMap,
2720 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
2739 const export_type& exporter,
2740 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
2741 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
2742 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
2769 const ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node>& rowTransfer,
2770 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
2771 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
2772 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
2792 insertGlobalValuesFiltered (
const GlobalOrdinal globalRow,
2793 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
2794 const Teuchos::ArrayView<const Scalar>& values);
2806 insertLocalValuesFiltered (
const LocalOrdinal localRow,
2807 const Teuchos::ArrayView<const LocalOrdinal>& indices,
2808 const Teuchos::ArrayView<const Scalar>& values);
2822 combineGlobalValues (
const GlobalOrdinal globalRowIndex,
2823 const Teuchos::ArrayView<const GlobalOrdinal>& columnIndices,
2824 const Teuchos::ArrayView<const Scalar>& values,
2860 template<
class BinaryFunction>
2862 transformGlobalValues (GlobalOrdinal globalRow,
2863 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
2864 const Teuchos::ArrayView<const Scalar>& values,
2867 using Teuchos::Array;
2868 using Teuchos::ArrayView;
2869 typedef LocalOrdinal LO;
2870 typedef GlobalOrdinal GO;
2871 typedef impl_scalar_type ST;
2872 typedef typename ArrayView<const GO>::size_type size_type;
2874 if (! isFillActive ()) {
2876 return Teuchos::OrdinalTraits<LO>::invalid ();
2878 else if (values.size () != indices.size ()) {
2880 return Teuchos::OrdinalTraits<LO>::invalid ();
2883 const LO lrow = this->
getRowMap ()->getLocalElement (globalRow);
2884 if (lrow == Teuchos::OrdinalTraits<LO>::invalid ()) {
2886 return Teuchos::OrdinalTraits<LO>::invalid ();
2889 if (staticGraph_.is_null ()) {
2890 return Teuchos::OrdinalTraits<LO>::invalid ();
2892 const crs_graph_type& graph = *staticGraph_;
2894 if (indices.size () == 0) {
2895 return static_cast<LO
> (0);
2898 ArrayView<const ST> valsIn =
2899 Teuchos::av_reinterpret_cast<
const ST> (values);
2901 if (isLocallyIndexed ()) {
2907 const map_type& colMap = * (this->
getColMap ());
2908 const size_type numInds = indices.size ();
2909 Array<LO> lclInds (numInds);
2910 for (size_type k = 0; k < numInds; ++k) {
2917 return graph.template transformLocalValues<ST, BinaryFunction> (rowInfo,
2922 else if (isGloballyIndexed ()) {
2923 return graph.template transformGlobalValues<ST, BinaryFunction> (rowInfo,
2933 return static_cast<LO
> (0);
2946 insertNonownedGlobalValues (
const GlobalOrdinal globalRow,
2947 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
2948 const Teuchos::ArrayView<const Scalar>& values);
2955 typedef Teuchos::OrdinalTraits<LocalOrdinal> OTL;
2956 typedef Kokkos::Details::ArithTraits<impl_scalar_type> STS;
2957 typedef Kokkos::Details::ArithTraits<mag_type> STM;
2960 typedef crs_graph_type
Graph;
2963 enum GraphAllocationStatus {
2964 GraphAlreadyAllocated,
2965 GraphNotYetAllocated
2984 void allocateValues (ELocalGlobal lg, GraphAllocationStatus gas);
3068 const bool force =
false)
const;
3093 const bool force =
false)
const;
3106 const Teuchos::ETransp mode,
3119 Teuchos::ArrayView<const impl_scalar_type>
getView (
RowInfo rowinfo)
const;
3135 void fillLocalMatrix (
const Teuchos::RCP<Teuchos::ParameterList>& params);
3159 Teuchos::RCP<const Graph> staticGraph_;
3160 Teuchos::RCP< Graph> myGraph_;
3179 typename local_matrix_type::values_type k_values1D_;
3180 Teuchos::ArrayRCP<Teuchos::Array<impl_scalar_type> > values2D_;
3224 std::map<GlobalOrdinal, std::pair<Teuchos::Array<GlobalOrdinal>,
3239 template<
class ViewType,
class OffsetViewType>
3240 struct pack_functor {
3244 OffsetViewType src_offset_;
3245 OffsetViewType dst_offset_;
3246 typedef typename OffsetViewType::non_const_value_type scalar_index_type;
3248 pack_functor (ViewType dst, ViewType src,
3249 OffsetViewType dst_offset, OffsetViewType src_offset) :
3252 src_offset_ (src_offset),
3253 dst_offset_ (dst_offset)
3256 KOKKOS_INLINE_FUNCTION
3257 void operator () (
const LocalOrdinal row)
const {
3258 scalar_index_type srcPos = src_offset_(row);
3259 const scalar_index_type dstEnd = dst_offset_(row+1);
3260 scalar_index_type dstPos = dst_offset_(row);
3261 for ( ; dstPos < dstEnd; ++dstPos, ++srcPos) {
3262 dst_(dstPos) = src_(srcPos);
3277 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node, const
bool classic = Node::
classic>
3278 Teuchos::RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
3280 size_t maxNumEntriesPerRow = 0,
3281 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
3284 return Teuchos::rcp (
new matrix_type (map, maxNumEntriesPerRow,
3339 template<
class CrsMatrixType>
3340 Teuchos::RCP<CrsMatrixType>
3342 const Import<
typename CrsMatrixType::local_ordinal_type,
3343 typename CrsMatrixType::global_ordinal_type,
3344 typename CrsMatrixType::node_type>& importer,
3345 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3346 typename CrsMatrixType::global_ordinal_type,
3347 typename CrsMatrixType::node_type> >& domainMap = Teuchos::null,
3348 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3349 typename CrsMatrixType::global_ordinal_type,
3350 typename CrsMatrixType::node_type> >& rangeMap = Teuchos::null,
3351 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
3353 Teuchos::RCP<CrsMatrixType> destMatrix;
3354 sourceMatrix->importAndFillComplete (destMatrix,importer, domainMap, rangeMap, params);
3391 template<
class CrsMatrixType>
3392 Teuchos::RCP<CrsMatrixType>
3394 const Export<
typename CrsMatrixType::local_ordinal_type,
3395 typename CrsMatrixType::global_ordinal_type,
3396 typename CrsMatrixType::node_type>& exporter,
3397 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3398 typename CrsMatrixType::global_ordinal_type,
3399 typename CrsMatrixType::node_type> >& domainMap = Teuchos::null,
3400 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3401 typename CrsMatrixType::global_ordinal_type,
3402 typename CrsMatrixType::node_type> >& rangeMap = Teuchos::null,
3403 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
3405 Teuchos::RCP<CrsMatrixType> destMatrix;
3406 sourceMatrix->exportAndFillComplete (destMatrix,exporter, domainMap, rangeMap, params);
3418 #endif // TPETRA_CRSMATRIX_DECL_HPP size_t getLocalLength() const
Local number of rows on the calling process.
LocalOrdinal sumIntoLocalValues(const LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Sum into one or more sparse matrix entries, using local 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...
std::string description() const
A one-line description of this object.
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.
Teuchos::RCP< node_type > getNode() const
The Kokkos Node instance.
Sparse matrix that presents a row-oriented interface that lets users read or modify entries...
Teuchos::ArrayView< const impl_scalar_type > getView(RowInfo rowinfo) const
Constant view of all entries (including extra space) in the 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...
LocalOrdinal local_ordinal_type
This class' second template parameter; the type of local indices.
void checkInternalState() const
Check that this object's state is sane; throw if it's not.
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to alpha.
Teuchos::RCP< const crs_graph_type > getCrsGraph() const
This matrix's graph, as a CrsGraph.
void sortEntries()
Sort the entries of each row by their column indices.
Teuchos::RCP< const RowGraph< LocalOrdinal, GlobalOrdinal, Node > > getGraph() const
This matrix's graph, as a RowGraph.
KokkosClassic::DefaultNode::DefaultNodeType node_type
Default value of Node template parameter.
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.
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< const map_type > getRowMap() const
The Map that describes the row distribution in this matrix.
LocalOrdinal sumIntoGlobalValues(const GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Sum into one or more sparse matrix entries, using global indices.
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.
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...
Teuchos::RCP< const map_type > getColMap() const
The Map that describes the column distribution in this matrix.
One or more distributed dense vectors.
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.
bool isLocallyIndexed() const
Whether the matrix is locally indexed on the calling process.
virtual bool supportsRowViews() const
Return true if getLocalRowView() and getGlobalRowView() are valid for this object.
bool isUpperTriangular() const
Indicates whether the matrix is upper triangular.
void replaceColMap(const Teuchos::RCP< const map_type > &newColMap)
Replace the matrix's column Map with the given Map.
virtual bool checkSizes(const SrcDistObject &source)
Compare the source and target (this) objects for compatibility.
void setAllValues(const typename local_matrix_type::row_map_type &rowPointers, const typename local_graph_type::entries_type::non_const_type &columnIndices, const typename local_matrix_type::values_type &values)
Sets the 1D pointer arrays of the graph.
size_t getNodeNumRows() const
The number of matrix rows owned by the calling process.
Node node_type
This class' fourth template parameter; the Kokkos device type.
bool fillComplete_
Whether the matrix is fill complete.
Node::device_type device_type
The Kokkos device type.
bool isConstantStride() const
Whether this multivector has constant stride between columns.
GlobalOrdinal getIndexBase() const
The index base for global indices for this matrix.
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...
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.
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.
local_matrix_type::values_type getLocalValuesView() const
Get the Kokkos local values.
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 removeEmptyProcessesInPlace(const Teuchos::RCP< const map_type > &newMap)
Remove processes owning zero rows from the Maps and their communicator.
void insertLocalValues(const LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert one or more entries into the matrix, using local indices.
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...
device_type::execution_space execution_space
The Kokkos execution space.
mag_type frobNorm_
Cached Frobenius norm of the (global) matrix.
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 .
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 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.
Kokkos::StaticCrsGraph< LocalOrdinal, Kokkos::LayoutLeft, execution_space > local_graph_type
The type of the part of the sparse graph on each MPI process.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &diag) const
Get a copy of the diagonal entries of the matrix.
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.
dual_view_type getDualView() const
Get the Kokkos::DualView which implements local storage.
Teuchos::RCP< MV > getRowMapMultiVector(const MV &Y_rangeMap, const bool force=false) const
Create a (or fetch a cached) row Map MultiVector.
bool isLowerTriangular() const
Indicates whether the matrix is lower triangular.
local_matrix_type::values_type t_ValuesType TPETRA_DEPRECATED
DEPRECATED; use local_matrix_type::values_type instead.
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.
LocalOrdinal replaceLocalValues(const LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace one or more entries' values, using local indices.
Teuchos::RCP< const map_type > getDomainMap() const
The domain Map of this matrix.
Communication plan for data redistribution from a (possibly) multiply-owned to a uniquely-owned distr...
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
The communicator over which the matrix is distributed.
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.
bool isFillComplete() const
Whether the matrix is fill complete.
void scale(const Scalar &alpha)
Scale the matrix's values: this := alpha*this.
void resumeFill(const RCP< ParameterList > ¶ms=null)
Resume operations that may change the values or structure of the matrix.
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.
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 .
CombineMode
Rule for combining data in an Import or Export.
bool isStorageOptimized() const
Returns true if storage has been optimized.
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.
size_t getNodeNumDiags() const
Returns the number of local diagonal entries, based on global row/column index comparisons.
local_matrix_type getLocalMatrix() const
The local sparse matrix.
ProfileType getProfileType() const
Returns true if the matrix was allocated with static data structures.
virtual ~CrsMatrix()
Destructor.
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.
global_size_t getGlobalNumRows() const
Number of global elements in the row map of this matrix.
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 .
global_size_t getGlobalNumDiags() const
Returns the number of global diagonal entries, based on global row/column index comparisons.
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.
Teuchos::RCP< MV > getColumnMapMultiVector(const MV &X_domainMap, const bool force=false) const
Create a (or fetch a cached) column Map MultiVector.
bool hasTransposeApply() const
Whether apply() allows applying the transpose or conjugate transpose.
void computeGlobalConstants()
Compute matrix properties that require collectives.
bool isFillActive() const
Whether the matrix is not fill complete.
bool isStaticGraph() const
Indicates that the graph is static, so that new entries cannot be added to this matrix.
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.
global_size_t getGlobalNumCols() const
The number of global columns in the matrix.
bool hasColMap() const
Indicates whether the matrix has a well-defined column map.
mag_type getFrobeniusNorm() const
Compute and return the Frobenius norm of the matrix.
Kokkos::Details::ArithTraits< impl_scalar_type >::mag_type mag_type
Type of a norm result.
LocalOrdinal replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace one or more entries' values, using global indices.
Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node2, Node2::classic > > clone(const Teuchos::RCP< Node2 > &node2, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=null) const
Create a deep copy of this CrsMatrix, where the copy may have a different Node type.
LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const
The local index corresponding to the given global index.
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().
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.
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
global_size_t getGlobalNumEntries() const
The global number of entries in this matrix.
A read-only, row-oriented interface to a sparse matrix.
std::map< GlobalOrdinal, std::pair< Teuchos::Array< GlobalOrdinal >, Teuchos::Array< Scalar > > > nonlocals_
Nonlocal data added using insertGlobalValues().
A distributed dense vector.
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.
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 expertStaticFillComplete(const RCP< const map_type > &domainMap, const RCP< const map_type > &rangeMap, const RCP< const import_type > &importer=Teuchos::null, const RCP< const export_type > &exporter=Teuchos::null, const RCP< ParameterList > ¶ms=Teuchos::null)
Perform a fillComplete on a matrix that already has data.
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.
size_t getNumVectors() const
Number of columns in the multivector.
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.
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.
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
void applyNonTranspose(const MV &X_in, MV &Y_in, Scalar alpha, Scalar beta) const
Special case of apply() for mode == Teuchos::NO_TRANS.
Teuchos::RCP< 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.
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) const
Get offsets of the diagonal entries in the matrix.
Map< LocalOrdinal, GlobalOrdinal, Node > map_type
The Map specialization suitable for this CrsMatrix specialization.
Export< LocalOrdinal, GlobalOrdinal, Node > export_type
The Export specialization suitable for this CrsMatrix specialization.
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=ScalarTraits< Scalar >::one(), Scalar beta=ScalarTraits< Scalar >::zero()) const
Compute a sparse matrix-MultiVector multiply.
size_t getNodeNumCols() const
The number of columns connected to the locally owned rows of this matrix.
Teuchos::ArrayView< impl_scalar_type > getViewNonConst(RowInfo rowinfo)
Nonconst view of all entries (including extra space) in the given row.
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.
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries on this node in the specified global row.
Base class for distributed Tpetra objects that support data redistribution.
size_t getNodeNumEntries() const
The local number of entries in this matrix.
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.
void clearGlobalConstants()
Clear matrix properties that require collectives.
bool isGloballyIndexed() const
Whether the matrix is globally indexed on the calling process.
EStorageStatus
Status of the graph's or matrix's storage, when not in a fill-complete state.
void applyTranspose(const MV &X_in, MV &Y_in, const Teuchos::ETransp mode, Scalar alpha, Scalar beta) const
Special case of apply() for mode != Teuchos::NO_TRANS.
void fillComplete(const RCP< const map_type > &domainMap, const RCP< const map_type > &rangeMap, const RCP< ParameterList > ¶ms=null)
Signal that data entry is complete, specifying domain and range maps.
local_matrix_type lclMatrix_
The local sparse matrix.
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 fillLocalGraphAndMatrix(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Fill data into the local graph and matrix.
Teuchos::RCP< const map_type > getRangeMap() const
The range Map of this matrix.
RowInfo getRowInfo(const size_t myRow) const
Get information about the locally owned row with local index myRow.
size_t getNodeMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.