41 #ifndef __has_c2_function_hh 42 #define __has_c2_function_hh 1 47 #define _USE_MATH_DEFINES 48 #define c2_isnan _isnan 49 #define c2_isfinite _finite 51 #define c2_isnan std::isnan 52 #define c2_isfinite std::isfinite 73 virtual const char*
what()
const throw() {
return info.c_str(); }
86 template <
typename float_type>
class c2_ptr;
98 template <
typename float_type>
class c2_fblock 143 "c2_function.hh 490 2012-04-10 19:05:40Z marcus ";
148 const std::string cvs_file_vers()
const ;
153 if(sampling_grid && !no_overwrite_grid)
delete sampling_grid;
154 if(root_info)
delete root_info;
156 std::ostringstream outstr;
157 outstr <<
"attempt to delete an object with non-zero ownership in class ";
158 outstr <<
typeid(*this).name() << std::endl;
171 virtual float_type value_with_derivatives(float_type
x, float_type *yprime, float_type *yprime2)
const throw(
c2_exception) =0 ;
177 {
return value_with_derivatives(x, (float_type *)0, (float_type *)0); }
185 inline float_type operator () (float_type x, float_type *yprime, float_type *yprime2)
const throw(
c2_exception)
186 {
return value_with_derivatives(x, yprime, yprime2); }
206 float_type find_root(float_type lower_bracket, float_type upper_bracket, float_type start,
207 float_type value,
int *
error=0,
208 float_type *final_yprime=0, float_type *final_yprime2=0 )
const throw(
c2_exception) ;
228 float_type partial_integrals(std::vector<float_type> xgrid, std::vector<float_type> *partials = 0,
229 float_type abs_tol=1
e-12, float_type rel_tol=1
e-12,
int derivs=2,
bool adapt=
true,
bool extrapolate=
true)
251 float_type integral(float_type amin, float_type amax, std::vector<float_type> *partials = 0,
252 float_type abs_tol=1
e-12, float_type rel_tol=1
e-12,
int derivs=2,
bool adapt=
true,
bool extrapolate=
true)
293 float_type abs_tol=1
e-12, float_type rel_tol=1
e-12,
294 int derivs=2, std::vector<float_type> *xvals=0, std::vector<float_type> *yvals=0)
const throw(
c2_exception);
297 inline float_type
xmin()
const {
return fXMin; }
299 inline float_type
xmax()
const {
return fXMax; }
301 void set_domain(float_type amin, float_type amax) { fXMin=amin; fXMax=amax; }
318 bool check_monotonicity(
const std::vector<float_type> &data,
const char message[])
const throw(
c2_exception);
328 virtual void set_sampling_grid(
const std::vector<float_type> &grid)
throw(
c2_exception);
340 virtual void get_sampling_grid(float_type amin, float_type amax, std::vector<float_type> &grid)
const ;
345 void preen_sampling_grid(std::vector<float_type> *result)
const;
349 void refine_sampling_grid(std::vector<float_type> &grid,
size_t refinement)
const;
411 std::ostringstream outstr;
412 outstr <<
"attempt to release ownership of an unowned function in class ";
413 outstr <<
typeid(*this).name() << std::endl;
421 if(!release_ownership_for_return())
delete this;
429 no_overwrite_grid(false),
430 fXMin(src.fXMin), fXMax(src.fXMax), root_info(0), owner_count(0)
433 sampling_grid(0), no_overwrite_grid(0),
434 fXMin(-
std::numeric_limits<float_type>::
max()),
435 fXMax(
std::numeric_limits<float_type>::
max()), root_info(0), owner_count(0)
442 if (sampling_grid && !no_overwrite_grid)
delete sampling_grid;
443 sampling_grid=&grid; no_overwrite_grid=1;
458 fb.y=value_with_derivatives(
fb.x, &
fb.yp, &
fb.ypp);
461 increment_evaluations();
480 float_type abs_tol,
rel_tol, eps_scale, extrap_coef, extrap2, dx_tolerance, abs_tol_min;
490 float_type abs_tol,
rel_tol, dx_tolerance, abs_tol_min;
493 std::vector<float_type> *xvals, *
yvals;
544 if(!func)
throw c2_exception(
"c2_classic_function called with null function");
545 if(yprime) *yprime=0;
546 if(yprime2) *yprime2=0;
553 const float_type (*func)(float_type);
573 { this->set_function(&f); }
577 { this->set_function(src.
get_ptr()); }
582 if(func) func->release_ownership();
584 if(func) func->claim_ownership();
590 { this->set_function(f.
get_ptr());
return f; }
594 { this->set_function(&f);
return f; }
603 if(func) func->release_ownership_for_return();
616 if(!func)
throw c2_exception(
"c2_ptr accessed uninitialized");
625 bool valid()
const {
return func != 0; }
646 {
return get().value_with_derivatives(x, yprime, yprime2); }
706 { this->set_function(f.
get_ptr());
return f; }
710 { this->set_function(&f);
return f; }
732 :
c2_const_ptr<float_type>() { this->set_function(&f); }
744 inline c2_class<float_type> *operator -> ()
const 750 operator c2_class<float_type>&()
const {
return get(); }
754 { this->set_function(f.
get_ptr()); }
757 void operator =(c2_class<float_type> &
f)
758 { this->set_function(&f); }
794 func.set_function(f);
795 if(f) this->set_domain(f->
xmin(), f->
xmax());
801 if(!func.valid())
throw c2_exception(
"c2_plugin_function_p called uninitialized");
802 return func->value_with_derivatives(x, yprime, yprime2);
810 virtual void get_sampling_grid(float_type amin, float_type amax, std::vector<float_type> &grid)
const 812 if(!func.valid())
throw c2_exception(
"c2_plugin_function_p called uninitialized");
814 else func->get_sampling_grid(amin, amax, grid);
839 {
return this->func.get(); }
852 if(stub)
throw c2_exception(
"attempt to evaluate a c2_binary_function stub");
853 return this->combine(*Left.get_ptr(), *Right.get_ptr(),
x, yprime, yprime2);
867 float_type x, float_type *yprime, float_type *yprime2),
869 c2_function<float_type>(), combine(combiner), Left(left), Right(right), stub(false)
881 float_type x, float_type *yprime, float_type *yprime2)
882 ) :
c2_function<float_type>(), combine(combiner), Left(), Right(), stub(true) { }
886 float_type
x, float_type *yprime, float_type *yprime2);
906 c2_function<float_type>(), func(outer), yscale(scale) { }
917 float_type
y=this->func->value_with_derivatives(x, yprime, yprime2);
918 if(yprime) (*yprime)*=yscale;
919 if(yprime2) (*yprime2)*=yscale;
943 func(f), init(false) {}
950 if(!init || x != x0) {
951 y=this->func->value_with_derivatives(x, &yp, &ypp);
955 if(yprime) *yprime=yp;
956 if(yprime2) *yprime2=ypp;
964 mutable float_type x0,
y, yp,
ypp;
987 float_type x, float_type *yprime, float_type *yprime2)
throw(
c2_exception)
990 if(yprime || yprime2) {
991 float_type yp0, ypp0, yp1, ypp1;
992 y0=
right.value_with_derivatives(x, &yp0, &ypp0);
993 y1=
left.value_with_derivatives(y0, &yp1, &ypp1);
994 if(yprime) *yprime=yp1*yp0;
995 if(yprime2) *yprime2=ypp0*yp1+yp0*yp0*ypp1;
1018 float_type x, float_type *yprime, float_type *yprime2)
throw(
c2_exception)
1021 if(yprime || yprime2) {
1022 float_type yp0, ypp0, yp1, ypp1;
1023 y0=
left.value_with_derivatives(x, &yp0, &ypp0);
1024 y1=
right.value_with_derivatives(x, &yp1, &ypp1);
1025 if(yprime) *yprime=yp0+yp1;
1026 if(yprime2) *yprime2=ypp0+ypp1;
1050 float_type x, float_type *yprime, float_type *yprime2)
throw(
c2_exception)
1053 if(yprime || yprime2) {
1054 float_type yp0, ypp0, yp1, ypp1;
1055 y0=
left.value_with_derivatives(x, &yp0, &ypp0);
1056 y1=
right.value_with_derivatives(x, &yp1, &ypp1);
1057 if(yprime) *yprime=yp0-yp1;
1058 if(yprime2) *yprime2=ypp0-ypp1;
1082 float_type x, float_type *yprime, float_type *yprime2)
throw(
c2_exception)
1085 if(yprime || yprime2) {
1086 float_type yp0, ypp0, yp1, ypp1;
1087 y0=
left.value_with_derivatives(x, &yp0, &ypp0);
1088 y1=
right.value_with_derivatives(x, &yp1, &ypp1);
1089 if(yprime) *yprime=y1*yp0+y0*yp1;
1090 if(yprime2) *yprime2=ypp0*y1+2.0*yp0*yp1+ypp1*y0;
1114 float_type x, float_type *yprime, float_type *yprime2)
throw(
c2_exception)
1117 if(yprime || yprime2) {
1118 float_type yp0, ypp0, yp1, ypp1;
1119 y0=
left.value_with_derivatives(x, &yp0, &ypp0);
1120 y1=
right.value_with_derivatives(x, &yp1, &ypp1);
1121 if(yprime) *yprime=(yp0*y1-y0*yp1)/(y1*y1);
1122 if(yprime2) *yprime2=(y1*y1*ypp0+y0*(2*yp1*yp1-y1*ypp1)-2*y1*yp0*yp1)/(y1*y1*
y1);
1139 void reset(float_type val) { value=val; }
1141 {
if(yprime) *yprime=0;
if(yprime2) *yprime2=0;
return value; }
1158 float_type (*xin)(float_type), float_type (*xinp)(float_type), float_type (*xinpp)(float_type), float_type (*xout)(float_type)
1160 fTransformed(transformed), fHasStaticTransforms(true),
1161 pIn(xin), pInPrime(xinp), pInDPrime(xinpp), pOut(xout) { }
1166 fTransformed(transformed), fHasStaticTransforms(false),
1167 pIn(report_error), pInPrime(report_error), pInDPrime(report_error), pOut(report_error) { }
1178 float_type (*
const pIn)(float_type);
1180 float_type (*
const pInPrime)(float_type);
1182 float_type (*
const pInDPrime)(float_type);
1184 float_type (*
const pOut)(float_type);
1187 virtual float_type
fIn(float_type x)
const {
return pIn(x); }
1189 virtual float_type
fInPrime(float_type x)
const {
return pInPrime(x); }
1191 virtual float_type
fInDPrime(float_type x)
const {
return pInDPrime(x); }
1193 virtual float_type
fOut(float_type x)
const {
return pOut(x); }
1199 static float_type
ident(float_type x) {
return x; }
1201 static float_type
one(float_type) {
return 1; }
1203 static float_type
zero(float_type) {
return 0; }
1205 static float_type
recip(float_type x) {
return 1.0/
x; }
1246 template <
typename float_type>
1254 isIdentity(!(xx.fTransformed || yy.fTransformed)),
X(xx),
Y(yy) { }
1265 virtual float_type evaluate(float_type xraw,
1266 float_type
y, float_type yp0, float_type ypp0,
1267 float_type *yprime, float_type *yprime2)
const;
1389 fTransform(transform) { }
1402 bool lowerSlopeNatural, float_type lowerSlope,
1403 bool upperSlopeNatural, float_type upperSlope,
bool splined=
true 1415 std::vector<std::pair<float_type, float_type> > &data,
1416 bool lowerSlopeNatural, float_type lowerSlope,
1417 bool upperSlopeNatural, float_type upperSlope,
bool splined=
true 1438 float_type amin, float_type amax, float_type abs_tol, float_type rel_tol,
1439 bool lowerSlopeNatural, float_type lowerSlope,
1440 bool upperSlopeNatural, float_type upperSlope
1479 const std::vector<float_type> &bins,
const std::vector<float_type> &binheights,
bool splined=
true)
1482 virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2)
const throw(
c2_exception);
1497 void get_data(std::vector<float_type> &xvals, std::vector<float_type> &yvals)
const throw() ;
1506 std::vector<float_type> &xvals,
1507 std::vector<float_type> &yvals,
1508 std::vector<float_type> &y2vals)
const 1509 { xvals=
X; yvals=F; y2vals=
y2; }
1516 void set_lower_extrapolation(float_type bound);
1522 void set_upper_extrapolation(float_type bound);
1570 set_sampling_grid_pointer(Xraw);
1578 bool lowerSlopeNatural, float_type lowerSlope,
1579 bool upperSlopeNatural, float_type upperSlope
1583 static bool comp_pair(std::pair<float_type,float_type>
const &i, std::pair<float_type,float_type>
const &j) {
return i.first<j.first;}
1585 std::vector<float_type> Xraw,
X, F,
y2;
1670 { float_type q=std::sin(x);
if(yprime) *yprime=std::cos(x);
if(yprime2) *yprime2=-q;
return q; }
1676 virtual void get_sampling_grid(float_type amin, float_type amax, std::vector<float_type> &grid)
const;
1689 { float_type q=std::cos(x);
if(yprime) *yprime=-std::sin(x);
if(yprime2) *yprime2=-q;
return q; }
1703 float_type
c=std::cos(x), ss=std::sin(x);
1705 float_type yp=1/(c*
c);
1706 if(yprime) *yprime=yp;
if(yprime2) *yprime2=2*t*yp;
1721 {
if(yprime) *yprime=1.0/
x;
if(yprime2) *yprime2=-1.0/(x*
x);
return std::log(x); }
1734 { float_type q=std::exp(x);
if(yprime) *yprime=q;
if(yprime2) *yprime2=q;
return q; }
1747 { float_type q=std::sqrt(x);
if(yprime) *yprime=0.5/q;
if(yprime2) *yprime2=-0.25/(x*q);
return q; }
1762 float_type
y=rscale*q;
1763 if(yprime) *yprime=-y*q;
1764 if(yprime2) *yprime2=2*y*q*q;
1784 {
if(yprime) *yprime=1.0;
if(yprime2) *yprime2=0;
return x; }
1805 c2_function<float_type>(), xint(x0), intercept(y0),
m(slope) {}
1810 void reset(float_type x0, float_type y0, float_type slope) { xint=x0; intercept=y0;
m=slope; }
1812 {
if(yprime) *yprime=
m;
if(yprime2) *yprime2=0;
return m*(x-xint)+intercept; }
1841 c2_function<float_type>(), intercept(y0), center(x0),
a(x2coef),
b(xcoef) {}
1847 void reset(float_type x0, float_type y0, float_type xcoef, float_type x2coef) { intercept=y0; center=x0;
a=x2coef;
b=xcoef; }
1849 { float_type dx=x-center;
if(yprime) *yprime=2*
a*dx+
b;
if(yprime2) *yprime2=2*
a;
return a*dx*dx+b*dx+intercept; }
1881 { float_type q=
a*std::pow(x,
b-2);
if(yprime) *yprime=
b*q*
x;
if(yprime2) *yprime2=
b*(
b-1)*q;
return q*x*
x; }
1912 virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2)
const throw(
c2_exception);
1924 {
return hinting_function.valid()? hinting_function(x) : start_hint; }
1943 { hinting_function.set_function(hint_func); }
1949 { hinting_function=hint_func; }
1976 accumulated_histogram(
const std::vector<float_type>binedges,
const std::vector<float_type> binheights,
1977 bool normalize=
false,
bool inverse_function=
false,
bool drop_zeros=
true);
2007 bool auto_center, float_type
y1);
2022 float_type x0, float_type y0, float_type yp0, float_type ypp0,
2023 float_type x2, float_type
y2, float_type yp2, float_type ypp2,
2024 bool auto_center, float_type y1);
2034 bool auto_center, float_type y1);
2038 virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2)
const throw (
c2_exception);
2044 bool auto_center, float_type y1);
2074 virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2)
const throw (
c2_exception);
2088 #include "c2_function.icc" const c2_function< float_type > * func
c2_recip_p(float_type scale)
constructor.
create a non-generic container for a c2_function which handles the reference counting.
void reset(float_type scale)
set a new scale factor
c2_typed_ptr(c2_class< float_type > &f)
construct the container with a pre-defined function
bool ypbad
flag, filled in by c2_function::fill_fblock(), indicating the derivative is NaN of Inf ...
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
bool stub
if true, we don't own any functions, we are just a source of a combining function.
log_log_interpolating_function_p()
an empty log-log cubic-spline interpolating_function_p
const std::string cvs_header_vers() const
get versioning information for the header file
c2_plugin_function_p(c2_function< float_type > &f)
construct the container with a pre-defined function
std::vector< c2_const_ptr< float_type > > functions
c2_linear_p(float_type x0, float_type y0, float_type slope)
Construct the operator f=y0 + slope * (x-x0)
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
G4String operator+(const G4String &, const int)
create a c2_function which is the ratio of two other c2_functions.This should always be constructed u...
G4ErrorMatrix operator*(const G4ErrorMatrix &m1, const G4ErrorMatrix &m2)
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
Create a very lightweight method to return a scalar multiple of another function. \ \The factory func...
float_type xmin() const
return the lower bound of the domain for this function as set by set_domain()
a container into which any conventional c-style function can be dropped, to create a degenerate c2_fu...
void claim_ownership() const
increment our reference count. Destruction is only legal if the count is zero.
compute tan(x) with its derivatives.The factory function c2_factory::tan() creates *new c2_tan_p ...
interpolating_function_p< float_type > & multiply_pointwise(const c2_function< float_type > &rhs) const
produce a newly resampled interpolating_function_p which is the specified product.
float_type ypp
the second derivative at x
Provides function composition (nesting)This allows evaluation of f(g(x)) where f and g are c2_functio...
create the formal inverse function of another functionfor example, given a c2_function f ...
c2_ratio_p()
Create a stub just for the combiner to avoid statics.
c2_const_plugin_function_p(const c2_function< float_type > &f)
construct the container with a pre-defined function
c2_const_ptr< float_type > sampler_function
bool valid() const
check if we have a valid function
void release_ownership() const
decrement our reference count. If the count reaches zero, destroy ourself.
std::vector< float_type > y2
void set_start_hint(float_type hint) const
give the function a hint as to where to look for its inverse
G4ErrorMatrix operator/(const G4ErrorMatrix &m1, G4double t)
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
create a linear mapping of another functionfor example, given a c2_function f
const c2_const_ptr< float_type > Right
void reset(float_type x0, float_type y0, float_type xcoef, float_type x2coef)
Modify the coefficients after construction.
A spline with X in reciprocal space and Y transformed in log space.Most useful for thermodynamic type...
c2_fblock< float_type > * f1
interpolating_function_p< float_type > & add_pointwise(const c2_function< float_type > &rhs) const
produce a newly resampled interpolating_function_p which is the specified sum.
c2_const_plugin_function_p()
construct the container with no function
c2_fblock< float_type > upper
interpolating_function_p(const c2_function_transformation< float_type > &transform)
an empty cubic-spline interpolating_function_p with a specific transform
c2_fblock< float_type > f1
c2_cached_function_p(const c2_function< float_type > &f)
construct the container
std::vector< float_type > * get_sampling_grid_pointer() const
get the sampling grid, which may be a null pointer
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
get the value and derivatives.
virtual ~interpolating_function_p()
destructor
compute cos(x) with its derivatives.The factory function c2_factory::cos() creates *new c2_cos_p ...
c2_classic_function_p(const float_type(*c_func)(float_type))
construct the container
void fill_fblock(c2_fblock< float_type > &fb) const
fill in a c2_fblock<float_type>... a shortcut for the integrator & sampler
compute exp(x) with its derivatives.The factory function c2_factory::exp() creates *new c2_exp_p ...
c2_piecewise_function_p< float_type > * out
create a c2_function which is the product of two other c2_functions.This should always be constructed...
virtual float_type get_start_hint(float_type x) const
get the starting hint.
void set_function(const c2_function< float_type > *f)
fill the container with a new function, or clear it with a null pointer
c2_constant_p(float_type x)
c2_sum_p()
Create a stub just for the combiner to avoid statics.
std::vector< float_type > F
c2_plugin_function_p()
construct the container with no function
float_type operator()(float_type x, float_type *yprime, float_type *yprime2) const
convenience operator to make us look like a function
virtual ~c2_const_plugin_function_p()
destructor
size_t count_owners() const
get the reference count, mostly for debugging
c2_function(const c2_function< float_type > &src)
void set_hinting_function(const c2_function< float_type > *hint_func)
set or unset the approximate function used to start the root finder
A spline with X and Y transformed into log space.Most useful for functions looking like y=x^n or any ...
c2_function< float_type > * get_ptr() const
get an unchecked pointer to our owned function
compute scale/x with its derivatives.The factory function c2_factory::recip() creates *new c2_recip_p...
void reset(float_type scale)
reset the scale factor
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
G4ErrorMatrix operator-(const G4ErrorMatrix &m1, const G4ErrorMatrix &m2)
static float_type combine(const c2_function< float_type > &left, const c2_function< float_type > &right, float_type x, float_type *yprime, float_type *yprime2)
execute math necessary to do multiplication
const c2_function_transformation< float_type > & fTransform
create a cubic spline interpolation of a set of (x,y) pairsThis is one of the main reasons for c2_fun...
c2_composed_function_p()
Create a stub just for the combiner to avoid statics.
log_lin_interpolating_function_p()
an empty log-linear cubic-spline interpolating_function_p
A spline with X transformed into log space.Most useful for functions looking like y=log(x) or any oth...
void set_hinting_function(const c2_const_ptr< float_type > hint_func)
set the hinting function from a pointer.
A container into which any other c2_function can be dropped.It allows a function to be pre-evaluated ...
c2_quadratic_p(float_type x0, float_type y0, float_type xcoef, float_type x2coef)
Construct the operator.
structure used to hold evaluated function data at a point.
virtual interpolating_function_p< float_type > & clone() const
create a new, empty interpolating function of this type (virtual constructor)
void reset(float_type x0, float_type y0, float_type slope)
Change the slope and intercepts after construction.
a c2_plugin_function_p which promises not to fiddle with the plugged function.The factory function c2...
size_t release_ownership_for_return() const
decrement our reference count. Do not destroy at zero.
size_t get_evaluations() const
this is a counter owned by the function but which can be used to monitor efficiency of algorithms...
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
function to manage the binary operation, used by c2_binary_function::value_with_derivatives() ...
void set_function(c2_function< float_type > *f)
fill the container with a new function, or clear it with a null pointer and copy our domain ...
compute x with its derivatives.The factory function c2_factory::identity() creates *new c2_identity_p...
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
c2_const_ptr(const c2_const_ptr< float_type > &src)
copy constructor
void set_domain(float_type amin, float_type amax)
set the domain for this function.
virtual interpolating_function_p< float_type > & clone() const
create a new, empty interpolating function of this type (virtual constructor)
c2_binary_function(float_type(*combiner)(const c2_function< float_type > &left, const c2_function< float_type > &right, float_type x, float_type *yprime, float_type *yprime2), const c2_function< float_type > &left, const c2_function< float_type > &right)
construct the binary function
virtual ~c2_function()
destructor
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
c2_class< float_type > * get_ptr() const
get an unchecked pointer to our owned function
structure used to hold root bracketing information
virtual interpolating_function_p< float_type > & clone() const
create a new, empty interpolating function of this type (virtual constructor)
void release_for_return()
release the function without destroying it, so it can be returned from a function ...
std::vector< float_type > X
virtual float_type value_with_derivatives(float_type, float_type *yprime, float_type *yprime2) const
const c2_const_ptr< float_type > func
c2_diff_p(const c2_function< float_type > &left, const c2_function< float_type > &right)
construct left - right
std::vector< recur_item > * rb_stack
a container into which any other c2_function can be dropped, to allow expressions with replacable com...
void get_internal_data(std::vector< float_type > &xvals, std::vector< float_type > &yvals, std::vector< float_type > &y2vals) const
retrieve copies of the transformed x, y and y2 tables from which this was built
float_type yp
the derivative at x
interpolating_function_p< float_type > & divide_pointwise(const c2_function< float_type > &rhs) const
produce a newly resampled interpolating_function_p which is the specified ratio.
static float_type combine(const c2_function< float_type > &left, const c2_function< float_type > &right, float_type x, float_type *yprime, float_type *yprime2)
execute math necessary to do subtraction
structure used to pass information recursively in integrator.
create a container for a c2_function which handles the reference counting.It is useful as a smart con...
static float_type combine(const c2_function< float_type > &left, const c2_function< float_type > &right, float_type x, float_type *yprime, float_type *yprime2)
execute math necessary to do division
std::vector< float_type > Xraw
const c2_const_ptr< float_type > func
virtual void get_sampling_grid(float_type amin, float_type amax, std::vector< float_type > &grid) const
virtual const char * what() const
the exception class for c2_function operations.
c2_ptr()
construct the container with no function
create a c2_function which smoothly connects two other c2_functions.This takes two points and generat...
c2_product_p()
Create a stub just for the combiner to avoid statics.
bool yppbad
flag, filled in by c2_function::fill_fblock(), indicating the second derivative is NaN of Inf ...
the parent class for all c2_functions.c2_functions know their value, first, and second derivative at ...
arrhenius_interpolating_function_p()
an empty arrhenius cubic-spline interpolating_function_p
c2_product_p(const c2_function< float_type > &left, const c2_function< float_type > &right)
construct left * right
c2_typed_ptr(const c2_typed_ptr< float_type, c2_class > &src)
copy constructor
c2_ptr(c2_function< float_type > &f)
construct the container with a pre-defined function
c2_const_ptr(const c2_function< float_type > &f)
construct the container with a pre-defined function
c2_exception(const char msgcode[])
construct the exception with an error message
float_type get_trouble_point() const
Find out where a calculation ran into trouble, if it got a nan. If the most recent computation did no...
the data element for the internal recursion stack for the sampler and integrator
c2_ratio_p(const c2_function< float_type > &left, const c2_function< float_type > &right)
construct left / right
structure used to pass information recursively in sampler.
A spline with Y transformed into log space.Most useful for functions looking like y=exp(x) ...
c2_power_law_p(float_type scale, float_type power)
Construct the operator.
c2_composed_function_p(const c2_function< float_type > &outer, const c2_function< float_type > &inner)
construct outer( inner (x))
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
float_type xmax() const
return the upper bound of the domain for this function as set by set_domain()
c2_binary_function(float_type(*combiner)(const c2_function< float_type > &left, const c2_function< float_type > &right, float_type x, float_type *yprime, float_type *yprime2))
construct a 'stub' c2_binary_function, which provides access to the combine() function ...
c2_scaled_function_p(const c2_function< float_type > &outer, float_type scale)
construct the function with its scale factor.
~c2_const_ptr()
destructor
c2_sum_p(const c2_function< float_type > &left, const c2_function< float_type > &right)
construct left + right
c2_ptr< float_type > func
const c2_const_ptr< float_type > func
the scaling factor for the function
c2_const_ptr()
construct the container with no function
An interpolating_function_p which is the cumulative integral of a histogram.Note than binedges should...
std::vector< recur_item > * rb_stack
lin_log_interpolating_function_p()
an empty linear-log cubic-spline interpolating_function_p
float_type y
the value of the function at x
virtual interpolating_function_p< float_type > & clone() const
create a new, empty interpolating function of this type (virtual constructor)
static float_type combine(const c2_function< float_type > &left, const c2_function< float_type > &right, float_type x, float_type *yprime, float_type *yprime2)
execute math necessary to do addition
void reset(float_type val)
virtual ~c2_plugin_function_p()
destructor
virtual void get_sampling_grid(float_type amin, float_type amax, std::vector< float_type > &grid) const
return the grid of 'interesting' points along this function which lie in the region requested ...
static PROLOG_HANDLER error
std::vector< float_type > * sampling_grid
compute sqrt(x) with its derivatives.The factory function c2_factory::sqrt() creates *new c2_sqrt_p()...
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
create a container for a c2_function which handles the reference counting.
virtual ~c2_binary_function()
destructor releases ownership of member functions
float_type bad_x_point
this point may be used to record where a calculation ran into trouble
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
get the value and derivatives.
const c2_function< float_type > & get() const
get a reference to our owned function
float_type operator()(float_type x) const
convenience operator to make us look like a function
virtual interpolating_function_p< float_type > & clone() const
create a new, empty interpolating function of this type (virtual constructor)
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
get the value and derivatives.
const c2_function< float_type > * get_ptr() const
get an unchecked pointer to our owned function
struct c2_root_info * root_info
it is declared as a pointer, since many c2_functions may never need one allocated ...
create a c2_function which is the sum of two other c2_function objects.This should always be construc...
void clone_data(const interpolating_function_p< float_type > &rhs)
copy data from another interpolating function. This only makes sense if the source ...
c2_diff_p()
Create a stub just for the combiner to avoid statics.
std::vector< float_type > * yvals
create a quadratic mapping of another functionfor example, given a c2_function f
c2_identity_p()
constructor.
void reset(float_type scale, float_type power)
Modify the mapping after construction.
compute sin(x) with its derivatives.The factory function c2_factory::sin() creates *new c2_sin_p ...
interpolating_function_p()
an empty linear-linear cubic-spline interpolating_function_p
void unset_function()
clear our function
c2_const_ptr< float_type > hinting_function
void reset_evaluations() const
reset the counter
virtual ~c2_classic_function_p()
static float_type combine(const c2_function< float_type > &left, const c2_function< float_type > &right, float_type x, float_type *yprime, float_type *yprime2)
execute math necessary to do composition
c2_typed_ptr()
construct the container with no function
c2_ptr(const c2_ptr< float_type > &src)
copy constructor
create a c2_function which is the difference of two other c2_functions.This should always be construc...
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
get the value and derivatives.
create a c2_function which is a piecewise assembly of other c2_functions.The functions must have incr...
void increment_evaluations() const
count evaluations
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
create a power law mapping of another functionfor example, given a c2_function f
Provides support for c2_function objects which are constructed from two other c2_function objects...
virtual void set_sampling_grid_pointer(std::vector< float_type > &grid)
interpolating_function_p< float_type > & subtract_pointwise(const c2_function< float_type > &rhs) const
produce a newly resampled interpolating_function_p which is the specified difference.
a c2_function which is constantThe factory function c2_factory::constant() creates *new c2_constant_p...
static bool comp_pair(std::pair< float_type, float_type > const &i, std::pair< float_type, float_type > const &j)
void unset_function(void)
clear the function
compute log(x) with its derivatives.The factory function c2_factory::log() creates *new c2_log_p ...
c2_fblock< float_type > * f1
void set_function(const c2_function< float_type > *f)
fill the container with a new function, or clear it with a null pointer