10 #ifndef MUELU_CGSOLVER_DEF_HPP
11 #define MUELU_CGSOLVER_DEF_HPP
14 #include <Xpetra_MatrixFactory2.hpp>
17 #include "MueLu_Utilities.hpp"
18 #include "MueLu_Constraint.hpp"
25 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
29 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
36 finalP = MatrixFactory2::BuildCopy(rcpFromRef(P0));
41 const auto rowMap = A->getRowMap();
43 A->getLocalDiagCopy(*invDiag);
44 invDiag->reciprocal(*invDiag);
54 #ifndef TWO_ARG_MATRIX_ADD
58 SC oldRZ, newRZ, alpha, beta, app;
62 T_->fillComplete(P0.getDomainMap(), P0.getRangeMap());
66 X = rcp_const_cast<Matrix>(rcpFromRef(P0));
68 tmpAP = MatrixMatrix::Multiply(*A,
false, *X,
false, mmfancy,
true ,
true );
78 Z->leftScale(*invDiag);
85 for (
size_t i = 0; i < nIts_; i++) {
87 if (i == 0 || useTpetra) {
92 tmpAP = MatrixMatrix::Multiply(*A,
false, *P,
false, mmfancy,
true ,
true );
95 tmpAP = MatrixMatrix::Multiply(*A,
false, *P,
false, tmpAP, mmfancy,
true ,
true );
106 X = MatrixFactory2::BuildCopy(rcpFromRef(P0));
112 this->GetOStream(
Runtime1, 1) <<
"alpha = " << alpha << std::endl;
115 #ifndef TWO_ARG_MATRIX_ADD
116 newX = Teuchos::null;
117 MatrixMatrix::TwoMatrixAdd(*P,
false, alpha, *X,
false, one, newX, mmfancy);
118 newX->fillComplete(P0.getDomainMap(), P0.getRangeMap());
121 MatrixMatrix::TwoMatrixAdd(*P,
false, alpha, *X, one);
128 #ifndef TWO_ARG_MATRIX_ADD
129 newR = Teuchos::null;
130 MatrixMatrix::TwoMatrixAdd(*AP,
false, -alpha, *R,
false, one, newR, mmfancy);
131 newR->fillComplete(P0.getDomainMap(), P0.getRangeMap());
134 MatrixMatrix::TwoMatrixAdd(*AP,
false, -alpha, *R, one);
138 Z = MatrixFactory2::BuildCopy(R);
139 Z->leftScale(*invDiag);
143 beta = newRZ / oldRZ;
146 #ifndef TWO_ARG_MATRIX_ADD
147 newP = Teuchos::null;
148 MatrixMatrix::TwoMatrixAdd(*P,
false, beta, *Z,
false, one, newP, mmfancy);
149 newP->fillComplete(P0.getDomainMap(), P0.getRangeMap());
152 MatrixMatrix::TwoMatrixAdd(*Z,
false, one, *P, beta);
163 #endif // ifndef MUELU_CGSOLVER_DECL_HPP
Constraint space information for the potential prolongator.
void swap(RCP< T > &r_ptr)
RCP< const CrsGraph > GetPattern() const
Print even more statistics.
void Iterate(const Matrix &A, const Constraint &C, const Matrix &P0, RCP< Matrix > &P) const
Iterate.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
static RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > BuildCopy(const RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > A)
static RCP< Vector > Build(const Teuchos::RCP< const Map > &map, bool zeroOut=true)
void Apply(const Matrix &P, Matrix &Projected) const
Apply constraint.
static Scalar Frobenius(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B)
Frobenius inner product of two matrices.
Description of what is happening (more verbose)