| # Gaudi Framework, version v21r6 |

Home |  | Generated: 11 Nov 2009

# EqSolver Class Reference

`#include <EqSolver.h>`

Inheritance diagram for EqSolver:

[legend]
Collaboration diagram for EqSolver:

[legend]

List of all members.

## 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.

## 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

## 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 342 of file EqSolver.cpp.

    00343 {}

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           break;
    00228         }
    00229
    00230       status = gsl_multiroot_test_residual (s->f,
    00231                                             m_norm_residual);
    00232
    00233       if ( status != GSL_CONTINUE ) { break; }
    00234     }
    00235
    00236   for (unsigned int i = 0; i < vect.vector.size; ++i)
    00237     {
    00238       gsl_vector_set (&vect.vector, i, gsl_vector_get (s->x, i));
    00239     }
    00240
    00241   if (status == GSL_SUCCESS)
    00242     {
    00243       log << MSG::DEBUG
    00244           << "We stopped in the method on the " << iter
    00245           << " iteration (we have maximum "     << m_max_iter
    00246           << " iterations)"                     << endmsg;
    00247     }
    00248   else if (status == GSL_CONTINUE && iter <= m_max_iter )
    00249     {
    00250       return Error ( "Method finished with '"
    00251                      + std::string(gsl_strerror(status))
    00252                      +  "' error" );
    00253     }
    00254   else
    00255     {
    00256       return Error ( "Method finished with '" +
    00257                      std::string(gsl_strerror(status))
    00258                      +  "' error" );
    00259     }
    00260
    00261   gsl_multiroot_fdfsolver_free (s);
    00262
    00263   if (status)
    00264     {
    00265       return Error ( "Method finished with '"
    00266                      + std::string(gsl_strerror(status))
    00267                      +  "' error" );
    00268     }
    00269
    00270   return GSL_SUCCESS;
    00271 }

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

Overriding initialize.

Reimplemented from GaudiTool.

Definition at line 274 of file EqSolver.cpp.

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

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

standard finalization method

See also:
  AlgTool

  IAlgTool

Returns:
  status code

Reimplemented from GaudiTool.

Definition at line 329 of file EqSolver.cpp.

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

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_v21r6/GaudiGSL/src/Components/EqSolver.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r6/GaudiGSL/src/Components/EqSolver.cpp