Thyra Version of the Day
Loading...
Searching...
No Matches
Thyra_TestingToolsDecl.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_TESTING_TOOLS_DECL_HPP
11#define THYRA_TESTING_TOOLS_DECL_HPP
12
13#include "Thyra_OperatorVectorTypes.hpp"
14#include "Teuchos_VerbosityLevel.hpp"
15#include "Teuchos_TestingHelpers.hpp"
16
17namespace Thyra {
18
19
24inline const std::string passfail(const bool result)
25{
26 return Teuchos::passfail(result);
27}
28
29
34template <class Scalar>
35inline
37relErr( const Scalar &s1, const Scalar &s2 )
38{
39 return Teuchos::relErr<Scalar>(s1, s2);
40}
41
42
49template <class Scalar>
51relVectorErr( const VectorBase<Scalar> &v1, const VectorBase<Scalar> &v2 );
52
53
64template<class Scalar1, class Scalar2, class ScalarMag>
65bool testRelErrors(
66 const std::string &v1_name,
67 const ArrayView<const Scalar1> &v1,
68 const std::string &v2_name,
69 const ArrayView<const Scalar2> &v2,
70 const std::string &maxRelErr_error_name,
71 const ScalarMag &maxRelErr_error,
72 const std::string &maxRelErr_warning_name,
73 const ScalarMag &maxRelErr_warning,
74 const Ptr<std::ostream> &out,
75 const std::string &leadingIndent = std::string("")
76 );
77
78
89template<class Scalar>
91 const std::string &v1_name,
92 const VectorBase<Scalar> &v1,
93 const std::string &v2_name,
94 const VectorBase<Scalar> &v2,
95 const std::string &maxRelErr_error_name,
96 const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &maxRelErr_error,
97 const std::string &maxRelErr_warning_name,
98 const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &maxRelErr_warning,
99 std::ostream *out,
101 const std::string &leadingIndent = std::string("")
102 );
103
104
111template<class Scalar>
112bool testMaxErr(
113 const std::string &error_name,
114 const Scalar &error,
115 const std::string &max_error_name,
116 const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &max_error,
117 const std::string &max_warning_name,
118 const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &max_warning,
119 std::ostream *out,
120 const std::string &leadingIndent = std::string("")
121 );
122
123
132template<class Scalar>
133bool testMaxErrors(
134 const std::string &error_name,
135 const ArrayView<const typename Teuchos::ScalarTraits<Scalar>::magnitudeType> &errors,
136 const std::string &max_error_name,
137 const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &max_error,
138 const std::string &max_warning_name,
139 const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &max_warning,
140 const Ptr<std::ostream> &out,
141 const std::string &leadingIndent = std::string("")
142 );
143
144
151bool testBoolExpr(
152 const std::string &boolExprName,
153 const bool &boolExpr,
154 const bool &boolExpected,
155 const Ptr<std::ostream> &out,
156 const std::string &leadingIndent = std::string("")
157 );
158
159
184void printTestResults(
185 const bool result,
186 const std::string &test_summary,
187 const bool show_all_tests,
188 const Ptr<bool> &success,
189 const Ptr<std::ostream> &out
190 );
191
208public:
210 TestResultsPrinter(const RCP<FancyOStream> &out, const bool show_all_tests);
220 void printTestResults(const bool this_result, const Ptr<bool> &success);
221private:
223 bool show_all_tests_;
224 std::ostringstream ossStore_;
226 bool printedTestResults_;
227 TestResultsPrinter(); // Not defined!
228 TestResultsPrinter(const TestResultsPrinter&); // Not defined!
229};
230
231
239template<class Scalar>
240std::ostream& operator<<( std::ostream& o, const VectorBase<Scalar>& v );
241
242
250template<class Scalar>
251std::ostream& operator<<( std::ostream& o, const LinearOpBase<Scalar>& M );
252
253} // namespace Thyra
254
255
256#endif // THYRA_TESTING_TOOLS_DECL_HPP
Base class for all linear operators.
Control printing of test results.
RCP< FancyOStream > getTestOStream()
Return the stream used for testing.
~TestResultsPrinter()
Print the test results on destruction if not already printed.
RCP< FancyOStream > replaceOStream(const RCP< FancyOStream > &out)
Replace the underlying output stream (used for unit testing this class).
void printTestResults(const bool this_result, const Ptr< bool > &success)
Print the test result.
Abstract interface for finite-dimensional dense vectors.
Teuchos::ScalarTraits< Scalar >::magnitudeType relVectorErr(const VectorBase< Scalar > &v1, const VectorBase< Scalar > &v2)
Return relative error of two vectors.
bool testRelErrors(const std::string &v1_name, const ArrayView< const Scalar1 > &v1, const std::string &v2_name, const ArrayView< const Scalar2 > &v2, const std::string &maxRelErr_error_name, const ScalarMag &maxRelErr_error, const std::string &maxRelErr_warning_name, const ScalarMag &maxRelErr_warning, const Ptr< std::ostream > &out, const std::string &leadingIndent=std::string(""))
Compute, check and optionally print the relative errors in two scalar arays.
Teuchos::ScalarTraits< Scalar >::magnitudeType relErr(const Scalar &s1, const Scalar &s2)
const std::string passfail(const bool result)
bool testBoolExpr(const std::string &boolExprName, const bool &boolExpr, const bool &boolExpected, const Ptr< std::ostream > &out, const std::string &leadingIndent=std::string(""))
Check a boolean result against expected result.
bool testMaxErrors(const std::string &error_name, const ArrayView< const typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &errors, const std::string &max_error_name, const typename Teuchos::ScalarTraits< Scalar >::magnitudeType &max_error, const std::string &max_warning_name, const typename Teuchos::ScalarTraits< Scalar >::magnitudeType &max_warning, const Ptr< std::ostream > &out, const std::string &leadingIndent=std::string(""))
Check that an array of errors is less than some error tolerence.
bool testRelNormDiffErr(const std::string &v1_name, const VectorBase< Scalar > &v1, const std::string &v2_name, const VectorBase< Scalar > &v2, const std::string &maxRelErr_error_name, const typename Teuchos::ScalarTraits< Scalar >::magnitudeType &maxRelErr_error, const std::string &maxRelErr_warning_name, const typename Teuchos::ScalarTraits< Scalar >::magnitudeType &maxRelErr_warning, std::ostream *out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::VERB_LOW, const std::string &leadingIndent=std::string(""))
Compute, check and optionally print the relative errors in two vectors.
bool testMaxErr(const std::string &error_name, const Scalar &error, const std::string &max_error_name, const typename Teuchos::ScalarTraits< Scalar >::magnitudeType &max_error, const std::string &max_warning_name, const typename Teuchos::ScalarTraits< Scalar >::magnitudeType &max_warning, std::ostream *out, const std::string &leadingIndent=std::string(""))
Check that an error is less than some error tolerence.
T_To & dyn_cast(T_From &from)
const std::string passfail(const bool result)