Thyra
Version of the Day
|
Testing class for LinearOpBase
.
More...
#include <Thyra_LinearOpTester_decl.hpp>
Public Types | |
typedef Teuchos::ScalarTraits < Scalar >::magnitudeType | ScalarMag |
Local typedef for promoted scalar magnitude. More... | |
Public Member Functions | |
LinearOpTester () | |
Default constructor which sets default parameter values. More... | |
STANDARD_MEMBER_COMPOSITION_MEMBERS (bool, check_linear_properties) | |
Set if to check for linear properties alpha*op*(x + y) == op(alpha*x) + op(alpha*y) More... | |
STANDARD_MEMBER_COMPOSITION_MEMBERS (ScalarMag, linear_properties_warning_tol) | |
Set the tolerance above which a relative error will generate a warning message for the check of the linear properties. More... | |
STANDARD_MEMBER_COMPOSITION_MEMBERS (ScalarMag, linear_properties_error_tol) | |
Set the tolerance above which a relative error will generate a error message and result in test failure for the check of the linear properties. More... | |
STANDARD_MEMBER_COMPOSITION_MEMBERS (bool, check_adjoint) | |
Set if to check for adjoint property x'*(op*y) == y'*(op'*x) if adjoint is supported. More... | |
STANDARD_MEMBER_COMPOSITION_MEMBERS (ScalarMag, adjoint_warning_tol) | |
Set the tolerance above which a relative error will generate a warning message for the check of the adjoint. More... | |
STANDARD_MEMBER_COMPOSITION_MEMBERS (ScalarMag, adjoint_error_tol) | |
Set the tolerance above which a relative error will generate a error message and result in test failure for the check of the adjoint. More... | |
STANDARD_MEMBER_COMPOSITION_MEMBERS (bool, check_for_symmetry) | |
Set if to check for symmetry property x'*(op*y) == y'*(op*x) for symmetric operators. More... | |
STANDARD_MEMBER_COMPOSITION_MEMBERS (ScalarMag, symmetry_warning_tol) | |
Set the tolerance above which a relative error will generate a warning message for the check of symmetry. More... | |
STANDARD_MEMBER_COMPOSITION_MEMBERS (ScalarMag, symmetry_error_tol) | |
Set the tolerance above which a relative error will generate a error message and result in test failure for the check of symmetry. More... | |
STANDARD_MEMBER_COMPOSITION_MEMBERS (int, num_random_vectors) | |
Set the number random vectors that is generated during each test. More... | |
STANDARD_MEMBER_COMPOSITION_MEMBERS (bool, show_all_tests) | |
Set if all tests are shown or just summaries. More... | |
STANDARD_MEMBER_COMPOSITION_MEMBERS (bool, dump_all) | |
Set if all of the vectors are dumped or not (only relevant if show_all_tests()==true ). More... | |
STANDARD_MEMBER_COMPOSITION_MEMBERS (int, num_rhs) | |
Set the number of right-hand-sides in the multivectors. More... | |
void | enable_all_tests (const bool enable_all_tests) |
Enable or disable all tests. More... | |
void | set_all_warning_tol (const ScalarMag warning_tol) |
Set all the warning tolerances to the same value. More... | |
void | set_all_error_tol (const ScalarMag error_tol) |
Set all the error tolerances to the same value. More... | |
bool | check (const LinearOpBase< Scalar > &op, const Ptr< MultiVectorRandomizerBase< Scalar > > &rangeRandomizer, const Ptr< MultiVectorRandomizerBase< Scalar > > &domainRandomizer, const Ptr< FancyOStream > &out) const |
Check a linear operator. More... | |
bool | check (const LinearOpBase< Scalar > &op, const Ptr< FancyOStream > &out) const |
Calls this->check(op,null,null,out,leadingIndent,indentSpacer) More... | |
bool | compare (const LinearOpBase< Scalar > &op1, const LinearOpBase< Scalar > &op2, const Ptr< MultiVectorRandomizerBase< Scalar > > &domainRandomizer, const Ptr< FancyOStream > &out_arg) const |
Check if two linear operators are the same or not. More... | |
bool | compare (const LinearOpBase< Scalar > &op1, const LinearOpBase< Scalar > &op2, const Ptr< FancyOStream > &out_arg) const |
Calls this->compare(op1,op2,NULL,out,leadingIndent,indentSpacer) . More... | |
Testing class for LinearOpBase
.
This testing class performs many different tests just given a LinearOpBase
object using the function check()
.
This testing class also can check if two linear operators are the same using random vectors by using the function compare()
.
ToDo: Finish documentation!
The default compiler-generated copy constructor and assignment operators are allowed since they have the correct semantics which are to simply copy control parameters.
Definition at line 42 of file Thyra_LinearOpTester_decl.hpp.
typedef Teuchos::ScalarTraits<Scalar>::magnitudeType Thyra::LinearOpTester< Scalar >::ScalarMag |
Local typedef for promoted scalar magnitude.
Definition at line 46 of file Thyra_LinearOpTester_decl.hpp.
Thyra::LinearOpTester< Scalar >::LinearOpTester | ( | ) |
Default constructor which sets default parameter values.
See the implementation of this function for the defaults that get set.
Definition at line 122 of file Thyra_LinearOpTester_def.hpp.
Thyra::LinearOpTester< Scalar >::STANDARD_MEMBER_COMPOSITION_MEMBERS | ( | bool | , |
check_linear_properties | |||
) |
Set if to check for linear properties alpha*op*(x + y) == op(alpha*x) + op(alpha*y)
Thyra::LinearOpTester< Scalar >::STANDARD_MEMBER_COMPOSITION_MEMBERS | ( | ScalarMag | , |
linear_properties_warning_tol | |||
) |
Set the tolerance above which a relative error will generate a warning message for the check of the linear properties.
Thyra::LinearOpTester< Scalar >::STANDARD_MEMBER_COMPOSITION_MEMBERS | ( | ScalarMag | , |
linear_properties_error_tol | |||
) |
Set the tolerance above which a relative error will generate a error message and result in test failure for the check of the linear properties.
Thyra::LinearOpTester< Scalar >::STANDARD_MEMBER_COMPOSITION_MEMBERS | ( | bool | , |
check_adjoint | |||
) |
Set if to check for adjoint property x'*(op*y) == y'*(op'*x)
if adjoint is supported.
Thyra::LinearOpTester< Scalar >::STANDARD_MEMBER_COMPOSITION_MEMBERS | ( | ScalarMag | , |
adjoint_warning_tol | |||
) |
Set the tolerance above which a relative error will generate a warning message for the check of the adjoint.
Thyra::LinearOpTester< Scalar >::STANDARD_MEMBER_COMPOSITION_MEMBERS | ( | ScalarMag | , |
adjoint_error_tol | |||
) |
Set the tolerance above which a relative error will generate a error message and result in test failure for the check of the adjoint.
Thyra::LinearOpTester< Scalar >::STANDARD_MEMBER_COMPOSITION_MEMBERS | ( | bool | , |
check_for_symmetry | |||
) |
Set if to check for symmetry property x'*(op*y) == y'*(op*x)
for symmetric operators.
Thyra::LinearOpTester< Scalar >::STANDARD_MEMBER_COMPOSITION_MEMBERS | ( | ScalarMag | , |
symmetry_warning_tol | |||
) |
Set the tolerance above which a relative error will generate a warning message for the check of symmetry.
Thyra::LinearOpTester< Scalar >::STANDARD_MEMBER_COMPOSITION_MEMBERS | ( | ScalarMag | , |
symmetry_error_tol | |||
) |
Set the tolerance above which a relative error will generate a error message and result in test failure for the check of symmetry.
Thyra::LinearOpTester< Scalar >::STANDARD_MEMBER_COMPOSITION_MEMBERS | ( | int | , |
num_random_vectors | |||
) |
Set the number random vectors that is generated during each test.
Thyra::LinearOpTester< Scalar >::STANDARD_MEMBER_COMPOSITION_MEMBERS | ( | bool | , |
show_all_tests | |||
) |
Set if all tests are shown or just summaries.
Thyra::LinearOpTester< Scalar >::STANDARD_MEMBER_COMPOSITION_MEMBERS | ( | bool | , |
dump_all | |||
) |
Set if all of the vectors are dumped or not (only relevant if show_all_tests()==true
).
Thyra::LinearOpTester< Scalar >::STANDARD_MEMBER_COMPOSITION_MEMBERS | ( | int | , |
num_rhs | |||
) |
Set the number of right-hand-sides in the multivectors.
void Thyra::LinearOpTester< Scalar >::enable_all_tests | ( | const bool | enable_all_tests | ) |
Enable or disable all tests.
Postconditions:
this->check_linear_properties()==enable_all_tests
this->check_adjoint()==enable_all_tests
this->check_for_symmetry()==enable_all_tests
Definition at line 142 of file Thyra_LinearOpTester_def.hpp.
void Thyra::LinearOpTester< Scalar >::set_all_warning_tol | ( | const ScalarMag | warning_tol | ) |
Set all the warning tolerances to the same value.
Postconditions:
this->linear_properties_warning_tol()==warning_tol
this->adjoint_warning_tol()==warning_tol
this->symmetry_warning_tol()==warning_tol
Definition at line 151 of file Thyra_LinearOpTester_def.hpp.
void Thyra::LinearOpTester< Scalar >::set_all_error_tol | ( | const ScalarMag | error_tol | ) |
Set all the error tolerances to the same value.
Postconditions:
this->linear_properties_error_tol()==error_tol
this->adjoint_error_tol()==error_tol
this->symmetry_error_tol()==error_tol
Definition at line 160 of file Thyra_LinearOpTester_def.hpp.
bool Thyra::LinearOpTester< Scalar >::check | ( | const LinearOpBase< Scalar > & | op, |
const Ptr< MultiVectorRandomizerBase< Scalar > > & | rangeRandomizer, | ||
const Ptr< MultiVectorRandomizerBase< Scalar > > & | domainRandomizer, | ||
const Ptr< FancyOStream > & | out | ||
) | const |
Check a linear operator.
op | [in] The linear operator to check. |
out | [in/out] If out!=NULL then trace output about the tests performed will be sent to *out . |
rangeRandomizer | [in] Randomizer strategy object for creating random vectors in the range of the operator op . If NULL then UniveralMultiVectorRandomizer is used intead. |
domainRandomizer | [in] Randomizer strategy object for creating random vectors in the domain of the operator op . If NULL then UniveralMultiVectorRandomizer is used intead. |
Preconditions:
rangeRandomizer!=NULL
] rangeRandomizer->isCompatible(*op.range())==true
domainRandomizer!=NULL
] domainRandomizer->isCompatible(*op.domain())==true
This function performs a number of tests on op
:
Checks that the domain and range spaces are valid.
Creates temporary vectors using the domain and range spaces.
If this->check_linear_properties()==true
then checks that to a relative tolerance defined by error_tol()
. Note, if the client wants to check the linear properties of the adjoint then the client should first create an implicit adjoint using adjoint()
(or transpose using transpose()
) which wraps the operation in a DefaultScaledAdjointLinearOp
. Using this method a client can check all the various values of the enum EOpTransp
.
If this->check_adjoint()==true
then, checks that the non-transposed operator and the adjoint operator agree. The operator and adjoint operator must obey the defined scalar product. Specifically, for any two vectors (in the domain space ) and (in the range space ), the adjoint operation must obey:
where is the scalar product defined by op.range()->scalarProd()
and is the scalar product defined by op.domain()->scalarProd()
.
If this->check_for_symmetry()==true
the the operator will be checked to see if it is symmetric. Specifically, for any two random vectors and in the operator's space , the following property is checked:
where is the scalar product defined by op.domain()->scalarProd()
and op.domain()->scalarProd()
.
All relative errors that exceed xxx_warning_tol()
but do not exceed xxx_error_tol
will result in special warning messages printed to *out
(if out!=NULL
).
true
if all of the tests where within the xxx_error_tol()
and returns false
if not.The best way to see what this testing function is doing is to run the test with out!=NULL
and to look at the implementation by clicking on the following link to the source code:
bool Thyra::LinearOpTester< Scalar >::check | ( | const LinearOpBase< Scalar > & | op, |
const Ptr< FancyOStream > & | out | ||
) | const |
Calls this->check(op,null,null,out,leadingIndent,indentSpacer)
bool Thyra::LinearOpTester< Scalar >::compare | ( | const LinearOpBase< Scalar > & | op1, |
const LinearOpBase< Scalar > & | op2, | ||
const Ptr< MultiVectorRandomizerBase< Scalar > > & | domainRandomizer, | ||
const Ptr< FancyOStream > & | out_arg | ||
) | const |
Check if two linear operators are the same or not.
op1 | [in] The first linear operator |
op2 | [in] The second linear operator |
domainRandomizer | [in] Randomizer strategy object for creating random vectors in the domain of the operator op . If NULL then UniveralMultiVectorRandomizer is used intead. |
out | [in/out] If out!=NULL then trace output about the tests performed will be sent to *out . |
leadingIndent | [in] All output to *out will insert this spacer before each new line is printed. Default value "" . |
indentSpacer | [in] All output to *out that is further indented will use this indentation. Default value " " . |
This function checks if op1
and op2
are the same by checking that the range and domain spaces are compatible and then checking that sum(op1*v) == sum(op2*v)
for various random vectors. The allowed warning and error tolerances are taken from linear_properties_warning_tol()
and linear_properties_error_tol()
.
All relative errors that exceed xxx_warning_tol()
but do not exceed xxx_error_tol
will result in special warning messages printed to *out
(if out!=NULL
).
true
if all of the tests where within the xxx_error_tol()
and returns false
if not.The best way to see what this testing function is doing is to run the test with out!=NULL
and to look at the implementation by clicking on the following link to the source code:
bool Thyra::LinearOpTester< Scalar >::compare | ( | const LinearOpBase< Scalar > & | op1, |
const LinearOpBase< Scalar > & | op2, | ||
const Ptr< FancyOStream > & | out_arg | ||
) | const |
Calls this->compare(op1,op2,NULL,out,leadingIndent,indentSpacer)
.