| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

# EqSolver Class Reference

The simplest concrete implementation of IEqSolver interface. More...

`#include <EqSolver.h>`

Inheritance diagram for EqSolver:

[legend]
Collaboration diagram for EqSolver:

[legend]

List of all members.

## Public Types
typedef std::vector< Equations > | Jacobi
## Public Member Functions
virtual StatusCode | solver (const Equations &funcs, Arg &arg) const
| Solving nonlinear system with N equations in N unknowns of the function "GenFunc".
virtual StatusCode | initialize ()
| Overriding initialize.
virtual StatusCode | finalize ()
| standard finalization method
virtual | ~EqSolver ()
| Destructor.
| EqSolver (const std::string &type, const std::string &name, const IInterface *parent)
| Standard constructor.
## Private Member Functions
| EqSolver ()
| default constructor is private
| EqSolver (const EqSolver &)
| copy constructor is private
EqSolver & | operator= (const EqSolver &)
| assignment operator is
## Private Attributes
std::string | m_algType
double | m_max_iter
double | m_norm_residual
const gsl_multiroot_fdfsolver_type * | m_type
| AlgTool type (concrete class name).
## Friends
class | ToolFactory< EqSolver >
## Classes
class | EqSolverMisc

## Detailed Description

The simplest concrete implementation of IEqSolver interface.

See also:
  GaudiGSL/IEqSolver.h

Author:
  Kirill Miklyaev kirillm@iris1.itep.ru

Date:
  2003-07-07

Definition at line 28 of file EqSolver.h.

## Member Typedef Documentation

typedef std::vector<Equations> EqSolver::Jacobi

Definition at line 32 of file EqSolver.h.

## Constructor & Destructor Documentation

EqSolver::~EqSolver | ( |  | ) | `[virtual]`

Destructor.

Definition at line 341 of file EqSolver.cpp.

    00342 {}

EqSolver::EqSolver | ( | const std::string & | type,
|  | const std::string & | name,
|  | const IInterface * | parent |
| ) |  |  |

Standard constructor.

See also:
  GaudiTool

Parameters:

  | type | tool type
  | name | tool name
  | parent | parent of the tool

declare type of the algorithm for root finding

declare maximum of iteration

declare the absolute error bound for the residual value

Definition at line 75 of file EqSolver.cpp.

    00078   : base_class      ( type, name , parent )
    00079   , m_algType       ( "fdfsolver_hybridsj" )
    00080   , m_max_iter      ( 1000                 )
    00081   , m_norm_residual ( 1.0e-7               )
    00082   , m_type          ( 0                    )
    00083
    00084 {
    00086   declareProperty ( "Algorithm", m_algType       );
    00088   declareProperty ( "Iteration", m_max_iter      );
    00090   declareProperty ( "Residual" , m_norm_residual );
    00091 }

EqSolver::EqSolver | ( |  | ) | `[private]`

default constructor is private

EqSolver::EqSolver | ( | const EqSolver & |  | ) | `[private]`

copy constructor is private

## Member Function Documentation

StatusCode EqSolver::solver | ( | const Equations & | funcs,
|  | Arg & | arg |
| ) |  |  | const`[virtual]`

Solving nonlinear system with N equations in N unknowns of the function "GenFunc".

Solving nonlinear system of the function "GenFunc".

See also:
  IEqSolver.h

Returns:
  StatusCode

Definition at line 191 of file EqSolver.cpp.

    00194 {
    00195   using namespace Genfun;
    00196
    00197   gsl_vector_view vect = gsl_vector_view_array ( &arg[0] ,
    00198                                                  arg.dimension() );
    00199   MsgStream log( msgSvc(), name() );
    00200
    00201   EqSolverMisc local (funcs, arg);
    00202
    00203   const gsl_multiroot_fdfsolver_type *T = m_type;
    00204   gsl_multiroot_fdfsolver *s;
    00205   int    status = 0 ;
    00206   size_t iter   = 0 ;
    00207
    00208   gsl_multiroot_function_fdf function;
    00209
    00210   function.f = &fun_gsl;
    00211   function.df = &dfun_gsl;
    00212   function.fdf = &fdfun_gsl;
    00213   function.n = vect.vector.size;
    00214   function.params = (void*) &local;
    00215
    00216   s = gsl_multiroot_fdfsolver_alloc(T, vect.vector.size);
    00217   gsl_multiroot_fdfsolver_set (s, &function, &vect.vector);
    00218
    00219   for (iter = 0; iter < m_max_iter; ++iter)
    00220     {
    00221       status = gsl_multiroot_fdfsolver_iterate (s);
    00222       if (status)
    00223         {
    00224           return Error
    00225             ("Error from gsl_gsl_multiroot_fdfsolver_iterate '"
    00226              + std::string(gsl_strerror(status)) + "'") ;
    00227         }
    00228
    00229       status = gsl_multiroot_test_residual (s->f,
    00230                                             m_norm_residual);
    00231
    00232       if ( status != GSL_CONTINUE ) { break; }
    00233     }
    00234
    00235   for (unsigned int i = 0; i < vect.vector.size; ++i)
    00236     {
    00237       gsl_vector_set (&vect.vector, i, gsl_vector_get (s->x, i));
    00238     }
    00239
    00240   if (status == GSL_SUCCESS)
    00241     {
    00242       log << MSG::DEBUG
    00243           << "We stopped in the method on the " << iter
    00244           << " iteration (we have maximum "     << m_max_iter
    00245           << " iterations)"                     << endmsg;
    00246     }
    00247   else if (status == GSL_CONTINUE && iter <= m_max_iter )
    00248     {
    00249       return Error ( "Method finished with '"
    00250                      + std::string(gsl_strerror(status))
    00251                      +  "' error" );
    00252     }
    00253   else
    00254     {
    00255       return Error ( "Method finished with '" +
    00256                      std::string(gsl_strerror(status))
    00257                      +  "' error" );
    00258     }
    00259
    00260   gsl_multiroot_fdfsolver_free (s);
    00261
    00262   if (status)
    00263     {
    00264       return Error ( "Method finished with '"
    00265                      + std::string(gsl_strerror(status))
    00266                      +  "' error" );
    00267     }
    00268
    00269   return GSL_SUCCESS;
    00270 }

StatusCode EqSolver::initialize | ( |  | ) | `[virtual]`

Overriding initialize.

Reimplemented from GaudiTool.

Definition at line 273 of file EqSolver.cpp.

    00275 {
    00276   StatusCode sc = GaudiTool::initialize() ;
    00277
    00278   MsgStream log( msgSvc() , name() ) ;
    00279
    00280   if( sc.isFailure() )
    00281     {
    00282       return Error ("Could not initiliaze base class GaudiTool", sc);
    00283     }
    00284   /* The algorithm for multiional root-finding
    00285      (solving nonlinear systems with n equations in n unknowns)*/
    00286
    00287   if(       "fdfsolver_hybridsj" == m_algType )
    00288     {
    00289       m_type = gsl_multiroot_fdfsolver_hybridsj  ;
    00290       log << MSG::DEBUG
    00291           << "Root findind algoritms to be used: "
    00292           << "'gsl_multiroot_fdfsolver_hybridsj'"
    00293           << endmsg;
    00294     }
    00295   else if ( "fdfsolver_hybridj" == m_algType )
    00296     {
    00297       m_type = gsl_multiroot_fdfsolver_hybridj   ;
    00298       log << MSG::DEBUG
    00299           << "Root findind algoritms to be used: "
    00300           << "'gsl_multiroot_fdfsolver_hybridj'"
    00301           << endmsg;
    00302     }
    00303   else if ( "fdfsolver_newton" == m_algType )
    00304     {
    00305       m_type = gsl_multiroot_fdfsolver_newton    ;
    00306       log << MSG::DEBUG
    00307           << "Root findind algoritms to be used: "
    00308           << "'gsl_multiroot_fdfsolver_newton'"
    00309           << endmsg;
    00310     }
    00311   else if ( "fdfsolver_gnewton" == m_algType )
    00312     {
    00313       m_type = gsl_multiroot_fdfsolver_gnewton   ;
    00314       log << MSG::DEBUG
    00315           << "Root findind algoritms to be used: "
    00316           << "'gsl_multiroot_fdfsolver_gnewton'"
    00317           << endmsg;
    00318     }
    00319   else
    00320     {
    00321       return Error(" Unknown algorith type '"
    00322                    + std::string(m_algType) + "'");
    00323      }
    00324
    00325   return StatusCode::SUCCESS;
    00326 }

StatusCode EqSolver::finalize | ( |  | ) | `[virtual]`

standard finalization method

See also:
  AlgTool

  IAlgTool

Returns:
  status code

Reimplemented from GaudiTool.

Definition at line 328 of file EqSolver.cpp.

    00329 {
    00330   StatusCode sc = GaudiTool::finalize() ;
    00331
    00332   MsgStream log( msgSvc() , name() ) ;
    00333
    00334   if ( sc.isFailure() )
    00335     {
    00336       return Error("Could not finaliaze base class GaudiTool", sc);
    00337     }
    00338   return StatusCode::SUCCESS;
    00339 }

EqSolver& EqSolver::operator= | ( | const EqSolver & |  | ) | `[private]`

assignment operator is

## Friends And Related Function Documentation

friend class ToolFactory< EqSolver >`[friend]`

Definition at line 30 of file EqSolver.h.

## Member Data Documentation

std::string EqSolver::m_algType`[private]`

Definition at line 99 of file EqSolver.h.

double EqSolver::m_max_iter`[private]`

Definition at line 100 of file EqSolver.h.

double EqSolver::m_norm_residual`[private]`

Definition at line 101 of file EqSolver.h.

const gsl_multiroot_fdfsolver_type* EqSolver::m_type`[private]`

AlgTool type (concrete class name).

Reimplemented from AlgTool.

Definition at line 102 of file EqSolver.h.

The documentation for this class was generated from the following files:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r10p1/GaudiGSL/src/Components/EqSolver.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r10p1/GaudiGSL/src/Components/EqSolver.cpp