Import Geant4 10.4.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2017-06-30 10:49:55 +02:00
parent 3a5407696b
commit 1a1316fea4
2180 changed files with 237880 additions and 59109 deletions
@@ -36,7 +36,7 @@
*/
//
// $Id: c2_function.hh 97045 2016-05-23 09:49:44Z gcosmo $
// $Id: c2_function.hh 104041 2017-05-09 07:44:14Z gcosmo $
#ifndef __has_c2_function_hh
#define __has_c2_function_hh 1
@@ -178,12 +178,12 @@ public:
/// \param[out] yprime2 the second derivative (if pointer is non-null)
/// \return the value of the function
virtual float_type value_with_derivatives(float_type x, float_type *yprime,
float_type *yprime2) const throw(c2_exception) =0 ;
float_type *yprime2) const /* throw(c2_exception) */ =0 ;
/// \brief evaluate the function in the classic way, ignoring derivatives.
/// \param x the point at which to evaluate
/// \return the value of the function
inline float_type operator () (float_type x) const throw(c2_exception)
inline float_type operator () (float_type x) const /* throw(c2_exception) */
{ return value_with_derivatives(x, (float_type *)0, (float_type *)0); }
/// \brief get the value and derivatives.
@@ -193,7 +193,7 @@ public:
/// \param[out] yprime2 the second derivative (if pointer is non-null)
/// \return the value of the function
inline float_type operator () (float_type x, float_type *yprime,
float_type *yprime2) const throw(c2_exception)
float_type *yprime2) const /* throw(c2_exception) */
{ return value_with_derivatives(x, yprime, yprime2); }
/// \brief solve f(x)==value very efficiently, with explicit knowledge
@@ -232,7 +232,7 @@ public:
float_type start,
float_type value, int *error=0,
float_type *final_yprime=0,
float_type *final_yprime2=0 ) const throw(c2_exception);
float_type *final_yprime2=0 ) const /* throw(c2_exception) */;
/// solve f(x)=value
/// partial_integrals uses a method with an error O(dx**10) with
/// full information from
@@ -270,7 +270,7 @@ public:
float_type rel_tol=1e-12,
int derivs=2, bool adapt=true,
bool extrapolate=true)
const throw(c2_exception);
const /* throw(c2_exception) */;
/// \brief a fully-automated integrator which uses the information
/// provided by the
@@ -307,7 +307,7 @@ public:
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 throw(c2_exception);
const /* throw(c2_exception) */;
/// \brief create a c2_piecewise_function_p from
/// c2_connector_function_p segments which
@@ -384,7 +384,7 @@ public:
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 throw(c2_exception);
std::vector<float_type> *yvals=0) const /* throw(c2_exception) */;
inline float_type xmin() const { return fXMin; }
inline float_type xmax() const { return fXMax; }
@@ -406,7 +406,7 @@ public:
/// this throws c2_exception
/// \return true if in decreasing order, false if increasing
bool check_monotonicity(const std::vector<float_type> &data,
const char message[]) const throw(c2_exception);
const char message[]) const /* throw(c2_exception) */;
/// \brief establish a grid of 'interesting' points on the function.
///
@@ -425,7 +425,7 @@ public:
/// The contents is copied into an internal vector,
/// so the \a grid can be discarded after passingin.
virtual void set_sampling_grid(const std::vector<float_type> &grid)
throw(c2_exception);
/* throw(c2_exception) */;
/// \brief get the sampling grid, which may be a null pointer
/// \return pointer to the sampling grid
@@ -449,11 +449,11 @@ public:
c2_function<float_type> &normalized_function(
float_type amin,
float_type amax,
float_type norm=1.0) const throw(c2_exception);
float_type norm=1.0) const /* throw(c2_exception) */;
c2_function<float_type> &square_normalized_function(
float_type amin, float_type amax,
float_type norm=1.0)
const throw(c2_exception);
const /* throw(c2_exception) */;
/// \brief create a new c2_function from this one which is square-normalized
/// with the provided \a weight on the interval
/// \param amin lower bound of the domain for integration
@@ -464,7 +464,7 @@ public:
c2_function<float_type> &square_normalized_function(
float_type amin, float_type amax, const c2_function<float_type> &weight,
float_type norm=1.0)
const throw(c2_exception);
const /* throw(c2_exception) */;
/// \brief factory function to create a c2_sum_p from a regular
/// algebraic expression.
@@ -506,7 +506,7 @@ public:
void claim_ownership() const { owner_count++; }
/// \brief decrement our reference count. Do not destroy at zero.
/// \return final owner count, to check whether object should disappear.
size_t release_ownership_for_return() const throw(c2_exception) {
size_t release_ownership_for_return() const /* throw(c2_exception) */ {
if(!owner_count) {
std::ostringstream outstr;
outstr << "attempt to release ownership of an unowned function in class ";
@@ -516,7 +516,7 @@ public:
owner_count--;
return owner_count;
}
void release_ownership() const throw(c2_exception) {
void release_ownership() const /* throw(c2_exception) */ {
if(!release_ownership_for_return()) delete this;
}
/// \brief get the reference count, mostly for debugging
@@ -553,7 +553,7 @@ public:
/// \brief fill in a c2_fblock<float_type>... a
/// shortcut for the integrator & sampler
/// \param [in,out] fb the block to fill in with information
inline void fill_fblock(c2_fblock<float_type> &fb) const throw(c2_exception)
inline void fill_fblock(c2_fblock<float_type> &fb) const /* throw(c2_exception) */
{
fb.y=value_with_derivatives(fb.x, &fb.yp, &fb.ypp);
fb.ypbad=c2_isnan(fb.yp) || !c2_isfinite(fb.yp);
@@ -610,14 +610,14 @@ private:
/// to allow very efficient recursion.
/// \param rb a pointer to the recur struct.
float_type integrate_step(struct c2_integrate_recur &rb)
const throw(c2_exception);
const /* throw(c2_exception) */;
/// \brief Carry out the recursive subdivision for sampling.
///
/// This passes information recursively through the \a recur block pointer
/// to allow very efficient recursion.
/// \param rb a pointer to the recur struct.
void sample_step(struct c2_sample_recur &rb) const throw(c2_exception);
void sample_step(struct c2_sample_recur &rb) const /* throw(c2_exception) */;
/// this carry a memory of the last root bracketing,
/// to avoid the necessity of evaluating the function on the
@@ -648,7 +648,7 @@ public:
/// Uses the internal function pointer set by set_function().
virtual float_type value_with_derivatives(
float_type x, float_type *yprime,
float_type *yprime2) const throw(c2_exception)
float_type *yprime2) const /* throw(c2_exception) */
{
if(!func)
throw c2_exception("c2_classic_function called with null function");
@@ -717,7 +717,7 @@ public:
/// Once the function has been released from its container this way,
/// it is an orhpaned object
/// until the caller claims it, so it could get lost if an exception happens.
void release_for_return() throw(c2_exception)
void release_for_return() /* throw(c2_exception) */
{
if(func) func->release_ownership_for_return();
func=0;
@@ -732,7 +732,7 @@ public:
~c2_const_ptr() { this->set_function(0); }
/// \brief get a reference to our owned function
inline const c2_function<float_type> &get() const throw(c2_exception)
inline const c2_function<float_type> &get() const /* throw(c2_exception) */
{
if(!func) throw c2_exception("c2_ptr accessed uninitialized");
return *func;
@@ -753,7 +753,7 @@ public:
/// \param x the value at which to evaluate the contained function
/// \return the evaluated function
float_type operator()(float_type x) const throw(c2_exception)
float_type operator()(float_type x) const /* throw(c2_exception) */
{ return get()(x); }
/// \brief convenience operator to make us look like a function
/// \param x the value at which to evaluate the contained function
@@ -765,30 +765,30 @@ public:
/// and use func(x). Calling this operator wastes some time,
/// since it checks the alidity of the pointer every time.
float_type operator()(float_type x, float_type *yprime,
float_type *yprime2) const throw(c2_exception)
float_type *yprime2) const /* throw(c2_exception) */
{ return get().value_with_derivatives(x, yprime, yprime2); }
/// \brief factory function to create a c2_sum_p from a regular
/// algebraic expression.
/// \param rhs the right-hand term of the sum
/// \return a new c2_function
c2_sum_p<float_type> &operator + (const c2_function<float_type> &rhs)
const throw(c2_exception)
const /* throw(c2_exception) */
{ return *new c2_sum_p<float_type>(get(), rhs); }
c2_diff_p<float_type> &operator - (const c2_function<float_type> &rhs)
const throw(c2_exception)
const /* throw(c2_exception) */
{ return *new c2_diff_p<float_type>(get(), rhs); }
c2_product_p<float_type> &operator * (const c2_function<float_type> &rhs)
const throw(c2_exception)
const /* throw(c2_exception) */
{ return *new c2_product_p<float_type>(get(), rhs); }
c2_ratio_p<float_type> &operator / (const c2_function<float_type> &rhs)
const throw(c2_exception)
const /* throw(c2_exception) */
{ return *new c2_ratio_p<float_type>(get(), rhs); }
/// \brief compose this function outside another.
/// \param inner the inner function
/// \return the composed function
c2_composed_function_p<float_type> &
operator ()(const c2_function<float_type> &inner)
const throw(c2_exception)
const /* throw(c2_exception) */
{ return *new c2_composed_function_p<float_type>(get(), inner); }
protected:
@@ -809,7 +809,7 @@ public:
c2_ptr(const c2_ptr<float_type> &src) :
c2_const_ptr<float_type>() { this->set_function(src.get_ptr()); }
/// \brief get a checked pointer to our owned function
inline c2_function<float_type> &get() const throw(c2_exception)
inline c2_function<float_type> &get() const /* throw(c2_exception) */
{ return *const_cast<c2_function<float_type>*>(
&c2_const_ptr<float_type>::get()); }
/// \brief get an unchecked pointer to our owned function
@@ -849,7 +849,7 @@ public:
: c2_const_ptr<float_type>() { this->set_function(src.get_ptr()); }
/// \brief get a reference to our owned function
inline c2_class<float_type> &get() const throw(c2_exception)
inline c2_class<float_type> &get() const /* throw(c2_exception) */
{
return *static_cast<c2_class<float_type> *>
(const_cast<c2_function<float_type>*>(&c2_const_ptr<float_type>::get()));
@@ -894,7 +894,7 @@ public:
/// Uses the internal function pointer set by set_function().
virtual float_type value_with_derivatives(
float_type x, float_type *yprime,
float_type *yprime2) const throw(c2_exception)
float_type *yprime2) const /* throw(c2_exception) */
{
if(!func.valid())
throw c2_exception("c2_plugin_function_p called uninitialized");
@@ -934,7 +934,7 @@ public:
virtual ~c2_const_plugin_function_p() { }
/// \brief get a const reference to our owned function, for direct access
const c2_function<float_type> &get() const throw(c2_exception)
const c2_function<float_type> &get() const /* throw(c2_exception) */
{ return this->func.get(); }
};
@@ -943,7 +943,7 @@ template <typename float_type=double> class c2_binary_function
public:
virtual float_type value_with_derivatives(
float_type x, float_type *yprime,
float_type *yprime2) const throw (c2_exception)
float_type *yprime2) const /* throw(c2_exception) */
{
if(stub)
throw c2_exception("attempt to evaluate a c2_binary_function stub");
@@ -1005,7 +1005,7 @@ public:
virtual float_type value_with_derivatives(
float_type x, float_type *yprime,
float_type *yprime2) const throw (c2_exception)
float_type *yprime2) const /* throw (c2_exception) */
{
float_type y=this->func->value_with_derivatives(x, yprime, yprime2);
if(yprime) (*yprime)*=yscale;
@@ -1042,7 +1042,7 @@ public:
///
virtual float_type value_with_derivatives(
float_type x, float_type *yprime,
float_type *yprime2) const throw(c2_exception)
float_type *yprime2) const /* throw(c2_exception) */
{
if(!init || x != x0) {
y=this->func->value_with_derivatives(x, &yp, &ypp);
@@ -1076,7 +1076,7 @@ public:
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) throw(c2_exception)
float_type *yprime2) /* throw(c2_exception) */
{
float_type y0, y1;
if(yprime || yprime2) {
@@ -1109,7 +1109,7 @@ public:
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) throw(c2_exception)
float_type *yprime2) /* throw(c2_exception) */
{
float_type y0, y1;
if(yprime || yprime2) {
@@ -1142,7 +1142,7 @@ public:
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) throw(c2_exception)
float_type *yprime2) /* throw(c2_exception) */
{
float_type y0, y1;
if(yprime || yprime2) {
@@ -1179,7 +1179,7 @@ public:
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) throw(c2_exception)
float_type *yprime2) /* throw(c2_exception) */
{
float_type y0, y1;
if(yprime || yprime2) {
@@ -1216,7 +1216,7 @@ public:
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) throw(c2_exception)
float_type *yprime2) /* throw(c2_exception) */
{
float_type y0, y1;
if(yprime || yprime2) {
@@ -1245,7 +1245,7 @@ public:
void reset(float_type val) { value=val; }
virtual float_type value_with_derivatives(
float_type, float_type *yprime,
float_type *yprime2) const throw(c2_exception)
float_type *yprime2) const /* throw(c2_exception) */
{ if(yprime) *yprime=0; if(yprime2) *yprime2=0; return value; }
private:
@@ -1553,7 +1553,7 @@ public:
const std::vector<float_type> &f,
bool lowerSlopeNatural, float_type lowerSlope,
bool upperSlopeNatural, float_type upperSlope, bool splined=true
) throw(c2_exception);
) /* throw(c2_exception) */;
/// \brief do the dirty work of constructing the spline from a function.
/// \param data std::vector of std::pairs of x,y.
@@ -1574,7 +1574,7 @@ public:
std::vector<std::pair<float_type, float_type> > &data,
bool lowerSlopeNatural, float_type lowerSlope,
bool upperSlopeNatural, float_type upperSlope, bool splined=true
) throw(c2_exception);
) /* throw(c2_exception) */;
/// \brief do the dirty work of constructing the spline from a function.
/// \param func a function without any requirement of valid derivatives
@@ -1616,7 +1616,7 @@ public:
float_type abs_tol, float_type rel_tol,
bool lowerSlopeNatural, float_type lowerSlope,
bool upperSlopeNatural, float_type upperSlope
) throw(c2_exception);
) /* throw(c2_exception) */;
/// \brief initialize from a grid of points and a
/// c2_function (un-normalized) to an
@@ -1645,27 +1645,27 @@ public:
interpolating_function_p<float_type> & load_random_generator_function(
const std::vector<float_type> &bincenters,
const c2_function<float_type> &binheights)
throw(c2_exception);
/* throw(c2_exception) */;
interpolating_function_p<float_type> & load_random_generator_bins(
const std::vector<float_type> &bins,
const std::vector<float_type> &binheights,
bool splined=true)
throw(c2_exception);
/* throw(c2_exception) */;
virtual float_type value_with_derivatives(
float_type x, float_type *yprime,
float_type *yprime2) const throw(c2_exception);
float_type *yprime2) const /* throw(c2_exception) */;
/// \brief destructor
virtual ~interpolating_function_p() { delete &fTransform; }
virtual interpolating_function_p<float_type> &clone()
const throw(c2_exception)
const /* throw(c2_exception) */
{ return *new interpolating_function_p<float_type>(); }
void get_data(std::vector<float_type> &xvals,
std::vector<float_type> &yvals) const throw() ;
std::vector<float_type> &yvals) const /* throw() */ ;
void get_internal_data(
std::vector<float_type> &xvals,
@@ -1707,7 +1707,7 @@ protected:
void spline(
bool lowerSlopeNatural, float_type lowerSlope,
bool upperSlopeNatural, float_type upperSlope
) throw(c2_exception);
) /* throw(c2_exception) */;
static bool comp_pair(std::pair<float_type,float_type> const &i,
std::pair<float_type,float_type> const &j)
@@ -1732,7 +1732,7 @@ public:
*new c2_log_lin_function_transformation<float_type>)
{ }
virtual interpolating_function_p<float_type> &clone()
const throw(c2_exception)
const /* throw(c2_exception) */
{ return *new log_lin_interpolating_function_p<float_type>(); }
};
@@ -1751,7 +1751,7 @@ public:
*new c2_lin_log_function_transformation<float_type>)
{ }
virtual interpolating_function_p<float_type> &clone()
const throw(c2_exception)
const /* throw(c2_exception) */
{ return *new lin_log_interpolating_function_p<float_type>(); }
};
@@ -1771,7 +1771,7 @@ public:
*new c2_log_log_function_transformation<float_type>)
{ }
virtual interpolating_function_p<float_type> &clone()
const throw(c2_exception)
const /* throw(c2_exception) */
{ return *new log_log_interpolating_function_p<float_type>(); }
};
@@ -1791,7 +1791,7 @@ public:
*new c2_arrhenius_function_transformation<float_type>)
{ }
virtual interpolating_function_p<float_type> &clone()
const throw(c2_exception)
const /* throw(c2_exception) */
{ return *new arrhenius_interpolating_function_p<float_type>(); }
};
@@ -1807,7 +1807,7 @@ public:
virtual float_type value_with_derivatives(
float_type x, float_type *yprime,
float_type *yprime2) const throw(c2_exception)
float_type *yprime2) const /* throw(c2_exception) */
{ float_type q=std::sin(x);
if(yprime) *yprime=std::cos(x);
if(yprime2) *yprime2=-q;
@@ -1829,7 +1829,7 @@ public:
virtual float_type value_with_derivatives(
float_type x, float_type *yprime,
float_type *yprime2) const throw(c2_exception)
float_type *yprime2) const /* throw(c2_exception) */
{ float_type q=std::cos(x);
if(yprime) *yprime=-std::sin(x);
if(yprime2) *yprime2=-q;
@@ -1848,7 +1848,7 @@ public:
virtual float_type value_with_derivatives(
float_type x, float_type *yprime,
float_type *yprime2) const throw(c2_exception)
float_type *yprime2) const /* throw(c2_exception) */
{
float_type c=std::cos(x), ss=std::sin(x);
float_type t=ss/c;
@@ -1871,7 +1871,7 @@ public:
virtual float_type value_with_derivatives(
float_type x, float_type *yprime,
float_type *yprime2) const throw(c2_exception)
float_type *yprime2) const /* throw(c2_exception) */
{ if(yprime) *yprime=1.0/x;
if(yprime2) *yprime2=-1.0/(x*x);
return std::log(x); }
@@ -1889,7 +1889,7 @@ public:
virtual float_type value_with_derivatives(
float_type x, float_type *yprime,
float_type *yprime2) const throw(c2_exception)
float_type *yprime2) const /* throw(c2_exception) */
{ float_type q=std::exp(x);
if(yprime) *yprime=q;
if(yprime2) *yprime2=q;
@@ -1908,7 +1908,7 @@ public:
virtual float_type value_with_derivatives(
float_type x, float_type *yprime,
float_type *yprime2) const throw(c2_exception)
float_type *yprime2) const /* throw(c2_exception) */
{ float_type q=std::sqrt(x);
if(yprime) *yprime=0.5/q;
if(yprime2) *yprime2=-0.25/(x*q);
@@ -1927,7 +1927,7 @@ public:
virtual float_type value_with_derivatives(
float_type x, float_type *yprime,
float_type *yprime2) const throw(c2_exception)
float_type *yprime2) const /* throw(c2_exception) */
{
float_type q=1.0/x;
float_type y=rscale*q;
@@ -1954,7 +1954,7 @@ public:
virtual float_type value_with_derivatives(
float_type x, float_type *yprime,
float_type *yprime2) const throw(c2_exception)
float_type *yprime2) const /* throw(c2_exception) */
{ if(yprime) *yprime=1.0; if(yprime2) *yprime2=0; return x; }
};
@@ -1986,7 +1986,7 @@ public:
{ xint=x0; intercept=y0; m=slope; }
virtual float_type value_with_derivatives(
float_type x, float_type *yprime,
float_type *yprime2) const throw(c2_exception)
float_type *yprime2) const /* throw(c2_exception) */
{ if(yprime) *yprime=m;
if(yprime2) *yprime2=0;
return m*(x-xint)+intercept; }
@@ -2031,7 +2031,7 @@ public:
float_type x2coef) { intercept=y0; center=x0; a=x2coef; b=xcoef; }
virtual float_type value_with_derivatives(
float_type x, float_type *yprime,
float_type *yprime2) const throw(c2_exception)
float_type *yprime2) const /* throw(c2_exception) */
{ float_type dx=x-center;
if(yprime) *yprime=2*a*dx+b;
if(yprime2) *yprime2=2*a;
@@ -2069,7 +2069,7 @@ public:
void reset(float_type scale, float_type power) { a=scale; b=power; }
virtual float_type value_with_derivatives(
float_type x, float_type *yprime,
float_type *yprime2) const throw(c2_exception)
float_type *yprime2) const /* throw(c2_exception) */
{ float_type q=a*std::pow(x,b-2);
if(yprime) *yprime=b*q*x;
if(yprime2) *yprime2=b*(b-1)*q;
@@ -2106,7 +2106,7 @@ public:
c2_inverse_function_p(const c2_function<float_type> &source);
virtual float_type value_with_derivatives(
float_type x, float_type *yprime,
float_type *yprime2) const throw(c2_exception);
float_type *yprime2) const /* throw(c2_exception) */;
/// \brief give the function a hint as to where to look for its inverse
/// \param hint the likely value of the inverse,
@@ -2264,7 +2264,7 @@ public:
virtual ~c2_connector_function_p();
virtual float_type value_with_derivatives(
float_type x, float_type *yprime,
float_type *yprime2) const throw (c2_exception);
float_type *yprime2) const /* throw (c2_exception) */;
protected:
/// \brief fill container numerically
void init(
@@ -2309,7 +2309,7 @@ public:
virtual ~c2_piecewise_function_p();
virtual float_type value_with_derivatives(
float_type x, float_type *yprime,
float_type *yprime2) const throw (c2_exception);
float_type *yprime2) const /* throw (c2_exception) */;
/// \brief append a new function to the sequence
///
/// This takes a c2_function, and appends it onto the end of
@@ -2323,7 +2323,7 @@ public:
/// \param func a c2_function with a defined domain to be
/// appended to the collection
void append_function(const c2_function<float_type> &func)
throw (c2_exception);
/* throw (c2_exception) */;
protected:
std::vector<c2_const_ptr<float_type> > functions;
mutable int lastKLow;