Geant4  10.01.p03
c2_factory.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
36 //
37 // $Id: c2_factory.hh 68263 2013-03-20 10:16:46Z maire $
38 
39 #ifndef __has_c2_factory_hh
40 #define __has_c2_factory_hh 1
41 
42 #include "c2_function.hh"
43 
57 template <typename float_type> class c2_factory {
58 public:
59 
62  &classic_function(float_type (*c_func)(float_type))
63  { return *new c2_classic_function_p<float_type>(c_func); }
66  { return *new c2_plugin_function_p<float_type>(); }
70  { return *new c2_plugin_function_p<float_type>(f); }
77  { return *new c2_const_plugin_function_p<float_type>(f); }
80  &scaled_function(const c2_function<float_type> &outer, float_type scale)
81  { return *new c2_scaled_function_p<float_type>(outer, scale); }
85  { return *new c2_cached_function_p<float_type>(func); }
88  &constant(float_type x) { return *new c2_constant_p<float_type>(x); }
92  { return *new interpolating_function_p<float_type>(); }
111  float_type x0, const c2_function<float_type> &f0, float_type x2,
112  const c2_function<float_type> &f2, bool auto_center, float_type y1)
113  {return *new c2_connector_function_p<float_type>(x0, f0, x2, f2,
114  auto_center, y1); }
117  const c2_fblock<float_type> &fb0, const c2_fblock<float_type> &fb2,
118  bool auto_center, float_type y1)
119  { return *new c2_connector_function_p<float_type>(fb0, fb2,
120  auto_center, y1); }
123  float_type x0, float_type y0, float_type yp0, float_type ypp0,
124  float_type x2, float_type y2, float_type yp2, float_type ypp2,
125  bool auto_center, float_type y1)
127  x0, y0, yp0, ypp0, x2, y2, yp2, ypp2, auto_center, y1); }
130  { return *new c2_piecewise_function_p<float_type>(); }
132 static c2_sin_p<float_type> &sin() { return *new c2_sin_p<float_type>(); }
134 static c2_cos_p<float_type> &cos() { return *new c2_cos_p<float_type>(); }
136 static c2_tan_p<float_type> &tan() { return *new c2_tan_p<float_type>(); }
138 static c2_log_p<float_type> &log() { return *new c2_log_p<float_type>(); }
140 static c2_exp_p<float_type> &exp() { return *new c2_exp_p<float_type>(); }
144 static c2_recip_p<float_type> &recip(float_type scale=1)
145  { return *new c2_recip_p<float_type>(scale); }
148  { return *new c2_identity_p<float_type>(); }
151  &linear(float_type x0, float_type y0, float_type slope)
152  { return *new c2_linear_p<float_type>(x0, y0, slope); }
155  float_type x0, float_type y0, float_type xcoef, float_type x2coef)
156  { return *new c2_quadratic_p<float_type>(x0, y0, xcoef, x2coef); }
158 static c2_power_law_p<float_type> &power_law(float_type scale, float_type power)
159  { return *new c2_power_law_p<float_type>(scale, power); }
163  { return *new c2_inverse_function_p<float_type>(source); }
164 
165 #if 0
166 template <template <typename f_t> class Final >
170  & inverse_integrated_density_bins(const std::vector<float_type> &bincenters,
171  const std::vector<float_type> &binheights)
172  throw(c2_exception)
173  {
174  return ::inverse_integrated_density_bins<float_type, Final<float_type> >
175  (bincenters, binheights);
176  }
179 template <template <typename f_t> class Final >
181  & inverse_integrated_density_function(
182  const std::vector<float_type> &bincenters,
183  const c2_function<float_type> &binheights)
184  throw(c2_exception)
185  {
186  return ::inverse_integrated_density_function<float_type,
187  Final<float_type> >
188  (bincenters, binheights);
189  }
190 #endif
191 
192 };
193 
194 #endif
static c2_classic_function_p< float_type > & classic_function(float_type(*c_func)(float_type))
make a *new object
Definition: c2_factory.hh:62
Create a very lightweight method to return a scalar multiple of another function. \ \The factory func...
Definition: c2_function.hh:899
static lin_log_interpolating_function_p< float_type > & lin_log_interpolating_function()
make a *new object
Definition: c2_factory.hh:95
a container into which any conventional c-style function can be dropped, to create a degenerate c2_fu...
Definition: c2_function.hh:534
compute tan(x) with its derivatives.The factory function c2_factory::tan() creates *new c2_tan_p ...
static const G4double f2
create the formal inverse function of another functionfor example, given a c2_function f ...
create a linear mapping of another functionfor example, given a c2_function f
static c2_const_plugin_function_p< float_type > & const_plugin_function()
make a *new object
Definition: c2_factory.hh:72
A spline with X in reciprocal space and Y transformed in log space.Most useful for thermodynamic type...
static c2_power_law_p< float_type > & power_law(float_type scale, float_type power)
make a *new object
Definition: c2_factory.hh:158
static arrhenius_interpolating_function_p< float_type > & arrhenius_interpolating_function()
make a *new object
Definition: c2_factory.hh:107
static c2_tan_p< float_type > & tan()
make a *new object
Definition: c2_factory.hh:136
compute cos(x) with its derivatives.The factory function c2_factory::cos() creates *new c2_cos_p ...
compute exp(x) with its derivatives.The factory function c2_factory::exp() creates *new c2_exp_p ...
static c2_plugin_function_p< float_type > & plugin_function()
make a *new object
Definition: c2_factory.hh:65
Provides the headers for the general c2_function algebra which supports fast, flexible operations on ...
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...
static c2_connector_function_p< float_type > & connector_function(float_type x0, float_type y0, float_type yp0, float_type ypp0, float_type x2, float_type y2, float_type yp2, float_type ypp2, bool auto_center, float_type y1)
make a *new object
Definition: c2_factory.hh:122
create a cubic spline interpolation of a set of (x,y) pairsThis is one of the main reasons for c2_fun...
A spline with X transformed into log space.Most useful for functions looking like y=log(x) or any oth...
static c2_connector_function_p< float_type > & connector_function(float_type x0, const c2_function< float_type > &f0, float_type x2, const c2_function< float_type > &f2, bool auto_center, float_type y1)
make a *new object
Definition: c2_factory.hh:110
A container into which any other c2_function can be dropped.It allows a function to be pre-evaluated ...
Definition: c2_function.hh:937
structure used to hold evaluated function data at a point.
Definition: c2_function.hh:101
create a quadratic mapping of another functionfor example, given a c2_function f
Definition: c2_function.hh:85
a c2_plugin_function_p which promises not to fiddle with the plugged function.The factory function c2...
Definition: c2_function.hh:824
compute x with its derivatives.The factory function c2_factory::identity() creates *new c2_identity_p...
static c2_plugin_function_p< float_type > & plugin_function(c2_function< float_type > &f)
make a *new object
Definition: c2_factory.hh:69
static c2_const_plugin_function_p< float_type > & const_plugin_function(const c2_function< float_type > &f)
make a *new object
Definition: c2_factory.hh:76
static c2_constant_p< float_type > & constant(float_type x)
make a *new object
Definition: c2_factory.hh:88
a container into which any other c2_function can be dropped, to allow expressions with replacable com...
Definition: c2_function.hh:782
static c2_recip_p< float_type > & recip(float_type scale=1)
make a *new object
Definition: c2_factory.hh:144
static c2_identity_p< float_type > & identity()
make a *new object
Definition: c2_factory.hh:147
the exception class for c2_function operations.
Definition: c2_function.hh:65
static log_lin_interpolating_function_p< float_type > & log_lin_interpolating_function()
make a *new object
Definition: c2_factory.hh:99
create a c2_function which smoothly connects two other c2_functions.This takes two points and generat...
static log_log_interpolating_function_p< float_type > & log_log_interpolating_function()
make a *new object
Definition: c2_factory.hh:103
the parent class for all c2_functions.
Definition: c2_function.hh:138
create a c2_function which is a piecewise assembly of other c2_functions.The functions must have incr...
Definition: c2_function.hh:84
static c2_log_p< float_type > & log()
make a *new object
Definition: c2_factory.hh:138
static c2_linear_p< float_type > & linear(float_type x0, float_type y0, float_type slope)
make a *new object
Definition: c2_factory.hh:151
A spline with Y transformed into log space.Most useful for functions looking like y=exp(x) ...
a factory of pre-templated c2_function generators
Definition: c2_factory.hh:57
static c2_inverse_function_p< float_type > & inverse_function(const c2_function< float_type > &source)
make a *new object
Definition: c2_factory.hh:162
static c2_sqrt_p< float_type > & sqrt()
make a *new object
Definition: c2_factory.hh:142
static c2_connector_function_p< float_type > & connector_function(const c2_fblock< float_type > &fb0, const c2_fblock< float_type > &fb2, bool auto_center, float_type y1)
make a *new object
Definition: c2_factory.hh:116
static c2_cached_function_p< float_type > & cached_function(const c2_function< float_type > &func)
make a *new object
Definition: c2_factory.hh:84
static c2_quadratic_p< float_type > & quadratic(float_type x0, float_type y0, float_type xcoef, float_type x2coef)
make a *new object
Definition: c2_factory.hh:154
compute sqrt(x) with its derivatives.The factory function c2_factory::sqrt() creates *new c2_sqrt_p()...
static c2_scaled_function_p< float_type > & scaled_function(const c2_function< float_type > &outer, float_type scale)
make a *new object
Definition: c2_factory.hh:80
static c2_cos_p< float_type > & cos()
make a *new object
Definition: c2_factory.hh:134
compute sin(x) with its derivatives.The factory function c2_factory::sin() creates *new c2_sin_p ...
static interpolating_function_p< float_type > & interpolating_function()
make a *new object
Definition: c2_factory.hh:91
create a power law mapping of another functionfor example, given a c2_function f
static c2_sin_p< float_type > & sin()
make a *new object
Definition: c2_factory.hh:132
a c2_function which is constantThe factory function c2_factory::constant() creates *new c2_constant_p...
static c2_exp_p< float_type > & exp()
make a *new object
Definition: c2_factory.hh:140
compute log(x) with its derivatives.The factory function c2_factory::log() creates *new c2_log_p ...
static c2_piecewise_function_p< float_type > & piecewise_function()
make a *new object
Definition: c2_factory.hh:129