35#include "gsl/gsl_math.h"
36#include "gsl/gsl_errno.h"
37#include "gsl/gsl_poly.h"
53 fDerived_params(std::vector<
double>(
n) )
61 fDerived_params(std::vector<
double>(1) )
71 fDerived_params(std::vector<
double>(2) )
83 fDerived_params(std::vector<
double>(3) )
96 fDerived_params(std::vector<
double>(4) )
121 return gsl_poly_eval(
p,
fOrder + 1,
x);
129 for (
unsigned int i = 0; i <
fOrder; ++i )
138 return gsl_pow_int(
x, ipar);
170 fRoots.push_back( std::complex<double> (
r, 0.0) );
178 std::cout <<
"Polynomial quadratic ::- FAILED to find roots" << std::endl;
182 fRoots.push_back(std::complex<double>(z1.dat[0],z1.dat[1]) );
183 fRoots.push_back(std::complex<double>(z2.dat[0],z2.dat[1]) );
187 gsl_complex z1, z2, z3;
196 std::cout <<
"Polynomial cubic::- FAILED to find roots" << std::endl;
201 fRoots.push_back(std::complex<double> (z1.dat[0],z1.dat[1]) );
202 fRoots.push_back(std::complex<double> (z2.dat[0],z2.dat[1]) );
203 fRoots.push_back(std::complex<double> (z3.dat[0],z3.dat[1]) );
208 gsl_complex z1, z2, z3, z4;
218 std::cout <<
"Polynomial quartic ::- FAILED to find roots" << std::endl;
222 fRoots.push_back(std::complex<double> (z1.dat[0],z1.dat[1]) );
223 fRoots.push_back(std::complex<double> (z2.dat[0],z2.dat[1]) );
224 fRoots.push_back(std::complex<double> (z3.dat[0],z3.dat[1]) );
225 fRoots.push_back(std::complex<double> (z4.dat[0],z4.dat[1]) );
239 std::vector<double>
roots;
241 for (
unsigned int i = 0; i <
fOrder; ++i) {
242 if (
fRoots[i].imag() == 0)
263 gsl_poly_complex_workspace *
w = gsl_poly_complex_workspace_alloc(
n + 1);
264 std::vector<double> z(2*
n);
265 int status = gsl_poly_complex_solve (
Parameters(),
n+1,
w, &z.front() );
266 gsl_poly_complex_workspace_free(
w);
268 for (
unsigned int i = 0; i <
n; ++i)
269 fRoots.push_back(std::complex<double> (z[2*i],z[2*i+1] ) );
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
virtual const double * Parameters() const
Access the parameter values.
std::vector< double > fParams
Parametric Function class describing polynomials of order n.
const std::vector< std::complex< double > > & FindRoots()
Find the polynomial roots.
std::vector< std::complex< double > > fRoots
Polynomial(unsigned int n=0)
Construct a Polynomial function of order n.
double DoEvalPar(double x, const double *p) const override
Implementation of the evaluation function using the x value and the parameters.
IGenFunction * Clone() const override
Clone a function.
double DoParameterDerivative(double x, const double *p, unsigned int ipar) const override
Evaluate the gradient, to be implemented by the derived classes.
std::vector< double > FindRealRoots()
Find the only the real polynomial roots.
const std::vector< std::complex< double > > & FindNumRoots()
Find the polynomial roots using always an iterative numerical methods The numerical method used is fr...
double DoDerivative(double x) const override
Function to evaluate the derivative with respect each coordinate. To be implemented by the derived cl...
std::vector< double > fDerived_params
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)
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
int gsl_poly_complex_solve_cubic(double a, double b, double c, gsl_complex *z0, gsl_complex *z1, gsl_complex *z2)