Thyra Package Browser (Single Doxygen Collection) Version of the Day
Classes
Templated Serial Implementation of the Power Method
Power Method Examples

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

Collaboration diagram for Templated Serial Implementation of the Power Method:

Classes

class  ExampleTridiagSerialLinearOp< Scalar >
 Simple example subclass for serial tridiagonal matrices. More...

Detailed Description

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

This example program is contained in the source file:

./example/operator_vector/sillyPowerMethod_serial.cpp 

where ./ is the base source directory for Thyra (i.e. ???/Trilinos/packages/Thyra).

The class ExampleTridiagSerialLinearOp that derives from the base class Thyra::SpmdLinearOpBase is quite simple and its complete implementation looks like:

The above serial matrix class is used in an example program (see runPowerMethodExample() below) that calls sillyPowerMethod(). In this example program, the matrix constructed and used is the well-known tridiagonal matrix

\[ A= \left[\begin{array}{rrrrrrrrrr} 2 & -1 \\ -1 & 2 & -1 \\ & \ddots & \ddots & \ddots \\ & & -1 & 2 & -1 \\ & & & -1 & 2 \end{array}\right]. \]

The power method is then run on the matrix $A$ run for a number of iterations (or until convergence to some tolerance).

After this, the first diagonal element $A_{(1,1)}=2$ is then scaled to $A_{(1,1)}=20$ and the power method is run again (which much faster convergence).

The following templated function implements the example described above:

The above templated function runPowerMethodExample() is instantiated with the following scalar types:

and is called multiple times from within the following main() program function:

The above example program is built as part of the Thyra package (unless examples where disabled at configure time) and the executable can be found at:

./example/operator_vector/sillyPowerMethod_serial.exe 

where ./ is the base build directory for Thyra (e.g. $TRILINOS_BUILD_DIR/packages/thyra).

This example program should run successfully with no arguments and produces the following output:

This example program also takes a number of command-line options. To see what the command-line options are, use the --help option. The command-line options returned from ./sillyPowerMethod_serial.exe --echo-command-line --help are:

To see the full listing of this example program click: sillyPowerMethod_serial.cpp

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines