Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:24:23

0001 // -*- C++ -*-
0002 
0003 // math/gsl.h is part of matchbox
0004 // (C) 2008 Simon Platzer -- sp@particle.uni-karlsruhe.de
0005 
0006 #ifndef matchbox_math_gsl_h
0007 #define matchbox_math_gsl_h
0008 
0009 #include "gsl/gsl_math.h"
0010 #include "gsl/gsl_roots.h"
0011 
0012 #include "ThePEG/Utilities/Exception.h"
0013 
0014 namespace matchbox {
0015 
0016   namespace gsl {
0017 
0018     /// exception class for GSL problems      
0019     struct gsl_exception : public ThePEG::Exception { };
0020 
0021     /// wrapper araound the bisection root solver
0022     template<class Function, unsigned long MaxIterations>
0023     struct bisection_root_solver {
0024 
0025       /// constructor -- allocates the solver
0026       inline bisection_root_solver (const Function& thef) : f(thef) {
0027     s = gsl_root_fsolver_alloc (gsl_root_fsolver_bisection);
0028       }
0029 
0030       /// destructor -- frees the solver
0031       ~bisection_root_solver () {
0032     gsl_root_fsolver_free (s);
0033       }
0034 
0035       /// solve for root given initial interval
0036       double solve (std::pair<double,double> interval, double precision = .000001);
0037 
0038       /// function object representing the equation to be solved
0039       Function f;
0040 
0041       /// the gsl solver used
0042       gsl_root_fsolver * s;
0043 
0044     };
0045 
0046   }
0047 
0048 }
0049 
0050 #include "gsl.tcc"
0051 
0052 #endif // matchbox_math_gsl_h