43 #ifndef IFPACK2_CONDEST_HPP 44 #define IFPACK2_CONDEST_HPP 46 #include "Ifpack2_ConfigDefs.hpp" 47 #include "Ifpack2_CondestType.hpp" 48 #include "Ifpack2_Preconditioner.hpp" 49 #include <Teuchos_Ptr.hpp> 84 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
85 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
88 const int MaxIters = 1550,
89 const typename Teuchos::ScalarTraits<Scalar>::magnitudeType& Tol = Teuchos::as<Scalar> (1e-9),
90 const Teuchos::Ptr<
const Tpetra::RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >& matrix_in = Teuchos::null)
93 typedef Teuchos::ScalarTraits<Scalar> STS;
94 typedef typename STS::magnitudeType MT;
95 typedef Teuchos::ScalarTraits<MT> STM;
96 typedef Tpetra::RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> row_matrix_type;
97 typedef Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> vec_type;
99 MT condNumEst = -STS::magnitude( STS::one() );
103 Ptr<const row_matrix_type> matrix = matrix_in;
104 if (matrix_in == Teuchos::null) {
106 TEUCHOS_TEST_FOR_EXCEPTION(
107 matrix == Teuchos::null,
109 "Ifpack2::Condest: Both the input matrix (matrix_in) and the Ifpack2 " 110 "preconditioner's matrix are null, so we have no matrix with which to " 111 "compute a condition number estimate. This probably indicates a bug " 112 "in Ifpack2, since no Ifpack2::Preconditioner subclass should accept a" 118 ones.putScalar (STS::one ());
120 onesResult.putScalar (STS::zero ());
121 TIFP.
apply (ones, onesResult);
122 condNumEst = onesResult.normInf ();
123 TEUCHOS_TEST_FOR_EXCEPTION(
124 STM::isnaninf (condNumEst),
126 "Ifpack2::Condest: $\\|A*[1, ..., 1]^T\\|_{\\infty}$ = " << condNumEst <<
" is NaN or Inf.");
128 TEUCHOS_TEST_FOR_EXCEPTION(
129 true, std::logic_error,
130 "Ifpack2::Condest: Condition number estimation using CG is not currently supported.");
132 TEUCHOS_TEST_FOR_EXCEPTION(
133 true, std::logic_error,
134 "Ifpack2::Condest: Condition number estimation using GMRES is not currently supported.");
141 #endif // IFPACK2_CONDEST_HPP CondestType
Ifpack2::CondestType: enum to define the type of condition number estimate.
Definition: Ifpack2_CondestType.hpp:50
virtual void apply(const Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const =0
Applies the effect of the preconditioner.
virtual const Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > & getRangeMap() const =0
Returns the Map associated with the range of this operator, which must be compatible with Y...
virtual const Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > & getDomainMap() const =0
Returns the Map associated with the domain of this operator, which must be compatible with X...
Base class for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:130
virtual Teuchos::RCP< const Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getMatrix() const =0
Returns a pointer to the input matrix.
Uses AztecOO's CG.
Definition: Ifpack2_CondestType.hpp:52
Uses AztecOO's GMRES.
Definition: Ifpack2_CondestType.hpp:53
Ifpack2::Container: a pure virtual class for creating and solving local linear problems.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:67
cheap estimate
Definition: Ifpack2_CondestType.hpp:51