| # Gaudi Framework, version v22r2 |

Home |  | Generated: Tue May 10 2011

Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends

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

## Classes
class | EqSolverMisc
## 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 >

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

    {}

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.

      : base_class      ( type, name , parent )
      , m_algType       ( "fdfsolver_hybridsj" )
      , m_max_iter      ( 1000                 )
      , m_norm_residual ( 1.0e-7               )
      , m_type          ( 0                    )

    {
      declareProperty ( "Algorithm", m_algType       );
      declareProperty ( "Iteration", m_max_iter      );
      declareProperty ( "Residual" , m_norm_residual );
    }

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

default constructor is private

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

copy constructor is private

## Member Function Documentation

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

standard finalization method

See also:
  AlgTool
  IAlgTool

Returns:
  status code

Reimplemented from GaudiTool.

Definition at line 328 of file EqSolver.cpp.

    {
      StatusCode sc = GaudiTool::finalize() ;

      MsgStream log( msgSvc() , name() ) ;

      if ( sc.isFailure() )
        {
          return Error("Could not finaliaze base class GaudiTool", sc);
        }
      return StatusCode::SUCCESS;
    }

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

Overriding initialize.

Reimplemented from GaudiTool.

Definition at line 273 of file EqSolver.cpp.

    {
      StatusCode sc = GaudiTool::initialize() ;

      MsgStream log( msgSvc() , name() ) ;

      if( sc.isFailure() )
        {
          return Error ("Could not initiliaze base class GaudiTool", sc);
        }
      /* The algorithm for multiional root-finding
         (solving nonlinear systems with n equations in n unknowns)*/

      if(       "fdfsolver_hybridsj" == m_algType )
        {
          m_type = gsl_multiroot_fdfsolver_hybridsj  ;
          log << MSG::DEBUG
              << "Root findind algoritms to be used: "
              << "'gsl_multiroot_fdfsolver_hybridsj'"
              << endmsg;
        }
      else if ( "fdfsolver_hybridj" == m_algType )
        {
          m_type = gsl_multiroot_fdfsolver_hybridj   ;
          log << MSG::DEBUG
              << "Root findind algoritms to be used: "
              << "'gsl_multiroot_fdfsolver_hybridj'"
              << endmsg;
        }
      else if ( "fdfsolver_newton" == m_algType )
        {
          m_type = gsl_multiroot_fdfsolver_newton    ;
          log << MSG::DEBUG
              << "Root findind algoritms to be used: "
              << "'gsl_multiroot_fdfsolver_newton'"
              << endmsg;
        }
      else if ( "fdfsolver_gnewton" == m_algType )
        {
          m_type = gsl_multiroot_fdfsolver_gnewton   ;
          log << MSG::DEBUG
              << "Root findind algoritms to be used: "
              << "'gsl_multiroot_fdfsolver_gnewton'"
              << endmsg;
        }
      else
        {
          return Error(" Unknown algorith type '"
                       + std::string(m_algType) + "'");
         }

      return StatusCode::SUCCESS;
    }

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

assignment operator is

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

Implements IEqSolver.

Definition at line 191 of file EqSolver.cpp.

    {
      using namespace Genfun;

      gsl_vector_view vect = gsl_vector_view_array ( &arg[0] ,
                                                     arg.dimension() );
      MsgStream log( msgSvc(), name() );

      EqSolverMisc local (funcs, arg);

      const gsl_multiroot_fdfsolver_type *T = m_type;
      gsl_multiroot_fdfsolver *s;
      int    status = 0 ;
      size_t iter   = 0 ;

      gsl_multiroot_function_fdf function;

      function.f = &fun_gsl;
      function.df = &dfun_gsl;
      function.fdf = &fdfun_gsl;
      function.n = vect.vector.size;
      function.params = (void*) &local;

      s = gsl_multiroot_fdfsolver_alloc(T, vect.vector.size);
      gsl_multiroot_fdfsolver_set (s, &function, &vect.vector);

      for (iter = 0; iter < m_max_iter; ++iter)
        {
          status = gsl_multiroot_fdfsolver_iterate (s);
          if (status)
            {
              return Error
                ("Error from gsl_gsl_multiroot_fdfsolver_iterate '"
                 + std::string(gsl_strerror(status)) + "'") ;
            }

          status = gsl_multiroot_test_residual (s->f,
                                                m_norm_residual);

          if ( status != GSL_CONTINUE ) { break; }
        }

      for (unsigned int i = 0; i < vect.vector.size; ++i)
        {
          gsl_vector_set (&vect.vector, i, gsl_vector_get (s->x, i));
        }

      if (status == GSL_SUCCESS)
        {
          log << MSG::DEBUG
              << "We stopped in the method on the " << iter
              << " iteration (we have maximum "     << m_max_iter
              << " iterations)"                     << endmsg;
        }
      else if (status == GSL_CONTINUE && iter <= m_max_iter )
        {
          return Error ( "Method finished with '"
                         + std::string(gsl_strerror(status))
                         +  "' error" );
        }
      else
        {
          return Error ( "Method finished with '" +
                         std::string(gsl_strerror(status))
                         +  "' error" );
        }

      gsl_multiroot_fdfsolver_free (s);

      if (status)
        {
          return Error ( "Method finished with '"
                         + std::string(gsl_strerror(status))
                         +  "' error" );
        }

      return GSL_SUCCESS;
    }

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

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines