Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
EqSolver Class Reference

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

#include <src/Components/EqSolver.h>

Inheritance diagram for EqSolver:
Collaboration diagram for EqSolver:

Classes

class  EqSolverMisc
 

Public Types

typedef std::vector< Equations > Jacobi
 
- Public Types inherited from extends< GaudiTool, IEqSolver >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 

Public Member Functions

StatusCode solver (const Equations &funcs, Arg &arg) const override
 Solving nonlinear system with N equations in N unknowns of the function "GenFunc". More...
 
StatusCode initialize () override
 Overriding initialize. More...
 
- Public Member Functions inherited from extends< GaudiTool, IEqSolver >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
- Public Member Functions inherited from GaudiTool
StatusCode initialize () override
 standard initialization method More...
 
StatusCode finalize () override
 standard finalization method More...
 
INTupleSvcntupleSvc () const
 Access the standard N-Tuple. More...
 
INTupleSvcevtColSvc () const
 Access the standard event collection service. More...
 
IDataProviderSvcdetSvc () const
 accessor to detector service More...
 
IIncidentSvcincSvc () const
 accessor to Incident Service More...
 
IChronoStatSvcchronoSvc () const
 accessor to Chrono & Stat Service More...
 
IHistogramSvchistoSvc () const
 acessor to the histogram service More...
 
IAlgContextSvccontextSvc () const
 acessor to the Algorithm Context Service More...
 
void put (IDataProviderSvc *svc, DataObject *object, const std::string &address, const bool useRootInTES=true) const
 Register a data object or container into Gaudi Event Transient Store. More...
 
void put (IDataProviderSvc *svc, std::unique_ptr< DataObject > object, const std::string &address, const bool useRootInTES=true) const
 
const DataObjectput (DataObject *object, const std::string &address, const bool useRootInTES=true) const
 Register a data object or container into Gaudi Event Transient Store. More...
 
const DataObjectput (std::unique_ptr< DataObject > object, const std::string &address, const bool useRootInTES=true) const
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type get (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Templated access to the data in Gaudi Transient Store. More...
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type getIfExists (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Templated access to the data in Gaudi Transient Store. More...
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type get (const std::string &location, const bool useRootInTES=true) const
 Templated access to the data from Gaudi Event Transient Store. More...
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type getIfExists (const std::string &location, const bool useRootInTES=true) const
 Templated access to the data in Gaudi Transient Store. More...
 
template<class TYPE >
TYPE * getDet (IDataProviderSvc *svc, const std::string &location) const
 Templated access to the detector data from the Gaudi Detector Transient Store. More...
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type getDetIfExists (IDataProviderSvc *svc, const std::string &location) const
 Templated access to the detector data from the Gaudi Detector Transient Store. More...
 
template<class TYPE >
TYPE * getDet (const std::string &location) const
 Templated access to the detector data from the Gaudi Detector Transient Store. More...
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type getDetIfExists (const std::string &location) const
 Templated access to the detector data from the Gaudi Detector Transient Store. More...
 
template<class TYPE >
bool exist (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Check the existence of a data object or container in the Gaudi Transient Event Store. More...
 
template<class TYPE >
bool exist (const std::string &location, const bool useRootInTES=true) const
 Check the existence of a data object or container in the Gaudi Transient Event Store. More...
 
template<class TYPE >
bool existDet (IDataProviderSvc *svc, const std::string &location) const
 Check the existence of detector objects in the Gaudi Transient Detector Store. More...
 
template<class TYPE >
bool existDet (const std::string &location) const
 Check the existence of detector objects in the Gaudi Transient Detector Store. More...
 
template<class TYPE , class TYPE2 >
Gaudi::Utils::GetData< TYPE >::return_type getOrCreate (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Get the existing data object from Gaudi Event Transient store. More...
 
template<class TYPE , class TYPE2 >
Gaudi::Utils::GetData< TYPE >::return_type getOrCreate (const std::string &location, const bool useRootInTES=true) const
 Get the existing data object from Gaudi Event Transient store. More...
 
StatusCode Error (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
 Print the error message and return with the given StatusCode. More...
 
StatusCode Warning (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
 Print the warning message and return with the given StatusCode. More...
 
StatusCode Info (const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const size_t mx=10) const
 Print the info message and return with the given StatusCode. More...
 
 GaudiTool (const std::string &type, const std::string &name, const IInterface *parent)
 Standard constructor. More...
 
 ~GaudiTool () override
 destructor, virtual and protected More...
 
- Public Member Functions inherited from GaudiCommon< CounterHolder< AlgTool > >
Gaudi::Utils::GetData< TYPE >::return_type get (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Templated access to the data in Gaudi Transient Store. More...
 
Gaudi::Utils::GetData< TYPE >::return_type getIfExists (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Quicker version of the get function which bypasses the check on the retrieved data. More...
 
bool exist (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Check the existence of a data object or container in the Gaudi Transient Event Store. More...
 
Gaudi::Utils::GetData< TYPE >::return_type getOrCreate (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Get the existing data object from Gaudi Event Transient store. More...
 
DataObjectput (IDataProviderSvc *svc, std::unique_ptr< DataObject > object, const std::string &location, const bool useRootInTES=true) const
 Register a data object or container into Gaudi Event Transient Store. More...
 
DataObjectput (IDataProviderSvc *svc, DataObject *object, const std::string &location, const bool useRootInTES=true) const
 
TOOL * tool (const std::string &type, const std::string &name, const IInterface *parent=0, bool create=true) const
 Useful method for the easy location of tools. More...
 
TOOL * tool (const std::string &type, const IInterface *parent=0, bool create=true) const
 A useful method for the easy location of tools. More...
 
SmartIF< SERVICE > svc (const std::string &name, const bool create=true) const
 A useful method for the easy location of services. More...
 
IUpdateManagerSvcupdMgrSvc () const
 Short-cut to locate the Update Manager Service. More...
 
WARN_UNUSED StatusCode Error (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
 Print the error message and return with the given StatusCode. More...
 
WARN_UNUSED StatusCode Warning (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
 Print the warning message and return with the given StatusCode. More...
 
WARN_UNUSED StatusCode Info (const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const size_t mx=10) const
 Print the info message and return with the given StatusCode. More...
 
WARN_UNUSED StatusCode Print (const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const MSG::Level lev=MSG::INFO) const
 Print the message and return with the given StatusCode. More...
 
void Assert (const bool ok, const std::string &message="", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Assertion - throw exception if the given condition is not fulfilled. More...
 
void Assert (const bool ok, const char *message, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Assertion - throw exception if the given condition is not fulfilled. More...
 
void Exception (const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Create and (re)-throw a given GaudiException. More...
 
void Exception (const std::string &msg, const std::exception &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Create and (re)-throw a given exception. More...
 
void Exception (const std::string &msg="no message", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Create and throw an exception with the given message. More...
 
StatEntitycounter (const std::string &tag) const
 accessor to certain counter by name More...
 
StatEntitycounter (const std::string &tag)
 
bool typePrint () const
 Insert the actual C++ type of the algorithm/tool in the messages ? More...
 
bool propsPrint () const
 Print properties at initialization ? More...
 
bool statPrint () const
 Print statistical counters at finalization ? More...
 
bool errorsPrint () const
 Print error counters at finalization ? More...
 
long printStat (const MSG::Level level=MSG::ALWAYS) const
 perform the actual printout of statistical counters More...
 
long printErrors (const MSG::Level level=MSG::ALWAYS) const
 perform the actual printout of error counters More...
 
long printProps (const MSG::Level level=MSG::ALWAYS) const
 perform the actual printout of properties More...
 
void registerCondition (const std::string &condition, StatusCode(CallerClass::*mf)()=nullptr)
 register the current instance to the UpdateManagerSvc as a consumer for a condition. More...
 
void registerCondition (const std::string &condition, CondType *&condPtrDest, StatusCode(CallerClass::*mf)()=NULL)
 register the current instance to the UpdateManagerSvc as a consumer for a condition. More...
 
void registerCondition (char *condition, StatusCode(CallerClass::*mf)()=NULL)
 just to avoid conflicts with the version using a pointer to a template class. More...
 
void registerCondition (TargetClass *condition, StatusCode(CallerClass::*mf)()=NULL)
 register the current instance to the UpdateManagerSvc as a consumer for a condition. More...
 
StatusCode runUpdate ()
 asks the UpdateManagerSvc to perform an update of the instance (if needed) without waiting the next BeginEvent incident. More...
 
 GaudiCommon (const std::string &name, ISvcLocator *pSvcLocator)
 Algorithm constructor - the SFINAE constraint below ensures that this is constructor is only defined if PBASE derives from Algorithm. More...
 
 GaudiCommon (const std::string &type, const std::string &name, const IInterface *ancestor)
 Tool constructor - SFINAE-ed to insure this constructor is only defined if PBASE derives from AlgTool. More...
 
StatusCode initialize () override
 standard initialization method More...
 
StatusCode finalize () override
 standard finalization method More...
 
StatusCode release (const IInterface *interface) const
 Manual forced (and 'safe') release of the active tool or service. More...
 
const Servicesservices () const
 get the list of aquired services More...
 
const std::stringcontext () const
 Returns the "context" string. Used to identify different processing states. More...
 
const std::stringrootInTES () const
 Returns the "rootInTES" string. More...
 
const std::string fullTESLocation (const std::string &location, const bool useRootInTES) const
 Returns the full correct event location given the rootInTes settings. More...
 
- Public Member Functions inherited from CounterHolder< BASE >
void declareCounter (const std::string &tag, Gaudi::Accumulators::PrintableCounter &r)
 
const Gaudi::Accumulators::PrintableCounterfindCounter (const std::string &tag) const
 
template<typename Callable >
void forEachCounter (Callable &&f) const
 
int nCounters () const
 
void clearCounters ()
 

Private Member Functions

 EqSolver ()=delete
 default constructor is private More...
 
 EqSolver (const EqSolver &)=delete
 copy constructor is private More...
 
EqSolveroperator= (const EqSolver &)=delete
 assignment operator is More...
 

Private Attributes

Gaudi::Property< std::stringm_algType
 
Gaudi::Property< double > m_max_iter {this, "Iteration", 1000, "maximum of iteration"}
 
Gaudi::Property< double > m_norm_residual {this, "Residual", 1.0e-7, "absolute error bound for the residual value"}
 
const gsl_multiroot_fdfsolver_type * m_type = nullptr
 

Additional Inherited Members

- Static Public Member Functions inherited from GaudiTool
static bool enableSummary (bool)
 enable/disable summary More...
 
static bool summaryEnabled ()
 is summary enabled? More...
 
- Protected Types inherited from GaudiCommon< CounterHolder< AlgTool > >
using base_class = CounterHolder< AlgTool >
 
typedef std::map< std::string, StatEntityStatisticsOwn
 the actual type of general counters More...
 
typedef std::map< std::string, std::reference_wrapper< Gaudi::Accumulators::PrintableCounter > > Statistics
 
typedef std::map< std::string, unsigned int > Counter
 the actual type error/warning counter More...
 
typedef std::vector< IAlgTool * > AlgTools
 storage for active tools More...
 
typedef std::vector< SmartIF< IService > > Services
 storage for active services More...
 
- Protected Member Functions inherited from GaudiCommon< CounterHolder< AlgTool > >
StatusCode releaseTool (const IAlgTool *tool) const
 manual forced (and 'safe') release of the tool More...
 
StatusCode releaseSvc (const IInterface *svc) const
 manual forced (and 'safe') release of the service More...
 
- Protected Attributes inherited from GaudiCommon< CounterHolder< AlgTool > >
SmartIF< ICounterSummarySvcm_counterSummarySvc
 a pointer to the CounterSummarySvc More...
 
- Static Protected Attributes inherited from GaudiCommon< CounterHolder< AlgTool > >
static const bool IgnoreRootInTES
 Simple definition to be used with the new useRootInTES argument get<TYPE> and put methods. More...
 
static const bool UseRootInTES
 Simple definition to be used with the new useRootInTES argument get<TYPE> and put methods. More...
 

Detailed Description

The simplest concrete implementation of IEqSolver interface.

See also
GaudiGSL/IEqSolver.h
Author
Kirill Miklyaev kiril.nosp@m.lm@i.nosp@m.ris1..nosp@m.itep.nosp@m..ru
Date
2003-07-07

Definition at line 23 of file EqSolver.h.

Member Typedef Documentation

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

Definition at line 25 of file EqSolver.h.

Constructor & Destructor Documentation

EqSolver::EqSolver ( )
privatedelete

default constructor is private

EqSolver::EqSolver ( const EqSolver )
privatedelete

copy constructor is private

Member Function Documentation

StatusCode EqSolver::initialize ( )
override

Overriding initialize.

Definition at line 175 of file EqSolver.cpp.

175  {
177  if ( sc.isFailure() ) { return Error( "Could not initiliaze base class GaudiTool", sc ); }
178 
179  /* The algorithm for multiional root-finding
180  (solving nonlinear systems with n equations in n unknowns)*/
181 
182  if ( "fdfsolver_hybridsj" == m_algType ) {
183  m_type = gsl_multiroot_fdfsolver_hybridsj;
184  debug() << "Root finding algorithm to be used: "
185  << "'gsl_multiroot_fdfsolver_hybridsj'" << endmsg;
186  } else if ( "fdfsolver_hybridj" == m_algType ) {
187  m_type = gsl_multiroot_fdfsolver_hybridj;
188  debug() << "Root finding algorithm to be used: "
189  << "'gsl_multiroot_fdfsolver_hybridj'" << endmsg;
190  } else if ( "fdfsolver_newton" == m_algType ) {
191  m_type = gsl_multiroot_fdfsolver_newton;
192  debug() << "Root findind algorithm to be used: "
193  << "'gsl_multiroot_fdfsolver_newton'" << endmsg;
194  } else if ( "fdfsolver_gnewton" == m_algType ) {
195  m_type = gsl_multiroot_fdfsolver_gnewton;
196  debug() << "Root findind algorithm to be used: "
197  << "'gsl_multiroot_fdfsolver_gnewton'" << endmsg;
198  } else {
199  return Error( " Unknown algorithm type '" + std::string( m_algType ) + "'" );
200  }
201 
202  return StatusCode::SUCCESS;
203 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
bool isFailure() const
Definition: StatusCode.h:130
STL class.
Gaudi::Property< std::string > m_algType
Definition: EqSolver.h:79
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
StatusCode Error(const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
Print the error message and return with the given StatusCode.
Definition: GaudiTool.h:663
const gsl_multiroot_fdfsolver_type * m_type
Definition: EqSolver.h:84
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
StatusCode initialize() override
standard initialization method
Definition: GaudiTool.cpp:144
EqSolver& EqSolver::operator= ( const EqSolver )
privatedelete

assignment operator is

StatusCode EqSolver::solver ( const Equations &  funcs,
Arg &  arg 
) const
override

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

121 {
122  using namespace Genfun;
123 
124  gsl_vector_view vect = gsl_vector_view_array( &arg[0], arg.dimension() );
125  EqSolverMisc local( funcs, arg );
126 
127  const gsl_multiroot_fdfsolver_type* T = m_type;
128  gsl_multiroot_fdfsolver* s = nullptr;
129  int status = 0;
130  size_t iter = 0;
131 
132  gsl_multiroot_function_fdf function;
133 
134  function.f = &fun_gsl;
135  function.df = &dfun_gsl;
136  function.fdf = &fdfun_gsl;
137  function.n = vect.vector.size;
138  function.params = &local;
139 
140  s = gsl_multiroot_fdfsolver_alloc( T, vect.vector.size );
141  gsl_multiroot_fdfsolver_set( s, &function, &vect.vector );
142 
143  for ( iter = 0; iter < m_max_iter; ++iter ) {
144  status = gsl_multiroot_fdfsolver_iterate( s );
145  if ( status ) {
146  return Error( "Error from gsl_gsl_multiroot_fdfsolver_iterate '" + std::string( gsl_strerror( status ) ) + "'" );
147  }
148 
149  status = gsl_multiroot_test_residual( s->f, m_norm_residual );
150 
151  if ( status != GSL_CONTINUE ) { break; }
152  }
153 
154  for ( unsigned int i = 0; i < vect.vector.size; ++i ) {
155  gsl_vector_set( &vect.vector, i, gsl_vector_get( s->x, i ) );
156  }
157 
158  if ( status == GSL_SUCCESS ) {
159  debug() << "We stopped in the method on the " << iter << " iteration (we have maximum " << m_max_iter
160  << " iterations)" << endmsg;
161  } else if ( status == GSL_CONTINUE && iter <= m_max_iter ) {
162  return Error( "Method finished with '" + std::string( gsl_strerror( status ) ) + "' error" );
163  } else {
164  return Error( "Method finished with '" + std::string( gsl_strerror( status ) ) + "' error" );
165  }
166 
167  gsl_multiroot_fdfsolver_free( s );
168 
169  if ( status ) { return Error( "Method finished with '" + std::string( gsl_strerror( status ) ) + "' error" ); }
170 
171  return StatusCode( GSL_SUCCESS );
172 }
STL class.
Gaudi::Property< double > m_max_iter
Definition: EqSolver.h:81
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
StatusCode Error(const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
Print the error message and return with the given StatusCode.
Definition: GaudiTool.h:663
string s
Definition: gaudirun.py:312
const gsl_multiroot_fdfsolver_type * m_type
Definition: EqSolver.h:84
CLHEP.
Definition: IEqSolver.h:13
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Gaudi::Property< double > m_norm_residual
Definition: EqSolver.h:82

Member Data Documentation

Gaudi::Property<std::string> EqSolver::m_algType
private
Initial value:
{this, "Algorithm", "fdfsolver_hybridsj",
"type of the algorithm for root finding"}

Definition at line 79 of file EqSolver.h.

Gaudi::Property<double> EqSolver::m_max_iter {this, "Iteration", 1000, "maximum of iteration"}
private

Definition at line 81 of file EqSolver.h.

Gaudi::Property<double> EqSolver::m_norm_residual {this, "Residual", 1.0e-7, "absolute error bound for the residual value"}
private

Definition at line 82 of file EqSolver.h.

const gsl_multiroot_fdfsolver_type* EqSolver::m_type = nullptr
private

Definition at line 84 of file EqSolver.h.


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