42 #ifndef TPETRA_CRSMATRIX_DECL_HPP 43 #define TPETRA_CRSMATRIX_DECL_HPP 45 #include <Kokkos_DefaultNode.hpp> 46 #include <Kokkos_DefaultKernels.hpp> 48 #include "Tpetra_ConfigDefs.hpp" 49 #include "Tpetra_RowMatrix_decl.hpp" 50 #include "Tpetra_Exceptions.hpp" 51 #include "Tpetra_DistObject.hpp" 52 #include "Tpetra_CrsGraph.hpp" 53 #include "Tpetra_Vector.hpp" 189 template <
class Scalar,
190 class LocalOrdinal = int,
191 class GlobalOrdinal = LocalOrdinal,
192 class Node = Kokkos::DefaultNode::DefaultNodeType,
193 class LocalMatOps =
typename Kokkos::DefaultKernels<Scalar,LocalOrdinal,Node>::SparseOps >
195 public DistObject<char, LocalOrdinal,GlobalOrdinal,Node> {
197 typedef Scalar scalar_type;
198 typedef LocalOrdinal local_ordinal_type;
199 typedef GlobalOrdinal global_ordinal_type;
200 typedef Node node_type;
203 typedef LocalMatOps mat_vec_type;
204 typedef LocalMatOps mat_solve_type;
206 template <
class S2,
class LO2,
class GO2,
class N2,
class LMO2>
230 size_t maxNumEntriesPerRow,
280 size_t maxNumEntriesPerRow,
383 template <
class Node2>
387 const char tfecfFuncName[] =
"clone()";
388 bool fillCompleteClone =
true;
391 if (params != null) fillCompleteClone = params->get(
"fillComplete clone",fillCompleteClone);
392 if (params != null) useLocalIndices = params->get(
"Locally indexed clone",useLocalIndices);
393 if (params != null && params->get(
"Static profile clone",
true) ==
false) pftype =
DynamicProfile;
396 hasColMap() ==
false && useLocalIndices ==
true,
398 ": requested clone using local indices, but source graph doesn't have a column map yet." 407 size_t numEntriesForAll = 0;
408 if (staticGraph_->indicesAreAllocated() ==
false) {
409 if (staticGraph_->numAllocPerRow_ != null) numEntries = staticGraph_->numAllocPerRow_;
410 else numEntriesForAll = staticGraph_->numAllocForAllRows_;
412 else if (staticGraph_->numRowEntries_ != null) numEntries = staticGraph_->numRowEntries_;
413 else if (staticGraph_->nodeNumAllocated_ == 0) numEntriesForAll = 0;
418 numEntriesForAll = 0;
420 if (numRows) numEnt = arcp<size_t>(numRows);
421 for (
size_t i=0; i<numRows; ++i) {
422 numEnt[i] = staticGraph_->rowPtrs_[i+1] - staticGraph_->rowPtrs_[i];
428 if (useLocalIndices) {
430 if (numEntries == null) clonedMatrix =
rcp(
new CrsMatrix2(clonedRowMap,clonedColMap,numEntriesForAll,pftype,matrixparams));
431 else clonedMatrix =
rcp(
new CrsMatrix2(clonedRowMap,clonedColMap,numEntries,pftype,matrixparams));
434 if (numEntries == null) clonedMatrix =
rcp(
new CrsMatrix2(clonedRowMap,numEntriesForAll,pftype,matrixparams));
435 else clonedMatrix =
rcp(
new CrsMatrix2(clonedRowMap,numEntries,pftype,matrixparams));
439 numEntriesForAll = 0;
443 clonedMatrix->allocateValues(LocalIndices,CrsMatrix2::GraphNotYetAllocated);
448 for (LocalOrdinal lrow = clonedRowMap->getMinLocalIndex();
449 lrow <= clonedRowMap->getMaxLocalIndex();
453 if (linds.
size()) clonedMatrix->insertLocalValues(lrow, linds, vals);
460 for (LocalOrdinal lrow = clonedRowMap->getMinLocalIndex();
461 lrow <= clonedRowMap->getMaxLocalIndex();
464 size_t theNumEntries;
467 this->
getLocalRowCopy(clonedRowMap->getGlobalElement(lrow), linds(), vals(), theNumEntries);
468 if (theNumEntries) clonedMatrix->insertLocalValues(lrow, linds(0,theNumEntries), vals(0,theNumEntries) );
474 clonedMatrix->allocateValues(GlobalIndices,CrsMatrix2::GraphNotYetAllocated);
479 for (GlobalOrdinal grow = clonedRowMap->getMinGlobalIndex();
480 grow <= clonedRowMap->getMaxGlobalIndex();
484 if (ginds.
size()) clonedMatrix->insertGlobalValues(grow, ginds, vals);
491 for (GlobalOrdinal grow = clonedRowMap->getMinGlobalIndex();
492 grow <= clonedRowMap->getMaxGlobalIndex();
495 size_t theNumEntries;
499 if (theNumEntries) clonedMatrix->insertGlobalValues(grow, ginds(0,theNumEntries), vals(0,theNumEntries) );
504 if (fillCompleteClone) {
513 clonedRangeMap = clonedRowMap;
519 clonedDomainMap = clonedRowMap;
521 clonedMatrix->fillComplete(clonedDomainMap, clonedRangeMap, fillparams);
523 catch (std::exception &e) {
524 const bool caughtExceptionOnClone =
true;
528 <<
"\ncaught the following exception while calling fillComplete() on clone of type\n" 728 void scale(
const Scalar &alpha);
1212 template <
class DomainScalar,
class RangeScalar>
1218 RangeScalar beta)
const;
1244 template <
class DomainScalar,
class RangeScalar>
1249 const RangeScalar& dampingFactor,
1250 const Kokkos::ESweepDirection direction)
const;
1268 template <
class DomainScalar,
class RangeScalar>
1384 const Scalar& dampingFactor,
1386 const int numSweeps)
const;
1420 const Scalar& dampingFactor,
1422 const int numSweeps,
1423 const bool zeroInitialGuess)
const;
1436 add (
const Scalar& alpha,
1471 size_t& constantNumPackets,
1486 size_t& constantNumPackets,
1502 size_t constantNumPackets,
1508 template<
class CrsMatrixType>
1511 const Import<
typename CrsMatrixType::local_ordinal_type,
1512 typename CrsMatrixType::global_ordinal_type,
1513 typename CrsMatrixType::node_type>& importer,
1514 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
1515 typename CrsMatrixType::global_ordinal_type,
1516 typename CrsMatrixType::node_type> >& domainMap,
1517 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
1518 typename CrsMatrixType::global_ordinal_type,
1519 typename CrsMatrixType::node_type> >& rangeMap,
1522 template<
class CrsMatrixType>
1525 const Export<
typename CrsMatrixType::local_ordinal_type,
1526 typename CrsMatrixType::global_ordinal_type,
1527 typename CrsMatrixType::node_type>& exporter,
1528 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
1529 typename CrsMatrixType::global_ordinal_type,
1530 typename CrsMatrixType::node_type> >& domainMap,
1531 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
1532 typename CrsMatrixType::global_ordinal_type,
1533 typename CrsMatrixType::node_type> >& rangeMap,
1576 insertGlobalValuesFiltered (
const GlobalOrdinal globalRow,
1586 insertLocalValuesFiltered (
const LocalOrdinal localRow,
1598 combineGlobalValues (
const GlobalOrdinal globalRowIndex,
1634 template<
class BinaryFunction>
1636 transformLocalValues (LocalOrdinal localRow,
1641 typedef LocalOrdinal LO;
1642 typedef GlobalOrdinal GO;
1650 "Tpetra::CrsMatrix::transformLocalValues: Fill must be active in order " 1651 "to call this method. That is, isFillActive() must return true. If " 1652 "you have already called fillComplete(), you need to call resumeFill() " 1653 "before you can replace values.");
1657 "Tpetra::CrsMatrix::transformLocalValues: values.size () = " 1658 << values.
size () <<
" != indices.size () = " << indices.
size ()
1661 ! this->hasColMap (),
1663 "Tpetra::CrsMatrix::transformLocalValues: We cannot transform local " 1664 "indices without a column map.");
1665 const bool isLocalRow =
getRowMap ()->isNodeLocalElement (localRow);
1666 TEUCHOS_TEST_FOR_EXCEPTION(
1669 "Tpetra::CrsMatrix::transformLocalValues: The specified local row " 1670 << localRow <<
" does not belong to this process " 1671 << getRowMap ()->getComm ()->getRank () <<
".");
1673 RowInfo rowInfo = staticGraph_->getRowInfo (localRow);
1674 if (indices.
size () > 0) {
1676 if (isLocallyIndexed ()) {
1677 staticGraph_->template transformLocalValues<Scalar, BinaryFunction> (rowInfo, curVals, indices, values, f);
1679 else if (isGloballyIndexed ()) {
1685 while (lindit != indices.
end()) {
1691 staticGraph_->template transformGlobalValues<Scalar, BinaryFunction> (rowInfo, curVals, gindices (), values, f);
1726 template<
class BinaryFunction>
1728 transformGlobalValues (GlobalOrdinal globalRow,
1733 typedef LocalOrdinal LO;
1734 typedef GlobalOrdinal GO;
1742 "Tpetra::CrsMatrix::transformGlobalValues: Fill must be active in order " 1743 "to call this method. That is, isFillActive() must return true. If " 1744 "you have already called fillComplete(), you need to call resumeFill() " 1745 "before you can replace values.");
1749 "Tpetra::CrsMatrix::transformGlobalValues: values.size () = " 1750 << values.
size () <<
" != indices.size () = " << indices.
size ()
1753 const LO lrow = this->
getRowMap()->getLocalElement(globalRow);
1763 std::ostringstream os;
1764 os <<
"transformGlobalValues: The given global row index " 1765 << globalRow <<
" is not owned by the calling process (rank " 1766 << this->
getRowMap()->getComm()->getRank() <<
").";
1770 RowInfo rowInfo = staticGraph_->getRowInfo (lrow);
1771 if (indices.
size () > 0) {
1773 if (isLocallyIndexed ()) {
1779 while (gindit != indices.
end()) {
1785 staticGraph_->template transformLocalValues<Scalar, BinaryFunction> (rowInfo, curVals, lindices (), values, f);
1787 else if (isGloballyIndexed ()) {
1788 staticGraph_->template transformGlobalValues<Scalar, BinaryFunction> (rowInfo, curVals, indices, values, f);
1802 typedef typename LocalMatOps::template bind_scalar<Scalar>::other_type sparse_ops_type;
1803 typedef typename sparse_ops_type::template graph<LocalOrdinal,Node>::graph_type local_graph_type;
1804 typedef typename sparse_ops_type::template matrix<Scalar,LocalOrdinal,Node>::matrix_type local_matrix_type;
1810 enum GraphAllocationStatus {
1811 GraphAlreadyAllocated,
1812 GraphNotYetAllocated
1831 void allocateValues (ELocalGlobal lg, GraphAllocationStatus gas);
1915 const bool force =
false)
const;
1940 const bool force =
false)
const;
1975 void checkInternalState()
const;
2042 std::map<GlobalOrdinal, Array<std::pair<GlobalOrdinal,Scalar> > >
nonlocals_;
2059 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2062 size_t maxNumEntriesPerRow = 0,
2067 return rcp (
new matrix_type (map, maxNumEntriesPerRow,
DynamicProfile, params));
2121 template<
class CrsMatrixType>
2124 const Import<
typename CrsMatrixType::local_ordinal_type,
2125 typename CrsMatrixType::global_ordinal_type,
2126 typename CrsMatrixType::node_type>& importer,
2127 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
2128 typename CrsMatrixType::global_ordinal_type,
2129 typename CrsMatrixType::node_type> >& domainMap = Teuchos::null,
2130 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
2131 typename CrsMatrixType::global_ordinal_type,
2132 typename CrsMatrixType::node_type> >& rangeMap = Teuchos::null,
2135 return sourceMatrix->importAndFillComplete (importer, domainMap, rangeMap, params);
2171 template<
class CrsMatrixType>
2174 const Export<
typename CrsMatrixType::local_ordinal_type,
2175 typename CrsMatrixType::global_ordinal_type,
2176 typename CrsMatrixType::node_type>& exporter,
2177 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
2178 typename CrsMatrixType::global_ordinal_type,
2179 typename CrsMatrixType::node_type> >& domainMap = Teuchos::null,
2180 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
2181 typename CrsMatrixType::global_ordinal_type,
2182 typename CrsMatrixType::node_type> >& rangeMap = Teuchos::null,
2185 return sourceMatrix->exportAndFillComplete (exporter, domainMap, rangeMap, params);
Teuchos::RCP< MV > exportMV_
Row Map MultiVector used in apply().
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
void localGaussSeidel(const MultiVector< DomainScalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< RangeScalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &D, const RangeScalar &dampingFactor, const Kokkos::ESweepDirection direction) const
Gauss-Seidel or SOR on .
size_t getNodeNumRows() const
Returns the number of matrix rows owned on the calling node.
void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &indices, ArrayView< const Scalar > &values) const
Extract a const, non-persisting view of global indices in a specified row 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.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
void sortEntries()
Sort the entries of each row by their column indices.
RCP< Node > getNode() const
Returns the underlying node.
Sparse matrix that presents a compressed sparse row interface.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
GlobalOrdinal getIndexBase() const
Returns the index base for global indices for this matrix.
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 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 mergeRedundantEntries()
Merge entries in each row with the same column indices.
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
bool isStaticGraph() const
Indicates that the graph is static, so that new entries cannot be added to this matrix.
RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > > getCrsGraph() const
Returns the CrsGraph associated with this matrix.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > & getRowMap() const
Returns the Map that describes the row distribution in this matrix.
ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Returns the Frobenius norm of the matrix.
virtual void packAndPrepare(const SrcDistObject &source, const Teuchos::ArrayView< const LocalOrdinal > &exportLIDs, Teuchos::Array< char > &exports, const Teuchos::ArrayView< size_t > &numPacketsPerLID, size_t &constantNumPackets, Distributor &distor)
Perform any packing or preparation required for communication.
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
void getLocalRowCopy(LocalOrdinal LocalRow, const ArrayView< LocalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const
Extract a list of entries in a specified local row of the matrix. Put into storage allocated by calli...
#define TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(throw_exception_test, Exception, msg)
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
One or more distributed dense vectors.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void insertGlobalValues(const GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert one or more entries into the matrix, using global indices.
size_t getNodeNumDiags() const
Returns the number of local diagonal entries, based on global row/column index comparisons.
bool fillComplete_
Whether the matrix is fill complete.
RCP< CrsMatrix< T, LocalOrdinal, GlobalOrdinal, Node > > convert() const
Returns another CrsMatrix with the same entries, but represented as a different scalar type...
void globalAssemble()
Communicate nonlocal contributions to other processes.
void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace matrix entries, using local IDs.
Allocation information for a locally owned row in a CrsGraph or CrsMatrix.
void getGlobalRowCopy(GlobalOrdinal GlobalRow, const ArrayView< GlobalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const
Extract a list of entries in a specified global row of this matrix. Put into pre-allocated storage...
void fillLocalMatrix(const RCP< ParameterList > ¶ms)
Fill data into the local matrix.
void setAllValues(const ArrayRCP< size_t > &rowPointers, const ArrayRCP< LocalOrdinal > &columnIndices, const ArrayRCP< Scalar > &values)
Sets the 1D pointer arrays of the graph.
void gaussSeidel(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &D, const Scalar &dampingFactor, const ESweepDirection direction, const int numSweeps) const
"Hybrid" Jacobi + (Gauss-Seidel or SOR) on .
virtual void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newMap)
Remove processes owning zero rows from the Maps and their communicator.
RCP< sparse_ops_type > lclMatOps_
virtual void copyAndPermute(const SrcDistObject &source, size_t numSameIDs, const ArrayView< const LocalOrdinal > &permuteToLIDs, const ArrayView< const LocalOrdinal > &permuteFromLIDs)
Perform copies and permutations that are local to this process.
Exception thrown by CrsMatrix on invalid global row index.
size_t global_size_t
Global size_t object.
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to scalarThis.
void apply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=ScalarTraits< Scalar >::one(), Scalar beta=ScalarTraits< Scalar >::zero()) const
Compute a sparse matrix-MultiVector multiply.
bool isFillComplete() const
Returns true if the matrix is in compute mode, i.e. if fillComplete() has been called.
global_size_t getGlobalNumRows() const
Number of global elements in the row map of this matrix.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const
Get a copy of the diagonal entries owned by this node, with local row indices.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > & getDomainMap() const
The domain Map of this operator.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > & getRangeMap() const
The range Map of this operator.
size_t getNodeNumCols() const
Returns the number of columns connected to the locally owned rows of this matrix. ...
bool isUpperTriangular() const
Indicates whether the matrix is upper triangular.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void fillLocalGraphAndMatrix(const RCP< ParameterList > ¶ms)
Fill data into the local graph and matrix.
void applyNonTranspose(const MV &X_in, MV &Y_in, Scalar alpha, Scalar beta) const
Special case of apply() for mode == Teuchos::NO_TRANS.
void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices, ArrayView< const Scalar > &values) const
Extract a const, non-persisting view of local indices in a specified row of the matrix.
RCP< local_matrix_type > lclMatrix_
ESweepDirection
Sweep direction for Gauss-Seidel or Successive Over-Relaxation (SOR).
void expertStaticFillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > &importer=Teuchos::null, const RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > &exporter=Teuchos::null, const RCP< ParameterList > ¶ms=Teuchos::null)
Perform a fillComplete on a matrix that already has data.
Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > createCrsMatrix(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t maxNumEntriesPerRow=0, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Non-member function to create an empty CrsMatrix given a row map and a non-zero profile.
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace matrix entries, using global IDs.
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
Communication plan for data redistribution from a (possibly) multiply-owned to a uniquely-owned distr...
void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > ¶ms=null)
Signal that data entry is complete, specifying domain and range maps.
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) const
Get offsets of the diagonal entries in the matrix.
std::map< GlobalOrdinal, Array< std::pair< GlobalOrdinal, Scalar > > > nonlocals_
Nonlocal data added using insertGlobalValues().
Sets up and executes a communication plan for a Tpetra DistObject.
GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const
The global index corresponding to the given local index.
CombineMode
Tpetra::Combine Mode enumerable type.
void localSolve(const MultiVector< RangeScalar, LocalOrdinal, GlobalOrdinal, Node > &Y, MultiVector< DomainScalar, LocalOrdinal, GlobalOrdinal, Node > &X, Teuchos::ETransp trans) const
Solves a linear system when the underlying matrix is triangular.
friend 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, 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().
std::string description() const
A simple one-line description of this object.
bool isFillActive() const
Returns true if the matrix is in edit mode.
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
Teuchos::RCP< MV > getColumnMapMultiVector(const MV &X_domainMap, const bool force=false) const
Create a (or fetch a cached) column Map MultiVector.
Abstract base class for objects that can be the source of an Import or Export operation.
virtual bool supportsRowViews() const
Returns true if getLocalRowView() and getGlobalRowView() are valid for this class.
size_t getNodeNumEntries() const
Returns the local number of entries in this matrix.
void resize(size_type new_size, const value_type &x=value_type())
void gaussSeidelCopy(MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &D, const Scalar &dampingFactor, const ESweepDirection direction, const int numSweeps, const bool zeroInitialGuess) const
Version of gaussSeidel(), with fewer requirements on X.
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 clearGlobalConstants()
Clear matrix properties that require collectives.
static const EVerbosityLevel verbLevel_default
size_t getNodeMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
ProfileType getProfileType() const
Returns true if the matrix was allocated with static data structures.
friend 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, 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().
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.
global_size_t getGlobalNumDiags() const
Returns the number of global diagonal entries, based on global row/column index comparisons.
virtual ~CrsMatrix()
Destructor.
Magnitude frobNorm_
Cached Frobenius norm of the (global) matrix.
global_size_t getGlobalNumCols() const
Number of global columns in the matrix.
LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const
The local index corresponding to the given global index.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > & getColMap() const
Returns the Map that describes the column distribution in this matrix.
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
Describes a parallel distribution of objects over processes.
bool isLowerTriangular() const
Indicates whether the matrix is lower triangular.
A read-only, row-oriented interface to a sparse matrix.
void computeGlobalConstants()
Compute matrix properties that require collectives.
A distributed dense vector.
void replaceDomainMapAndImporter(const Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &newDomainMap, Teuchos::RCP< const Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > &newImporter)
Replace the current domain Map and Import with the given objects.
void resumeFill(const RCP< ParameterList > ¶ms=null)
Resume operations that may change the values or structure of the matrix.
bool hasColMap() const
Indicates whether the matrix has a well-defined column map.
bool hasTransposeApply() const
Whether apply() allows applying the transpose or conjugate transpose.
Teuchos::RCP< MV > importMV_
Column Map MultiVector used in apply() and gaussSeidel().
void localMultiply(const MultiVector< DomainScalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< RangeScalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp trans, RangeScalar alpha, RangeScalar beta) const
Compute a sparse matrix-MultiVector product local to each process.
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries on this node in the specified global row.
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 scale(const Scalar &alpha)
Scale the current values of a matrix, this = alpha*this.
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
Base class for distributed Tpetra objects that support data redistribution.
bool isStorageOptimized() const
Returns true if storage has been optimized.
std::vector< T >::iterator iterator
void 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.
void allocateValues(ELocalGlobal lg, GraphAllocationStatus gas)
Allocate values (and optionally indices) using the Node.
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
Implementation of SrcDistObjectWithPack.
virtual bool checkSizes(const SrcDistObject &source)
Compare the source and target (this) objects for compatibility.
const RCP< const Comm< int > > & getComm() const
Returns the communicator.
std::string typeName(const T &t)
Teuchos::RCP< MV > getRowMapMultiVector(const MV &Y_rangeMap, const bool force=false) const
Create a (or fetch a cached) row Map MultiVector.
RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node2, typename Kokkos::DefaultKernels< void, LocalOrdinal, Node2 >::SparseOps > > clone(const RCP< Node2 > &node2, const RCP< ParameterList > ¶ms=null)
Create a cloned CrsMatrix for a different node type.
RCP< const RowGraph< LocalOrdinal, GlobalOrdinal, Node > > getGraph() const
Returns the RowGraph associated with this matrix.