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;
101 template <
typename float_type>
class c2_fblock
152 "c2_function.hh 490 2012-04-10 19:05:40Z marcus ";
165 std::ostringstream outstr;
166 outstr <<
"attempt to delete an object with non-zero ownership in class";
167 outstr <<
typeid(*this).name() << std::endl;
181 float_type *yprime2)
const =0 ;
196 float_type *yprime2)
const
231 float_type
find_root(float_type lower_bracket, float_type upper_bracket,
234 float_type *final_yprime=0,
235 float_type *final_yprime2=0 )
const ;
268 std::vector<float_type> *partials = 0,
269 float_type abs_tol=1
e-12,
270 float_type rel_tol=1e-12,
271 int derivs=2,
bool adapt=true,
272 bool extrapolate=true)
306 float_type
integral(float_type amin, float_type amax,
307 std::vector<float_type> *partials = 0,
308 float_type abs_tol=1e-12, float_type rel_tol=1e-12,
309 int derivs=2,
bool adapt=true,
bool extrapolate=true)
384 float_type amin, float_type amax,
385 float_type abs_tol=1e-12, float_type rel_tol=1e-12,
386 int derivs=2, std::vector<float_type> *xvals=0,
387 std::vector<float_type> *yvals=0) const ;
436 std::vector<float_type> &grid)
const ;
441 size_t refinement)
const;
454 float_type amin, float_type amax,
511 std::ostringstream outstr;
512 outstr <<
"attempt to release ownership of an unowned function in class ";
513 outstr <<
typeid(*this).name() << std::endl;
534 fXMin(-std::numeric_limits<float_type>::
max()),
650 float_type
x, float_type *yprime,
651 float_type *yprime2)
const
654 throw c2_exception(
"c2_classic_function called with null function");
655 if(yprime) *yprime=0;
656 if(yprime2) *yprime2=0;
663 const float_type (*
func)(float_type);
722 if(
func)
func->release_ownership_for_return();
768 float_type *yprime2)
const
769 {
return get().value_with_derivatives(
x, yprime, yprime2); }
836 template <
typename float_type,
template <
typename>
class c2_class >
852 inline c2_class<float_type> &
get()
const
854 return *
static_cast<c2_class<float_type> *
>
862 {
return static_cast<c2_class<float_type> *
>(
865 operator c2_class<float_type>&()
const {
return get(); }
890 func.set_function(f);
896 float_type
x, float_type *yprime,
897 float_type *yprime2)
const
900 throw c2_exception(
"c2_plugin_function_p called uninitialized");
901 return func->value_with_derivatives(
x, yprime, yprime2);
910 std::vector<float_type> &grid)
const
913 throw c2_exception(
"c2_plugin_function_p called uninitialized");
916 else func->get_sampling_grid(amin, amax, grid);
938 {
return this->
func.get(); }
945 float_type
x, float_type *yprime,
946 float_type *yprime2)
const
949 throw c2_exception(
"attempt to evaluate a c2_binary_function stub");
961 float_type
x, float_type *yprime,
962 float_type *yprime2),
976 float_type
x, float_type *yprime, float_type *yprime2)
984 float_type
x, float_type *yprime, float_type *yprime2);
1007 float_type
x, float_type *yprime,
1008 float_type *yprime2)
const
1010 float_type
y=this->
func->value_with_derivatives(
x, yprime, yprime2);
1011 if(yprime) (*yprime)*=
yscale;
1012 if(yprime2) (*yprime2)*=
yscale;
1044 float_type
x, float_type *yprime,
1045 float_type *yprime2)
const
1048 y=this->
func->value_with_derivatives(
x, &
yp, &
ypp);
1052 if(yprime) *yprime=
yp;
1053 if(yprime2) *yprime2=
ypp;
1078 float_type
x, float_type *yprime,
1079 float_type *yprime2)
1082 if(yprime || yprime2) {
1083 float_type yp0, ypp0, yp1, ypp1;
1086 if(yprime) *yprime=yp1*yp0;
1087 if(yprime2) *yprime2=ypp0*yp1+yp0*yp0*ypp1;
1096 template <
typename float_type=
double>
class c2_sum_p
1111 float_type
x, float_type *yprime,
1112 float_type *yprime2)
1115 if(yprime || yprime2) {
1116 float_type yp0, ypp0, yp1, ypp1;
1119 if(yprime) *yprime=yp0+yp1;
1120 if(yprime2) *yprime2=ypp0+ypp1;
1129 template <
typename float_type=
double>
class c2_diff_p
1144 float_type
x, float_type *yprime,
1145 float_type *yprime2)
1148 if(yprime || yprime2) {
1149 float_type yp0, ypp0, yp1, ypp1;
1152 if(yprime) *yprime=yp0-yp1;
1153 if(yprime2) *yprime2=ypp0-ypp1;
1166 template <
typename float_type=
double>
class c2_product_p
1181 float_type
x, float_type *yprime,
1182 float_type *yprime2)
1185 if(yprime || yprime2) {
1186 float_type yp0, ypp0, yp1, ypp1;
1189 if(yprime) *yprime=y1*yp0+y0*yp1;
1190 if(yprime2) *yprime2=ypp0*y1+2.0*yp0*yp1+ypp1*y0;
1203 template <
typename float_type=
double>
class c2_ratio_p
1218 float_type
x, float_type *yprime,
1219 float_type *yprime2)
1222 if(yprime || yprime2) {
1223 float_type yp0, ypp0, yp1, ypp1;
1226 if(yprime) *yprime=(yp0*y1-y0*yp1)/(y1*y1);
1227 if(yprime2) *yprime2=(y1*y1*ypp0+y0*(2*yp1*yp1-y1*ypp1)-2*y1*yp0*yp1)
1247 float_type, float_type *yprime,
1248 float_type *yprime2)
const
1249 {
if(yprime) *yprime=0;
if(yprime2) *yprime2=0;
return value; }
1266 float_type (*xin)(float_type),
1267 float_type (*xinp)(float_type),
1268 float_type (*xinpp)(float_type),
1269 float_type (*xout)(float_type)
1294 float_type (*
const pIn)(float_type);
1300 float_type (*
const pOut)(float_type);
1303 virtual float_type
fIn(float_type
x)
const {
return pIn(x); }
1309 virtual float_type
fOut(float_type
x)
const {
return pOut(x); }
1314 throw c2_exception(
"use of improperly constructed axis transform");
1317 static float_type
ident(float_type
x) {
return x; }
1319 static float_type
one(float_type) {
return 1; }
1321 static float_type
zero(float_type) {
return 0; }
1323 static float_type
recip(float_type
x) {
return 1.0/
x; }
1350 true, std::log, this->
recip,
1378 template <
typename float_type>
1387 isIdentity(!(xx.fTransformed || yy.fTransformed)),
X(xx),
Y(yy) { }
1392 float_type
y, float_type yp0, float_type ypp0,
1393 float_type *yprime, float_type *yprime2)
const;
1552 const std::vector<float_type> &
x,
1553 const std::vector<float_type> &
f,
1554 bool lowerSlopeNatural, float_type lowerSlope,
1555 bool upperSlopeNatural, float_type upperSlope,
bool splined=
true
1574 std::vector<std::pair<float_type, float_type> > &
data,
1575 bool lowerSlopeNatural, float_type lowerSlope,
1576 bool upperSlopeNatural, float_type upperSlope,
bool splined=
true
1615 float_type amin, float_type amax,
1616 float_type abs_tol, float_type rel_tol,
1617 bool lowerSlopeNatural, float_type lowerSlope,
1618 bool upperSlopeNatural, float_type upperSlope
1646 const std::vector<float_type> &bincenters,
1651 const std::vector<float_type> &bins,
1652 const std::vector<float_type> &binheights,
1657 float_type
x, float_type *yprime,
1658 float_type *yprime2)
const ;
1667 void get_data(std::vector<float_type> &xvals,
1668 std::vector<float_type> &yvals)
const ;
1671 std::vector<float_type> &xvals,
1672 std::vector<float_type> &yvals,
1673 std::vector<float_type> &y2vals)
const
1674 { xvals=
X; yvals=
F; y2vals=
y2; }
1708 bool lowerSlopeNatural, float_type lowerSlope,
1709 bool upperSlopeNatural, float_type upperSlope
1712 static bool comp_pair(std::pair<float_type,float_type>
const &i,
1713 std::pair<float_type,float_type>
const &j)
1714 {
return i.first<j.first;}
1809 float_type
x, float_type *yprime,
1810 float_type *yprime2)
const
1811 { float_type q=std::sin(
x);
1812 if(yprime) *yprime=std::cos(
x);
1813 if(yprime2) *yprime2=-q;
1817 std::vector<float_type> &grid)
const;
1831 float_type
x, float_type *yprime,
1832 float_type *yprime2)
const
1833 { float_type q=std::cos(
x);
1834 if(yprime) *yprime=-std::sin(
x);
1835 if(yprime2) *yprime2=-q;
1850 float_type
x, float_type *yprime,
1851 float_type *yprime2)
const
1853 float_type c=std::cos(
x),
ss=std::sin(
x);
1855 float_type yp=1/(c*c);
1856 if(yprime) { *yprime=yp; }
1857 if(yprime2){*yprime2=2*t*yp; }
1873 float_type
x, float_type *yprime,
1874 float_type *yprime2)
const
1875 {
if(yprime) *yprime=1.0/
x;
1876 if(yprime2) *yprime2=-1.0/(
x*
x);
1877 return std::log(
x); }
1891 float_type
x, float_type *yprime,
1892 float_type *yprime2)
const
1893 { float_type q=std::exp(
x);
1894 if(yprime) *yprime=q;
1895 if(yprime2) *yprime2=q;
1910 float_type
x, float_type *yprime,
1911 float_type *yprime2)
const
1912 { float_type q=std::sqrt(
x);
1913 if(yprime) *yprime=0.5/q;
1914 if(yprime2) *yprime2=-0.25/(
x*q);
1929 float_type
x, float_type *yprime,
1930 float_type *yprime2)
const
1934 if(yprime) *yprime=-y*q;
1935 if(yprime2) *yprime2=2*y*q*q;
1956 float_type
x, float_type *yprime,
1957 float_type *yprime2)
const
1958 {
if(yprime) *yprime=1.0;
if(yprime2) *yprime2=0;
return x; }
1985 void reset(float_type x0, float_type y0, float_type slope)
1988 float_type
x, float_type *yprime,
1989 float_type *yprime2)
const
1990 {
if(yprime) *yprime=
m;
1991 if(yprime2) *yprime2=0;
2023 float_type xcoef, float_type x2coef) :
2030 void reset(float_type x0, float_type y0, float_type xcoef,
2033 float_type
x, float_type *yprime,
2034 float_type *yprime2)
const
2036 if(yprime) *yprime=2*
a*dx+
b;
2037 if(yprime2) *yprime2=2*
a;
2071 float_type
x, float_type *yprime,
2072 float_type *yprime2)
const
2073 { float_type q=
a*std::pow(
x,
b-2);
2074 if(yprime) *yprime=
b*q*
x;
2075 if(yprime2) *yprime2=
b*(
b-1)*q;
2108 float_type
x, float_type *yprime,
2109 float_type *yprime2)
const ;
2186 const std::vector<float_type> binheights,
2187 bool normalize=
false,
2188 bool inverse_function=
false,
bool drop_zeros=
true);
2230 bool auto_center, float_type
y1);
2247 float_type x0, float_type y0, float_type yp0, float_type ypp0,
2248 float_type x2, float_type
y2, float_type yp2, float_type ypp2,
2249 bool auto_center, float_type y1);
2261 bool auto_center, float_type y1);
2266 float_type
x, float_type *yprime,
2267 float_type *yprime2)
const ;
2273 bool auto_center, float_type y1);
2311 float_type
x, float_type *yprime,
2312 float_type *yprime2)
const ;
2332 #include "c2_function.icc"
const c2_function< float_type > * func
c2_recip_p(float_type scale)
constructor.
interpolating_function_p< float_type > & load_random_generator_bins(const std::vector< float_type > &bins, const std::vector< float_type > &binheights, bool splined=true)
float_type operator()(float_type x) const
evaluate the function in the classic way, ignoring derivatives.
const std::string cvs_file_vers() const
get versioning information for the source file
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
const XML_Char XML_Encoding * info
T max(const T t1, const T t2)
brief Return the largest of the two arguments
log_log_interpolating_function_p()
an empty log-log cubic-spline interpolating_function_p
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
get the value and derivatives.
void set_start_hint(float_type hint) const
give the function a hint as to where to look for its inverse
interpolating_function_p< float_type > & multiply_pointwise(const c2_function< float_type > &rhs) const
c2_function< float_type > * get_ptr() const
get an unchecked pointer to our owned function
create a c2_function which is the ratio of two other c2_functions.This should always be constructed u...
virtual void get_sampling_grid(float_type amin, float_type amax, std::vector< float_type > &grid) const
void get_internal_data(std::vector< float_type > &xvals, std::vector< float_type > &yvals, std::vector< float_type > &y2vals) const
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
get the value and derivatives.
a container into which any conventional c-style function can be dropped, to create a degenerate c2_fu...
const c2_const_ptr< float_type > Left
compute tan(x) with its derivatives.The factory function c2_factory::tan() creates *new c2_tan_p ...
interpolating_function_p< float_type > & add_pointwise(const c2_function< float_type > &rhs) const
float_type ypp
the second derivative at x
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
get the value and derivatives.
Float_t y1[n_points_granero]
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
void claim_ownership() const
increment our reference count. Destruction is only legal if the count is zero.
std::vector< float_type > * xvals
std::vector< float_type > y2
virtual ~c2_piecewise_function_p()
destructor
size_t get_evaluations() const
virtual float_type value_with_derivatives(float_type, float_type *yprime, float_type *yprime2) const
get the value and derivatives.
create a linear mapping of another functionfor example, given a c2_function f
virtual ~c2_connector_function_p()
destructor
c2_ratio_p< float_type > & operator/(const c2_function< float_type > &rhs) const
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
void preen_sampling_grid(std::vector< float_type > *result) const
The grid is modified in place.
interpolating_function_p< float_type > & divide_pointwise(const c2_function< float_type > &rhs) const
float_type(*const combine)(const c2_function< float_type > &left, const c2_function< float_type > &right, float_type x, float_type *yprime, float_type *yprime2)
c2_function< float_type > & normalized_function(float_type amin, float_type amax, float_type norm=1.0) const
create a new c2_function from this one which is normalized on the interval
c2_diff_p< float_type > & operator-(const c2_function< float_type > &rhs) const
virtual const char * what() const
void message(RunManager *runmanager)
c2_function< float_type > & square_normalized_function(float_type amin, float_type amax, float_type norm=1.0) const
const c2_ptr< float_type > & operator=(const c2_ptr< float_type > &f)
fill the container from another container
interpolating_function_p< float_type > & subtract_pointwise(const c2_function< float_type > &rhs) const
c2_const_plugin_function_p()
construct the container with no function
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
get the value and derivatives.
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
interpolating_function_p< float_type > & load(const std::vector< float_type > &x, const std::vector< float_type > &f, bool lowerSlopeNatural, float_type lowerSlope, bool upperSlopeNatural, float_type upperSlope, bool splined=true)
do the dirty work of constructing the spline from a function.
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...
c2_diff_p< float_type > & operator-(const c2_function< float_type > &rhs) const
factory function to create a c2_diff_p from a regular algebraic expression.
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
get the value and derivatives.
virtual void get_sampling_grid(float_type amin, float_type amax, std::vector< float_type > &grid) const
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
get the value and derivatives.
c2_fblock< float_type > f1
c2_cached_function_p(const c2_function< float_type > &f)
construct the container
virtual ~interpolating_function_p()
destructor
void append_function(const c2_function< float_type > &func)
append a new function to the sequence
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
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
get the value and derivatives.
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 void get_sampling_grid(float_type amin, float_type amax, std::vector< float_type > &grid) const
const c2_function< float_type > * operator->() const
get a checked pointer to our owned function
float_type integrate_step(struct c2_integrate_recur &rb) const
Carry out the recursive subdivision and integration.
void set_function(const c2_function< float_type > *f)
c2_class< float_type > * operator->() const
get a checked pointer to our owned function
c2_constant_p(float_type x)
float_type partial_integrals(std::vector< float_type > xgrid, std::vector< float_type > *partials=0, float_type abs_tol=1e-12, float_type rel_tol=1e-12, int derivs=2, bool adapt=true, bool extrapolate=true) const
c2_sum_p()
Create a stub just for the combiner to avoid statics.
c2_piecewise_function_p()
construct the container
interpolating_function_p< float_type > & load_pairs(std::vector< std::pair< float_type, float_type > > &data, bool lowerSlopeNatural, float_type lowerSlope, bool upperSlopeNatural, float_type upperSlope, bool splined=true)
do the dirty work of constructing the spline from a function.
TFile f0("testem6_0.root")
c2_product_p< float_type > & operator*(const c2_function< float_type > &rhs) const
std::vector< float_type > F
c2_plugin_function_p()
construct the container with no function
bool check_monotonicity(const std::vector< float_type > &data, const char message[]) const
check that a vector is monotonic, throw an exception if not, and return a flag if it is reversed ...
virtual ~c2_const_plugin_function_p()
destructor
Float_t y2[n_points_geant4]
c2_function(const c2_function< float_type > &src)
interpolating_function_p< float_type > & binary_operator(const c2_function< float_type > &rhs, const c2_binary_function< float_type > *combining_stub) const
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< float_type > & clone() const
void set_hinting_function(const c2_function< float_type > *hint_func)
set or unset the approximate function used to start the root finder
virtual void set_sampling_grid(const std::vector< float_type > &grid)
establish a grid of 'interesting' points on the function.
const XML_Char const XML_Char * data
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
get the value and derivatives.
size_t release_ownership_for_return() const
decrement our reference count. Do not destroy at zero.
A spline with X and Y transformed into log space.Most useful for functions looking like y=x^n or any ...
compute scale/x with its derivatives.The factory function c2_factory::recip() creates *new c2_recip_p...
void spline(bool lowerSlopeNatural, float_type lowerSlope, bool upperSlopeNatural, float_type upperSlope)
create the spline coefficients
void reset(float_type scale)
reset the scale factor
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
bool valid() const
check if we have a valid function
A spline with X transformed into log space.
void set_hinting_function(const c2_const_ptr< float_type > hint_func)
set the hinting function from a pointer.
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
get the value and derivatives.
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
get the value and derivatives.
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.
void reset(float_type x0, float_type y0, float_type slope)
Change the slope and intercepts after construction.
c2_piecewise_function_p< float_type > * adaptively_sample(float_type amin, float_type amax, float_type abs_tol=1e-12, float_type rel_tol=1e-12, int derivs=2, std::vector< float_type > *xvals=0, std::vector< float_type > *yvals=0) const
create a c2_piecewise_function_p from c2_connector_function_p segments which is a representation of t...
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
get the value and derivatives.
const XML_Char int const XML_Char * value
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
get the value and derivatives.
c2_function< float_type > * operator->() const
get a checked pointer to our owned function
void set_function(c2_function< float_type > *f)
compute x with its derivatives.The factory function c2_factory::identity() creates *new c2_identity_p...
void set_upper_extrapolation(float_type bound)
c2_const_ptr(const c2_const_ptr< float_type > &src)
copy constructor
void set_domain(float_type amin, float_type amax)
virtual interpolating_function_p< float_type > & clone() const
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)
virtual ~c2_function()
destructor
structure used to hold root bracketing information
void release_for_return()
release the function without destroying it, so it can be returned from a function ...
std::vector< float_type > X
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
const c2_function< float_type > & get() const
get a reference to our owned function
float_type yp
the derivative at x
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.
const G4ThreeVector const G4double const
create a container for a c2_function which handles the reference counting. It is useful as a smart co...
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
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
get the value and derivatives.
std::vector< float_type > Xraw
const c2_const_ptr< float_type > func
const float_type(* func)(float_type)
pointer to our function
interpolating_function_p< float_type > & sample_function(const c2_function< float_type > &func, float_type amin, float_type amax, float_type abs_tol, float_type rel_tol, bool lowerSlopeNatural, float_type lowerSlope, bool upperSlopeNatural, float_type upperSlope)
do the dirty work of constructing the spline from a function.
const std::string cvs_header_vers() const
get versioning information for the header file
the exception class for c2_function operations.
float_type integral(float_type amin, float_type amax, std::vector< float_type > *partials=0, float_type abs_tol=1e-12, float_type rel_tol=1e-12, int derivs=2, bool adapt=true, bool extrapolate=true) const
a fully-automated integrator which uses the information provided by the get_sampling_grid() function ...
c2_ptr()
construct the container with no function
void sample_step(struct c2_sample_recur &rb) const
Carry out the recursive subdivision for sampling.
G4double G4ParticleHPJENDLHEData::G4double result
float_type find_root(float_type lower_bracket, float_type upper_bracket, float_type start, float_type value, int *error=0, float_type *final_yprime=0, float_type *final_yprime2=0) const
solve f(x)==value very efficiently, with explicit knowledge of derivatives of the function ...
const c2_function< float_type > * get_ptr() const
get an unchecked pointer to our owned 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.
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
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
interpolating_function_p< float_type > & unary_operator(const c2_function< float_type > &source) const
structure used to pass information recursively in sampler.
c2_class< float_type > * get_ptr() const
get an unchecked pointer to our owned function
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
get the value and derivatives.
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)
float_type operator()(float_type x, float_type *yprime, float_type *yprime2) const
convenience operator to make us look like a function
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))
c2_scaled_function_p(const c2_function< float_type > &outer, float_type scale)
construct the function with its scale factor.
virtual interpolating_function_p< float_type > & clone() const
~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_sum_p< float_type > & operator+(const c2_function< float_type > &rhs) const
factory function to create a c2_sum_p from a regular algebraic expression.
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
virtual float_type get_start_hint(float_type x) const
size_t count_owners() const
get the reference count, mostly for debugging
virtual interpolating_function_p< float_type > & clone() const
lin_log_interpolating_function_p()
an empty linear-log cubic-spline interpolating_function_p
c2_fblock< float_type > * f0
c2_fblock< float_type > * f0
float_type y
the value of the function at x
c2_connector_function_p(float_type x0, const c2_function< float_type > &f0, float_type x2, const c2_function< float_type > &f2, bool auto_center, float_type y1)
construct the container from two functions
void operator=(const c2_typed_ptr< float_type, c2_class > &f)
fill the container from another container
accumulated_histogram(const std::vector< float_type >binedges, const std::vector< float_type > binheights, bool normalize=false, bool inverse_function=false, bool drop_zeros=true)
Construct the integrated histogram.
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
void refine_sampling_grid(std::vector< float_type > &grid, size_t refinement) const
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
get the value and derivatives.
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()...
interpolating_function_p< float_type > & load_random_generator_function(const std::vector< float_type > &bincenters, const c2_function< float_type > &binheights)
initialize from a grid of points and a c2_function (un-normalized) to an interpolator which...
virtual ~c2_binary_function()
destructor releases ownership of member functions
c2_ratio_p< float_type > & operator/(const c2_function< float_type > &rhs) const
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
get the value and derivatives.
void increment_evaluations() const
count evaluations
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 =0
get the value and derivatives.
struct c2_root_info * root_info
void release_ownership() const
void clone_data(const interpolating_function_p< float_type > &rhs)
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
get the value and derivatives.
Float_t x2[n_points_geant4]
void fill_fblock(c2_fblock< float_type > &fb) const
fill in a c2_fblock<float_type>... a shortcut for the integrator & sampler
c2_diff_p()
Create a stub just for the combiner to avoid statics.
std::vector< float_type > * yvals
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 quadratic mapping of another functionfor example, given a c2_function f
void reset_evaluations() const
reset the counter
void set_lower_extrapolation(float_type bound)
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
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
get the value and derivatives.
void init(const c2_fblock< float_type > &fb0, const c2_fblock< float_type > &fb2, bool auto_center, float_type y1)
fill container numerically
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 a piecewise assembly of other c2_functions.The functions must have incr...
c2_fblock< float_type > lower
create a power law mapping of another functionfor example, given a c2_function f
virtual float_type value_with_derivatives(float_type x, float_type *yprime, float_type *yprime2) const
get the value and derivatives.
virtual void set_sampling_grid_pointer(std::vector< float_type > &grid)
void get_data(std::vector< float_type > &xvals, std::vector< float_type > &yvals) const
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)
float_type previous_estimate
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)