12#ifndef XPETRA_MATRIX_DEF_HPP
13#define XPETRA_MATRIX_DEF_HPP
15#include <Tpetra_KokkosCompat_DefaultNode.hpp>
20#include "Xpetra_MultiVector.hpp"
26#include "Xpetra_StridedMap.hpp"
27#include "Xpetra_StridedMapFactory.hpp"
34template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
37template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
40template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
44 operatorViewTable_.put(viewLabel, view);
47template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
52 const size_t blkSize = 1;
53 std::vector<size_t> stridingInfo(1, blkSize);
54 LocalOrdinal stridedBlockId = -1;
56 if (A->IsView(viewLabel)) {
57 rangeMap = transposeA ? A->getColMap(viewLabel) : A->getRowMap(viewLabel);
58 domainMap = transposeA ? A->getRowMap(viewLabel) : A->getColMap(viewLabel);
61 rangeMap = transposeA ? A->getDomainMap() : A->getRangeMap();
62 domainMap = transposeA ? A->getRangeMap() : A->getDomainMap();
64 if (viewLabel ==
"stridedMaps") {
70 if (B != Teuchos::null) {
73 if (B->IsView(viewLabel)) {
74 domainMap = transposeB ? B->getRowMap(viewLabel) : B->getColMap(viewLabel);
77 domainMap = transposeB ? B->getRangeMap() : B->getDomainMap();
79 if (viewLabel ==
"stridedMaps")
84 if (IsView(viewLabel))
85 RemoveView(viewLabel);
87 CreateView(viewLabel, rangeMap, domainMap);
90template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
97 operatorViewTable_.arrayify(viewLabels, viewList);
98 out <<
"views associated with this operator" << std::endl;
99 for (
int i = 0; i < viewLabels.
size(); ++i)
100 out << viewLabels[i] << std::endl;
104template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
108 operatorViewTable_.remove(viewLabel);
111template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
115 currentViewLabel_ = viewLabel;
119template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
121 return operatorViewTable_.containsKey(viewLabel);
124template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
127template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
130template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
133template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
136template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
139 return operatorViewTable_.get(viewLabel)->GetRowMap();
142template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
145template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
148 return operatorViewTable_.get(viewLabel)->GetColMap();
151template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
154 std::vector<size_t> stridingInfo;
155 stridingInfo.push_back(Teuchos::as<size_t>(blksize));
156 LocalOrdinal stridedBlockId = -1;
164 this->getDomainMap(),
169 if (IsFixedBlockSizeSet()) RemoveView(
"stridedMaps");
170 CreateView(
"stridedMaps", stridedRangeMap, stridedDomainMap);
173template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
175 if (IsFixedBlockSizeSet()) {
181 return Teuchos::as<LocalOrdinal>(domainMap->getFixedBlockSize());
187template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
189 return IsView(
"stridedMaps");
192template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
194 operatorViewTable_.get(GetCurrentViewLabel())->SetMaxEigenvalueEstimate(sigma);
197template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
199 return operatorViewTable_.get(GetCurrentViewLabel())->GetMaxEigenvalueEstimate();
204#define XPETRA_MATRIX_SHORT
basic_FancyOStream & setOutputToRootOnly(const int rootRank)
int getOutputToRootOnly() const
Exception indicating invalid cast attempted.
Exception throws to report errors in the internal logical of the program.
const viewLabel_t & GetCurrentViewLabel() const
void CreateView(viewLabel_t viewLabel, const RCP< const Map > &rowMap, const RCP< const Map > &colMap)
virtual void SetMaxEigenvalueEstimate(Scalar const &sigma)
void SetFixedBlockSize(LocalOrdinal blksize, GlobalOrdinal offset=0)
virtual ~Matrix()
Destructor.
virtual const RCP< const Map > & getRowMap() const
Returns the Map that describes the row distribution in this matrix.
virtual const RCP< const Map > & getColMap() const
Returns the Map that describes the column distribution in this matrix. This might be null until fillC...
const viewLabel_t SwitchToView(const viewLabel_t viewLabel)
const viewLabel_t & GetDefaultViewLabel() const
bool IsView(const viewLabel_t viewLabel) const
bool IsFixedBlockSizeSet() const
Returns true, if SetFixedBlockSize has been called before.
void RemoveView(const viewLabel_t viewLabel)
const viewLabel_t SwitchToDefaultView()
void PrintViews(Teuchos::FancyOStream &out) const
Print all of the views associated with the Matrix.
LocalOrdinal GetFixedBlockSize() const
virtual Scalar GetMaxEigenvalueEstimate() const
static RCP< Xpetra::StridedMap< LocalOrdinal, GlobalOrdinal, Node > > Build(UnderlyingLib lib, global_size_t numGlobalElements, GlobalOrdinal indexBase, std::vector< size_t > &stridingInfo, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalOrdinal stridedBlockId=-1, GlobalOrdinal offset=0, LocalGlobal lg=Xpetra::GloballyDistributed)
Map constructor with Xpetra-defined contiguous uniform distribution.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)