Thyra Package Browser (Single Doxygen Collection) Version of the Day
Modules | Functions
CG Examples
Assorted Thyra Operator/Vector Example Code

Here we show some simple examples of using code in the Thyra package with an example ANA algorithm for the iterative solution of symmetric positive-definite linear systems using the conjugate gradient (CG) method. More...

Collaboration diagram for CG Examples:

Modules

 Templated Serial Implementation of the CG Method
 

Here is an example program that shows the use of the example serial templated matrix class ExampleTridiagSerialLinearOp with the example linear ANA implementation sillyCgSolve().


 Templated SPMD Implementation of the CG Method
 

Here is an example program that shows the use of the example SPMD templated matrix class ExampleTridiagSpmdLinearOp with the example linear ANA implementation sillyCgSolve() or silliestCgSolve().


Functions

template<class Scalar >
bool sillyCgSolve (const Thyra::LinearOpBase< Scalar > &A, const Thyra::VectorBase< Scalar > &b, const int maxNumIters, const typename Teuchos::ScalarTraits< Scalar >::magnitudeType tolerance, const Teuchos::Ptr< Thyra::VectorBase< Scalar > > &x, std::ostream &out)
 Silly little example unpreconditioned CG solver.
template<class Scalar >
void sillyModifiedGramSchmidt (Thyra::MultiVectorBase< Scalar > *V_inout, Teuchos::RCP< Thyra::MultiVectorBase< Scalar > > *R_out)
 Silly little implementation of the modified Gram-Schmidt algorithm to compute a QR factorization V=Q*R of a multi-vector V.

Detailed Description

Here we show some simple examples of using code in the Thyra package with an example ANA algorithm for the iterative solution of symmetric positive-definite linear systems using the conjugate gradient (CG) method.

The CG ANA is implemented in the function sillyCgSolve() and its implementation is shown below:

Another version of this CG algorithm is demonstrated in the below function:

This above templated functions are used in the following various example implementations which use several different scalar types:

  1. Templated Serial Implementation of the CG Method

  2. Templated SPMD Implementation of the CG Method


Function Documentation

template<class Scalar >
bool sillyCgSolve ( const Thyra::LinearOpBase< Scalar > &  A,
const Thyra::VectorBase< Scalar > &  b,
const int  maxNumIters,
const typename Teuchos::ScalarTraits< Scalar >::magnitudeType  tolerance,
const Teuchos::Ptr< Thyra::VectorBase< Scalar > > &  x,
std::ostream &  out 
)

Silly little example unpreconditioned CG solver.

This little function is just a silly little ANA that implements the CG (conjugate gradient) method for solving symmetric positive definite systems using the foundational Thyra operator/vector interfaces.

This function is small and is meant to be looked at so study its implementation by clicking on the below link to its definition.

Definition at line 49 of file sillyCgSolve.hpp.

References Thyra::apply(), Thyra::VectorSpaceBase< Scalar >::createMember(), Thyra::LinearOpBase< Scalar >::domain(), Thyra::VectorBase< Scalar >::inner(), Thyra::VectorBase< Scalar >::norm(), Thyra::NOTRANS, THYRA_ASSERT_LINEAR_OP_VEC_APPLY_SPACES, Thyra::VectorBase< Scalar >::V_V(), Thyra::V_V(), Thyra::VectorBase< Scalar >::Vp_StV(), Thyra::MultiVectorBase< Scalar >::Vp_V(), and Thyra::DefaultZeroLinearOp< Scalar >::zero().

Referenced by main(), and runCgSolveExample().

template<class Scalar >
void sillyModifiedGramSchmidt ( Thyra::MultiVectorBase< Scalar > *  V_inout,
Teuchos::RCP< Thyra::MultiVectorBase< Scalar > > *  R_out 
)

Silly little implementation of the modified Gram-Schmidt algorithm to compute a QR factorization V=Q*R of a multi-vector V.

Parameters:
V[in/out] On input, contains the columns to compute the factorization for. On output, contains the columns of Q.
R[out] On output, contains the upper triangular matrix R.

ToDo: Finish documentation!

Definition at line 49 of file sillyModifiedGramSchmidt.hpp.

References Thyra::MultiVectorBase< Scalar >::col(), Thyra::LinearOpBase< Scalar >::domain(), Thyra::n, Thyra::scale(), and Thyra::update().

Referenced by Thyra::DefaultLumpedParameterModelEvaluator< Scalar >::generateParameterBasisMatrix().

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines