Thyra::LinearOpTester< RangeScalar, DomainScalar > Class Template Reference
[Development of linear Abstract Numerical Algorithms (ANAs)]

Testing class for LinearOpBase. More...

#include <Thyra_LinearOpTesterDecl.hpp>

Inheritance diagram for Thyra::LinearOpTester< RangeScalar, DomainScalar >:

[legend]
List of all members.

Public Types

typedef Teuchos::PromotionTraits<
RangeScalar, DomainScalar
>::promote 
Scalar
 Local typedef for promoted scalar type .
typedef Teuchos::ScalarTraits<
Scalar >::magnitudeType 
ScalarMag
 Local typedef for promoted scalar magnitude.

Public Member Functions

 LinearOpTester (const bool check_linear_properties=true, const ScalarMag linear_properties_warning_tol=1e-13, const ScalarMag linear_properties_error_tol=1e-10, const bool check_adjoint=true, const ScalarMag adjoint_warning_tol=1e-13, const ScalarMag adjoint_error_tol=1e-10, const bool check_for_symmetry=false, const ScalarMag symmetry_warning_tol=1e-13, const ScalarMag symmetry_error_tol=1e-10, const int num_random_vectors=1, const bool show_all_tests=false, const bool dump_all=false, const int num_rhs=1)
 Default constructor which sets default parameter values.
void check_linear_properties (const bool &check_linear_properties)
 Set if to check for linear properties alpha*op*(x + y) == op(alpha*x) + op(alpha*y).
void linear_properties_warning_tol (const 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.
void linear_properties_error_tol (const 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.
void check_adjoint (const bool &check_adjoint)
 Set if to check for adjoint property x'*(op*y) == y'*(op'*x) if adjoint is supported.
void adjoint_warning_tol (const ScalarMag &adjoint_warning_tol)
 Set the tolerance above which a relative error will generate a warning message for the check of the adjoint.
void adjoint_error_tol (const 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.
void check_for_symmetry (const bool &check_for_symmetry)
 Set if to check for symmetry property x'*(op*y) == y'*(op*x) for symmetric operators.
void symmetry_warning_tol (const ScalarMag &symmetry_warning_tol)
 Set the tolerance above which a relative error will generate a warning message for the check of symmetry.
void symmetry_error_tol (const 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.
void num_random_vectors (const int &num_random_vectors)
 Set the number random vectors that is generated during each test.
void show_all_tests (const bool &show_all_tests)
 Set if all tests are shown or just summaries.
void dump_all (const bool &dump_all)
 Set if all of the vectors are dumped or not (only relevant if show_all_tests()==true).
void num_rhs (const int &num_rhs)
 Set the number of right-hand-sides in the multivectors.
void enable_all_tests (const bool enable_all_tests)
 Enable or disable all tests.
void set_all_warning_tol (const ScalarMag warning_tol)
 Set all the warning tolerances to the same value.
void set_all_error_tol (const ScalarMag error_tol)
 Set all the error tolerances to the same value.
bool check (const LinearOpBase< RangeScalar, DomainScalar > &op, MultiVectorRandomizerBase< RangeScalar > *rangeRandomizer, MultiVectorRandomizerBase< DomainScalar > *domainRandomizer, Teuchos::FancyOStream *out) const
 Check a linear operator.
bool check (const LinearOpBase< RangeScalar, DomainScalar > &op, Teuchos::FancyOStream *out) const
 Calls this->check(op,NULL,NULL,out,leadingIndent,indentSpacer).
bool compare (const LinearOpBase< RangeScalar, DomainScalar > &op1, const LinearOpBase< RangeScalar, DomainScalar > &op2, MultiVectorRandomizerBase< DomainScalar > *domainRandomizer, Teuchos::FancyOStream *out) const
 Check if two linear operators are the same or not.
bool compare (const LinearOpBase< RangeScalar, DomainScalar > &op1, const LinearOpBase< RangeScalar, DomainScalar > &op2, Teuchos::FancyOStream *out) const
 Calls this->compare(op1,op2,NULL,out,leadingIndent,indentSpacer).

Detailed Description

template<class RangeScalar, class DomainScalar = RangeScalar>
class Thyra::LinearOpTester< RangeScalar, DomainScalar >

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.

Examples:

sillyCgSolve_mpi.cpp, sillyCgSolve_serial.cpp, test_composite_linear_ops.cpp, and test_scalar_product.cpp.

Definition at line 57 of file Thyra_LinearOpTesterDecl.hpp.


Member Typedef Documentation

template<class RangeScalar, class DomainScalar = RangeScalar>
typedef Teuchos::PromotionTraits<RangeScalar,DomainScalar>::promote Thyra::LinearOpTester< RangeScalar, DomainScalar >::Scalar
 

Local typedef for promoted scalar type .

Definition at line 61 of file Thyra_LinearOpTesterDecl.hpp.

template<class RangeScalar, class DomainScalar = RangeScalar>
typedef Teuchos::ScalarTraits<Scalar>::magnitudeType Thyra::LinearOpTester< RangeScalar, DomainScalar >::ScalarMag
 

Local typedef for promoted scalar magnitude.

Definition at line 64 of file Thyra_LinearOpTesterDecl.hpp.


Constructor & Destructor Documentation

template<class RangeScalar, class DomainScalar>
Thyra::LinearOpTester< RangeScalar, DomainScalar >::LinearOpTester const bool  check_linear_properties = true,
const ScalarMag  linear_properties_warning_tol = 1e-13,
const ScalarMag  linear_properties_error_tol = 1e-10,
const bool  check_adjoint = true,
const ScalarMag  adjoint_warning_tol = 1e-13,
const ScalarMag  adjoint_error_tol = 1e-10,
const bool  check_for_symmetry = false,
const ScalarMag  symmetry_warning_tol = 1e-13,
const ScalarMag  symmetry_error_tol = 1e-10,
const int  num_random_vectors = 1,
const bool  show_all_tests = false,
const bool  dump_all = false,
const int  num_rhs = 1
 

Default constructor which sets default parameter values.

Note: It is not recommended that the client pass in values in this constructor since the argument list may change in the near future but instead use the below set functions to change an option after construction.

Definition at line 162 of file Thyra_LinearOpTester.hpp.


Member Function Documentation

template<class RangeScalar, class DomainScalar = RangeScalar>
void Thyra::LinearOpTester< RangeScalar, DomainScalar >::check_linear_properties const bool &  check_linear_properties  )  [inline]
 

Set if to check for linear properties alpha*op*(x + y) == op(alpha*x) + op(alpha*y).

Definition at line 92 of file Thyra_LinearOpTesterDecl.hpp.

template<class RangeScalar, class DomainScalar = RangeScalar>
void Thyra::LinearOpTester< RangeScalar, DomainScalar >::linear_properties_warning_tol const ScalarMag linear_properties_warning_tol  )  [inline]
 

Set the tolerance above which a relative error will generate a warning message for the check of the linear properties.

Definition at line 97 of file Thyra_LinearOpTesterDecl.hpp.

template<class RangeScalar, class DomainScalar = RangeScalar>
void Thyra::LinearOpTester< RangeScalar, DomainScalar >::linear_properties_error_tol const ScalarMag linear_properties_error_tol  )  [inline]
 

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.

Definition at line 103 of file Thyra_LinearOpTesterDecl.hpp.

template<class RangeScalar, class DomainScalar = RangeScalar>
void Thyra::LinearOpTester< RangeScalar, DomainScalar >::check_adjoint const bool &  check_adjoint  )  [inline]
 

Set if to check for adjoint property x'*(op*y) == y'*(op'*x) if adjoint is supported.

Definition at line 108 of file Thyra_LinearOpTesterDecl.hpp.

template<class RangeScalar, class DomainScalar = RangeScalar>
void Thyra::LinearOpTester< RangeScalar, DomainScalar >::adjoint_warning_tol const ScalarMag adjoint_warning_tol  )  [inline]
 

Set the tolerance above which a relative error will generate a warning message for the check of the adjoint.

Definition at line 113 of file Thyra_LinearOpTesterDecl.hpp.

template<class RangeScalar, class DomainScalar = RangeScalar>
void Thyra::LinearOpTester< RangeScalar, DomainScalar >::adjoint_error_tol const ScalarMag adjoint_error_tol  )  [inline]
 

Set the tolerance above which a relative error will generate a error message and result in test failure for the check of the adjoint.

Definition at line 118 of file Thyra_LinearOpTesterDecl.hpp.

template<class RangeScalar, class DomainScalar = RangeScalar>
void Thyra::LinearOpTester< RangeScalar, DomainScalar >::check_for_symmetry const bool &  check_for_symmetry  )  [inline]
 

Set if to check for symmetry property x'*(op*y) == y'*(op*x) for symmetric operators.

Definition at line 123 of file Thyra_LinearOpTesterDecl.hpp.

template<class RangeScalar, class DomainScalar = RangeScalar>
void Thyra::LinearOpTester< RangeScalar, DomainScalar >::symmetry_warning_tol const ScalarMag symmetry_warning_tol  )  [inline]
 

Set the tolerance above which a relative error will generate a warning message for the check of symmetry.

Definition at line 128 of file Thyra_LinearOpTesterDecl.hpp.

template<class RangeScalar, class DomainScalar = RangeScalar>
void Thyra::LinearOpTester< RangeScalar, DomainScalar >::symmetry_error_tol const ScalarMag symmetry_error_tol  )  [inline]
 

Set the tolerance above which a relative error will generate a error message and result in test failure for the check of symmetry.

Definition at line 133 of file Thyra_LinearOpTesterDecl.hpp.

template<class RangeScalar, class DomainScalar = RangeScalar>
void Thyra::LinearOpTester< RangeScalar, DomainScalar >::num_random_vectors const int &  num_random_vectors  )  [inline]
 

Set the number random vectors that is generated during each test.

Definition at line 137 of file Thyra_LinearOpTesterDecl.hpp.

template<class RangeScalar, class DomainScalar = RangeScalar>
void Thyra::LinearOpTester< RangeScalar, DomainScalar >::show_all_tests const bool &  show_all_tests  )  [inline]
 

Set if all tests are shown or just summaries.

Definition at line 141 of file Thyra_LinearOpTesterDecl.hpp.

template<class RangeScalar, class DomainScalar = RangeScalar>
void Thyra::LinearOpTester< RangeScalar, DomainScalar >::dump_all const bool &  dump_all  )  [inline]
 

Set if all of the vectors are dumped or not (only relevant if show_all_tests()==true).

Definition at line 146 of file Thyra_LinearOpTesterDecl.hpp.

template<class RangeScalar, class DomainScalar = RangeScalar>
void Thyra::LinearOpTester< RangeScalar, DomainScalar >::num_rhs const int &  num_rhs  )  [inline]
 

Set the number of right-hand-sides in the multivectors.

Definition at line 150 of file Thyra_LinearOpTesterDecl.hpp.

template<class RangeScalar, class DomainScalar>
void Thyra::LinearOpTester< RangeScalar, DomainScalar >::enable_all_tests const bool  enable_all_tests  ) 
 

Enable or disable all tests.

Postconditions:

Definition at line 193 of file Thyra_LinearOpTester.hpp.

template<class RangeScalar, class DomainScalar>
void Thyra::LinearOpTester< RangeScalar, DomainScalar >::set_all_warning_tol const ScalarMag  warning_tol  ) 
 

Set all the warning tolerances to the same value.

Postconditions:

Definition at line 201 of file Thyra_LinearOpTester.hpp.

template<class RangeScalar, class DomainScalar>
void Thyra::LinearOpTester< RangeScalar, DomainScalar >::set_all_error_tol const ScalarMag  error_tol  ) 
 

Set all the error tolerances to the same value.

Postconditions:

Definition at line 209 of file Thyra_LinearOpTester.hpp.

template<class RangeScalar, class DomainScalar>
bool Thyra::LinearOpTester< RangeScalar, DomainScalar >::check const LinearOpBase< RangeScalar, DomainScalar > &  op,
MultiVectorRandomizerBase< RangeScalar > *  rangeRandomizer,
MultiVectorRandomizerBase< DomainScalar > *  domainRandomizer,
Teuchos::FancyOStream out
const
 

Check a linear operator.

Parameters:
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 $\alpha A ( u + v ) = \alpha A u + \alpha A v$ 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 ETransp.

  • 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 $w$ (in the domain space $\mathcal{D}$) and $u$ (in the range space $\mathcal{R}$), the adjoint operation must obey:

    \[<u,A v>_{\mathcal{R}} = <A^H u, v>_{\mathcal{D}}\]

    where $<.,.>_{\mathcal{R}}$ is the scalar product defined by op.range()->scalarProd() and $<.,.>_{\mathcal{D}}$ 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 $w$ and $u$ in the operator's space $\mathcal{S}$, the following property is checked:

    \[<u,A v>_{\mathcal{S}} = <A u, v>_{\mathcal{S}}\]

    where $<.,.>_{\mathcal{S}}$ 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).

Returns:
The function returns 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:

Definition at line 217 of file Thyra_LinearOpTester.hpp.

template<class RangeScalar, class DomainScalar>
bool Thyra::LinearOpTester< RangeScalar, DomainScalar >::check const LinearOpBase< RangeScalar, DomainScalar > &  op,
Teuchos::FancyOStream out
const
 

Calls this->check(op,NULL,NULL,out,leadingIndent,indentSpacer).

Definition at line 586 of file Thyra_LinearOpTester.hpp.

template<class RangeScalar, class DomainScalar>
bool Thyra::LinearOpTester< RangeScalar, DomainScalar >::compare const LinearOpBase< RangeScalar, DomainScalar > &  op1,
const LinearOpBase< RangeScalar, DomainScalar > &  op2,
MultiVectorRandomizerBase< DomainScalar > *  domainRandomizer,
Teuchos::FancyOStream out
const
 

Check if two linear operators are the same or not.

Parameters:
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).

Returns:
The function returns 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:

Definition at line 595 of file Thyra_LinearOpTester.hpp.

template<class RangeScalar, class DomainScalar>
bool Thyra::LinearOpTester< RangeScalar, DomainScalar >::compare const LinearOpBase< RangeScalar, DomainScalar > &  op1,
const LinearOpBase< RangeScalar, DomainScalar > &  op2,
Teuchos::FancyOStream out
const
 

Calls this->compare(op1,op2,NULL,out,leadingIndent,indentSpacer).

Definition at line 737 of file Thyra_LinearOpTester.hpp.


The documentation for this class was generated from the following files:
Generated on Thu Sep 18 12:32:33 2008 for Thyra Operator/Vector Support by doxygen 1.3.9.1