Test solver for constrained Eigenvalue problems. More...

#include <constrained.hh>

Inheritance diagram for test::GolubExample:
test::ConstrainedEVP test::TestCase

Public Member Functions

void _succeed ()
 Explicitly succeds a test. More...
 
long getNumFailed () const
 Returns number of failed tests. More...
 
long getNumPassed () const
 Returns number of passed tests. More...
 
const ostream * getStream () const
 Returns output stream. More...
 
 GolubExample ()
 Constructor. Sets up three matrices a, b and c. More...
 
long report () const
 Prints a report on the number of passed and failed tests to the output stream. More...
 
virtual void reset ()
 Resets the counters for the failed and passed tests. More...
 
virtual void run ()
 Runs the tests. Must be overwritten by the specialization. More...
 
void setStream (ostream *osptr)
 Sets the output stream. More...
 
void testInexactInv ()
 Test with inexact inverse iteration. More...
 
virtual ~GolubExample ()
 

Protected Member Functions

void do_fail (const string &lbl, const char *fname, long lineno)
 Internal function to report a failed test (besides increasing the failed counter) More...
 
bool do_numtest (double num, double orig, const string &lbl, const string &lbl2, const char *fname, long lineno, const double tol=1e-10)
 Internal function to do a numerical test. More...
 
bool do_numtest (std::complex< double > num, std::complex< double > orig, const string &lbl, const string &lbl2, const char *fname, long lineno, const double tol=1e-10)
 
bool do_test (bool cond, const string &lbl, const char *fname, long lineno)
 Internal function to do a test. More...
 

Protected Attributes

std::unique_ptr< concepts::Operator< Real > > a
 
concepts::SparseMatrix< Real > b
 
concepts::SparseMatrix< Real > c
 
concepts::DummySpace< Real > cspc
 
const Real * exact_
 
concepts::DummySpace< Real > gspc
 
const uint kmax_
 
concepts::DummySpace< Real > spc
 

Private Member Functions

void testResults (const concepts::Array< Real > &res)
 

Private Attributes

long m_nFail
 
long m_nPass
 
ostream * m_osptr
 

Static Private Attributes

static const Real exact [4]
 

Detailed Description

Test solver for constrained Eigenvalue problems.

The example and the exact solution is taken from [1]. The constrained generalized Eigenvalue problem reads:

\[ Ax = \lambda B x\]

subject to $ Cx = 0 $, where

\[ A = \begin{pmatrix} 1 & -1 & 0 & 0 & 0 & 0 \\ -1 & 2 & -1 & 0 & 0 & 0 \\ 0 & -1 & 2 & -1 & 0 & 0 \\ 0 & 0 & -1 & 2 & -1 & 0 \\ 0 & 0 & 0 & -1 & 2 & -1 \\ 0 & 0 & 0 & 0 & -1 & 2 \end{pmatrix}, B = \begin{pmatrix} 6 & 5 & 4 & 3 & 2 & 1 \\ 5 & 5 & 4 & 3 & 2 & 1 \\ 4 & 4 & 4 & 3 & 2 & 1 \\ 3 & 3 & 3 & 3 & 2 & 1 \\ 2 & 2 & 2 & 2 & 2 & 1 \\ 1 & 1 & 1 & 1 & 1 & 1 \end{pmatrix}, C^\top = \begin{pmatrix} 1 & 1 & 8 & 5 \\ 1 & -1 & 2 & 1 \\ 1 & 1 & 8 & 5 \\ 1 & -1 & 2 & 1 \\ 1 & 1 & 8 & 5 \\ 1 & -1 & 2 & 1 \end{pmatrix}. \]

The exact Eigenvalues of this problem are 0.170039264847579, 1.23788202328080, 4.9176011926100, 9.2744775192616.

Author
Philipp Frauenfelder, 2004
See also
[1] Gene H. Golub and Richard Underwood, Stationary Values of the Ratio of Quadratic Forms Subject to Linear Constraints, ZAMP Vol. 21, 1970, p. 318-326.

Definition at line 86 of file constrained.hh.

Constructor & Destructor Documentation

◆ GolubExample()

test::GolubExample::GolubExample ( )

Constructor. Sets up three matrices a, b and c.

◆ ~GolubExample()

virtual test::GolubExample::~GolubExample ( )
inlinevirtual

Definition at line 90 of file constrained.hh.

Member Function Documentation

◆ _succeed()

void test::TestCase::_succeed ( )
inlineinherited

Explicitly succeds a test.

Definition at line 112 of file testcase.hh.

◆ do_fail()

void test::TestCase::do_fail ( const string &  lbl,
const char *  fname,
long  lineno 
)
protectedinherited

Internal function to report a failed test (besides increasing the failed counter)

◆ do_numtest() [1/2]

bool test::TestCase::do_numtest ( double  num,
double  orig,
const string &  lbl,
const string &  lbl2,
const char *  fname,
long  lineno,
const double  tol = 1e-10 
)
protectedinherited

Internal function to do a numerical test.

◆ do_numtest() [2/2]

bool test::TestCase::do_numtest ( std::complex< double >  num,
std::complex< double >  orig,
const string &  lbl,
const string &  lbl2,
const char *  fname,
long  lineno,
const double  tol = 1e-10 
)
protectedinherited

◆ do_test()

bool test::TestCase::do_test ( bool  cond,
const string &  lbl,
const char *  fname,
long  lineno 
)
protectedinherited

Internal function to do a test.

◆ getNumFailed()

long test::TestCase::getNumFailed ( ) const
inlineinherited

Returns number of failed tests.

Definition at line 105 of file testcase.hh.

◆ getNumPassed()

long test::TestCase::getNumPassed ( ) const
inlineinherited

Returns number of passed tests.

Definition at line 103 of file testcase.hh.

◆ getStream()

const ostream* test::TestCase::getStream ( ) const
inlineinherited

Returns output stream.

Definition at line 107 of file testcase.hh.

◆ report()

long test::TestCase::report ( ) const
inherited

Prints a report on the number of passed and failed tests to the output stream.

Returns
Number of failed tests.

◆ reset()

virtual void test::TestCase::reset ( )
inlinevirtualinherited

Resets the counters for the failed and passed tests.

Definition at line 119 of file testcase.hh.

◆ run()

virtual void test::ConstrainedEVP::run ( )
virtualinherited

Runs the tests. Must be overwritten by the specialization.

Implements test::TestCase.

◆ setStream()

void test::TestCase::setStream ( ostream *  osptr)
inlineinherited

Sets the output stream.

Definition at line 109 of file testcase.hh.

◆ testInexactInv()

void test::ConstrainedEVP::testInexactInv ( )
inherited

Test with inexact inverse iteration.

◆ testResults()

void test::ConstrainedEVP::testResults ( const concepts::Array< Real > &  res)
privateinherited

Member Data Documentation

◆ a

std::unique_ptr<concepts::Operator<Real> > test::ConstrainedEVP::a
protectedinherited

Definition at line 50 of file constrained.hh.

◆ b

concepts::SparseMatrix<Real> test::ConstrainedEVP::b
protectedinherited

Definition at line 51 of file constrained.hh.

◆ c

concepts::SparseMatrix<Real> test::ConstrainedEVP::c
protectedinherited

Definition at line 51 of file constrained.hh.

◆ cspc

concepts::DummySpace<Real> test::ConstrainedEVP::cspc
protectedinherited

Definition at line 49 of file constrained.hh.

◆ exact

const Real test::GolubExample::exact[4]
staticprivate

Definition at line 92 of file constrained.hh.

◆ exact_

const Real* test::ConstrainedEVP::exact_
protectedinherited

Definition at line 52 of file constrained.hh.

◆ gspc

concepts::DummySpace<Real> test::ConstrainedEVP::gspc
protectedinherited

Definition at line 49 of file constrained.hh.

◆ kmax_

const uint test::ConstrainedEVP::kmax_
protectedinherited

Definition at line 53 of file constrained.hh.

◆ m_nFail

long test::TestCase::m_nFail
privateinherited

Definition at line 139 of file testcase.hh.

◆ m_nPass

long test::TestCase::m_nPass
privateinherited

Definition at line 138 of file testcase.hh.

◆ m_osptr

ostream* test::TestCase::m_osptr
privateinherited

Definition at line 137 of file testcase.hh.

◆ spc

concepts::DummySpace<Real> test::ConstrainedEVP::spc
protectedinherited

Definition at line 49 of file constrained.hh.


The documentation for this class was generated from the following file:
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich