35 #include "gsl/gsl_math.h" 36 #include "gsl/gsl_errno.h" 37 #include "gsl/gsl_poly.h" 38 #include "gsl/gsl_poly.h" 54 fDerived_params(
std::vector<double>(n) )
122 return gsl_poly_eval( p,
fOrder + 1, x);
130 for (
unsigned int i = 0; i <
fOrder; ++i )
139 return gsl_pow_int(x, ipar);
171 fRoots.push_back( std::complex<double> ( r, 0.0) );
179 std::cout <<
"Polynomial quadratic ::- FAILED to find roots" << std::endl;
183 fRoots.push_back(std::complex<double>(z1.dat[0],z1.dat[1]) );
184 fRoots.push_back(std::complex<double>(z2.dat[0],z2.dat[1]) );
188 gsl_complex z1, z2, z3;
197 std::cout <<
"Polynomial cubic::- FAILED to find roots" << std::endl;
202 fRoots.push_back(std::complex<double> (z1.dat[0],z1.dat[1]) );
203 fRoots.push_back(std::complex<double> (z2.dat[0],z2.dat[1]) );
204 fRoots.push_back(std::complex<double> (z3.dat[0],z3.dat[1]) );
209 gsl_complex z1, z2, z3, z4;
219 std::cout <<
"Polynomial quartic ::- FAILED to find roots" << std::endl;
223 fRoots.push_back(std::complex<double> (z1.dat[0],z1.dat[1]) );
224 fRoots.push_back(std::complex<double> (z2.dat[0],z2.dat[1]) );
225 fRoots.push_back(std::complex<double> (z3.dat[0],z3.dat[1]) );
226 fRoots.push_back(std::complex<double> (z4.dat[0],z4.dat[1]) );
240 std::vector<double>
roots;
242 for (
unsigned int i = 0; i <
fOrder; ++i) {
243 if (
fRoots[i].imag() == 0)
244 roots.push_back(
fRoots[i].real() );
264 gsl_poly_complex_workspace * w = gsl_poly_complex_workspace_alloc( n + 1);
265 std::vector<double>
z(2*n);
266 int status = gsl_poly_complex_solve (
Parameters(), n+1, w, &z.front() );
267 gsl_poly_complex_workspace_free(w);
269 for (
unsigned int i = 0; i <
n; ++i)
270 fRoots.push_back(std::complex<double> (z[2*i],z[2*i+1] ) );
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
Polynomial(unsigned int n=0)
Construct a Polynomial function of order n.
std::vector< double > FindRealRoots()
Find the only the real polynomial roots.
std::vector< double > fDerived_params
const std::vector< std::complex< double > > & FindRoots()
Find the polynomial roots.
virtual const double * Parameters() const
Access the parameter values.
const std::vector< std::complex< double > > & FindNumRoots()
Find the polynomial roots using always an iterative numerical methods The numerical method used is fr...
double DoEvalPar(double x, const double *p) const
Implementation of the evaluation function using the x value and the parameters.
IGenFunction * Clone() const
Clone a function.
virtual void SetParameters(const double *p)
Set the parameter values.
std::vector< std::complex< double > > fRoots
std::vector< double > fParams
Parametric Function class describing polynomials of order n.
int gsl_poly_complex_solve_cubic(double a, double b, double c, gsl_complex *z0, gsl_complex *z1, gsl_complex *z2)
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Namespace for new Math classes and functions.
you should not use this method at all Int_t Int_t z
int gsl_poly_complex_solve_quartic(double a, double b, double c, double d, gsl_complex *z0, gsl_complex *z1, gsl_complex *z2, gsl_complex *z3)
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
double DoParameterDerivative(double x, const double *p, unsigned int ipar) const
Evaluate the gradient, to be implemented by the derived classes.
double DoDerivative(double x) const
function to evaluate the derivative with respect each coordinate.