Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_LinearOpWithSolveHelpers.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
4 //
5 // Copyright 2004 NTESS and the Thyra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef THYRA_LINEAR_OP_WITH_SOLVE_FACTORY_SUBCLASS_HELPERS_HPP
11 #define THYRA_LINEAR_OP_WITH_SOLVE_FACTORY_SUBCLASS_HELPERS_HPP
12 
13 
14 #include "Thyra_LinearOpWithSolveBase.hpp"
15 #include "Teuchos_toString.hpp"
16 
17 
18 namespace Thyra {
19 
20 
28 template<class Scalar>
29 void assertSolveSupports(
30  const LinearOpWithSolveBase<Scalar> &lows,
31  const EOpTransp M_trans,
32  const Ptr<const SolveCriteria<Scalar> > solveCriteria = Teuchos::null
33  );
34 
42 template<class Scalar>
43 void assertSupportsSolveMeasureType(
44  const LinearOpWithSolveBase<Scalar> &lows,
45  const EOpTransp M_trans,
46  const SolveMeasureType &solveMeasureType
47  );
48 // 2010/08/22: rabartl: ToDo: Deprecate this bug 4915 is finished!
49 
50 } // namespace Thyra
51 
52 
53 //
54 // Implementations
55 //
56 
57 
58 template<class Scalar>
59 void Thyra::assertSolveSupports(
60  const LinearOpWithSolveBase<Scalar> &lows,
61  const EOpTransp M_trans,
62  const Ptr<const SolveCriteria<Scalar> > solveCriteria
63  )
64 {
65  using Teuchos::toString;
67  !lows.solveSupports(M_trans, solveCriteria),
68  std::logic_error,
69  "Error, the LinearOpWithSolve object \"" << lows.description() << "\"\n"
70  "for M_trans = " << toString(M_trans) << " does not support the solve"
71  " criteria = "
72  << ( nonnull(solveCriteria) ? toString(*solveCriteria) : std::string("null") )
73  << "!"
74  );
75 }
76 // 2010/08/22: rabartl: Bug 4915 ToDo: Move the above into the NIV function
77 // solve(...).
78 
79 template<class Scalar>
80 void Thyra::assertSupportsSolveMeasureType(
81  const LinearOpWithSolveBase<Scalar> &lows,
82  const EOpTransp M_trans,
83  const SolveMeasureType &solveMeasureType
84  )
85 {
87  !solveSupportsSolveMeasureType(lows,M_trans,solveMeasureType),
88  std::logic_error,
89  "Error, the LinearOpWithSolve object \"" << lows.description() << "\"\n"
90  "for M_trans = " << toString(M_trans) << " does not support the solve"
91  " measure = "
92  << toString(solveMeasureType.numerator)
93  << "/"
94  << toString(solveMeasureType.denominator)
95  << "!"
96  );
97 }
98 
99 #endif // THYRA_LINEAR_OP_WITH_SOLVE_FACTORY_SUBCLASS_HELPERS_HPP
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
std::string toString(ModelEvaluatorBase::EInArgsMembers)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
bool solveSupportsSolveMeasureType(const LinearOpWithSolveBase< Scalar > &A, const EOpTransp transp, const SolveMeasureType &solveMeasureType)
Call solveSupportsSolveMeasureType() as a non-member function.
bool nonnull(const boost::shared_ptr< T > &p)
std::string toString(const T &t)