43#ifndef IFPACK2_CONDEST_HPP
44#define IFPACK2_CONDEST_HPP
46#include "Ifpack2_ConfigDefs.hpp"
47#include "Ifpack2_CondestType.hpp"
49#include <Teuchos_Ptr.hpp>
92template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
93typename Teuchos::ScalarTraits<Scalar>::magnitudeType
96 const int MaxIters = 1550,
97 const typename Teuchos::ScalarTraits<Scalar>::magnitudeType& Tol = Teuchos::as<Scalar> (1e-9),
98 const Teuchos::Ptr<
const Tpetra::RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >& matrix_in = Teuchos::null)
101 typedef Teuchos::ScalarTraits<Scalar> STS;
102 typedef typename STS::magnitudeType MT;
103 typedef Teuchos::ScalarTraits<MT> STM;
104 typedef Tpetra::RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> row_matrix_type;
105 typedef Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> vec_type;
107 MT condNumEst = -STS::magnitude( STS::one() );
111 Ptr<const row_matrix_type> matrix = matrix_in;
112 if (matrix_in == Teuchos::null) {
114 TEUCHOS_TEST_FOR_EXCEPTION(
115 matrix == Teuchos::null,
117 "Ifpack2::Condest: Both the input matrix (matrix_in) and the Ifpack2 "
118 "preconditioner's matrix are null, so we have no matrix with which to "
119 "compute a condition number estimate. This probably indicates a bug "
120 "in Ifpack2, since no Ifpack2::Preconditioner subclass should accept a"
126 ones.putScalar (STS::one ());
128 onesResult.putScalar (STS::zero ());
129 TIFP.
apply (ones, onesResult);
130 condNumEst = onesResult.normInf ();
131 TEUCHOS_TEST_FOR_EXCEPTION(
132 STM::isnaninf (condNumEst),
134 "Ifpack2::Condest: $\\|A*[1, ..., 1]^T\\|_{\\infty}$ = " << condNumEst <<
" is NaN or Inf.");
136 TEUCHOS_TEST_FOR_EXCEPTION(
137 true, std::logic_error,
138 "Ifpack2::Condest: Condition number estimation using CG is not currently supported.");
140 TEUCHOS_TEST_FOR_EXCEPTION(
141 true, std::logic_error,
142 "Ifpack2::Condest: Condition number estimation using GMRES is not currently supported.");
Interface for all Ifpack2 preconditioners.
Definition Ifpack2_Preconditioner.hpp:108
virtual Teuchos::RCP< const Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getMatrix() const =0
The input matrix given to the constructor.
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
Apply the preconditioner to X, putting the result in Y.
virtual Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const =0
The range Map of this operator.
virtual Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const =0
The domain Map of this operator.
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:74
CondestType
Ifpack2::CondestType: enum to define the type of condition number estimate.
Definition Ifpack2_CondestType.hpp:50
@ CG
Uses AztecOO's CG.
Definition Ifpack2_CondestType.hpp:52
@ Cheap
cheap estimate
Definition Ifpack2_CondestType.hpp:51
@ GMRES
Uses AztecOO's GMRES.
Definition Ifpack2_CondestType.hpp:53