Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:01

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /**
0027  *  \file electromagnetic/TestEm7/include/c2_factory.hh
0028  *  \brief Provides a factory class to avoid an infinite number of template
0029  *  \brief declarations.
0030  *
0031  *  \author Created by R. A. Weller and Marcus H. Mendenhall on 7/9/05.
0032  *  \author 2005 Vanderbilt University.
0033  *
0034  *         \version c2_factory.hh,v 1.13 2008/05/22 12:45:19 marcus Exp
0035  */
0036 //
0037 
0038 #ifndef __has_c2_factory_hh
0039 #define __has_c2_factory_hh 1
0040 
0041 #include "c2_function.hh"
0042 
0043 /// \brief a factory of pre-templated c2_function generators
0044 ///
0045 /// do \code
0046 /// typedef c2_ptr<double> c2_p;
0047 /// static c2_factory<double> c2;
0048 /// c2_p f=c2.sin();
0049 /// \endcode
0050 /// \note The factory class doesn't contain any data.
0051 /// It can be statically instantiated at the top of a file,
0052 /// and used everywhere inside, or even instantiated in your project's top-level
0053 /// include file.
0054 /// \see c2_math_factory
0055 /// \ingroup factories
0056 template<typename float_type>
0057 class c2_factory
0058 {
0059   public:
0060     /// make a *new object
0061     static c2_classic_function_p<float_type>& classic_function(float_type (*c_func)(float_type))
0062     {
0063       return *new c2_classic_function_p<float_type>(c_func);
0064     }
0065     /// make a *new object
0066     static c2_plugin_function_p<float_type>& plugin_function()
0067     {
0068       return *new c2_plugin_function_p<float_type>();
0069     }
0070     /// make a *new object
0071     static c2_plugin_function_p<float_type>& plugin_function(c2_function<float_type>& f)
0072     {
0073       return *new c2_plugin_function_p<float_type>(f);
0074     }
0075     /// make a *new object
0076     static c2_const_plugin_function_p<float_type>& const_plugin_function()
0077     {
0078       return *new c2_const_plugin_function_p<float_type>();
0079     }
0080     /// make a *new object
0081     static c2_const_plugin_function_p<float_type>&
0082     const_plugin_function(const c2_function<float_type>& f)
0083     {
0084       return *new c2_const_plugin_function_p<float_type>(f);
0085     }
0086     /// make a *new object
0087     static c2_scaled_function_p<float_type>& scaled_function(const c2_function<float_type>& outer,
0088                                                              float_type scale)
0089     {
0090       return *new c2_scaled_function_p<float_type>(outer, scale);
0091     }
0092     /// make a *new object
0093     static c2_cached_function_p<float_type>& cached_function(const c2_function<float_type>& func)
0094     {
0095       return *new c2_cached_function_p<float_type>(func);
0096     }
0097     /// make a *new object
0098     static c2_constant_p<float_type>& constant(float_type x)
0099     {
0100       return *new c2_constant_p<float_type>(x);
0101     }
0102     /// make a *new object
0103     static interpolating_function_p<float_type>& interpolating_function()
0104     {
0105       return *new interpolating_function_p<float_type>();
0106     }
0107     /// make a *new object
0108     static lin_log_interpolating_function_p<float_type>& lin_log_interpolating_function()
0109     {
0110       return *new lin_log_interpolating_function_p<float_type>();
0111     }
0112     /// make a *new object
0113     static log_lin_interpolating_function_p<float_type>& log_lin_interpolating_function()
0114     {
0115       return *new log_lin_interpolating_function_p<float_type>();
0116     }
0117     /// make a *new object
0118     static log_log_interpolating_function_p<float_type>& log_log_interpolating_function()
0119     {
0120       return *new log_log_interpolating_function_p<float_type>();
0121     }
0122     /// make a *new object
0123     static arrhenius_interpolating_function_p<float_type>& arrhenius_interpolating_function()
0124     {
0125       return *new arrhenius_interpolating_function_p<float_type>();
0126     }
0127     /// make a *new object
0128     static c2_connector_function_p<float_type>&
0129     connector_function(float_type x0, const c2_function<float_type>& f0, float_type x2,
0130                        const c2_function<float_type>& f2, bool auto_center, float_type y1)
0131     {
0132       return *new c2_connector_function_p<float_type>(x0, f0, x2, f2, auto_center, y1);
0133     }
0134     /// make a *new object
0135     static c2_connector_function_p<float_type>& connector_function(const c2_fblock<float_type>& fb0,
0136                                                                    const c2_fblock<float_type>& fb2,
0137                                                                    bool auto_center, float_type y1)
0138     {
0139       return *new c2_connector_function_p<float_type>(fb0, fb2, auto_center, y1);
0140     }
0141     /// make a *new object
0142     static c2_connector_function_p<float_type>& connector_function(float_type x0, float_type y0,
0143                                                                    float_type yp0, float_type ypp0,
0144                                                                    float_type x2, float_type y2,
0145                                                                    float_type yp2, float_type ypp2,
0146                                                                    bool auto_center, float_type y1)
0147     {
0148       return *new c2_connector_function_p<float_type>(x0, y0, yp0, ypp0, x2, y2, yp2, ypp2,
0149                                                       auto_center, y1);
0150     }
0151     /// make a *new object
0152     static c2_piecewise_function_p<float_type>& piecewise_function()
0153     {
0154       return *new c2_piecewise_function_p<float_type>();
0155     }
0156     /// make a *new object
0157     static c2_sin_p<float_type>& sin() { return *new c2_sin_p<float_type>(); }
0158     /// make a *new object
0159     static c2_cos_p<float_type>& cos() { return *new c2_cos_p<float_type>(); }
0160     /// make a *new object
0161     static c2_tan_p<float_type>& tan() { return *new c2_tan_p<float_type>(); }
0162     /// make a *new object
0163     static c2_log_p<float_type>& log() { return *new c2_log_p<float_type>(); }
0164     /// make a *new object
0165     static c2_exp_p<float_type>& exp() { return *new c2_exp_p<float_type>(); }
0166     /// make a *new object
0167     static c2_sqrt_p<float_type>& sqrt() { return *new c2_sqrt_p<float_type>(); }
0168     /// make a *new object
0169     static c2_recip_p<float_type>& recip(float_type scale = 1)
0170     {
0171       return *new c2_recip_p<float_type>(scale);
0172     }
0173     /// make a *new object
0174     static c2_identity_p<float_type>& identity() { return *new c2_identity_p<float_type>(); }
0175     /// make a *new object
0176     static c2_linear_p<float_type>& linear(float_type x0, float_type y0, float_type slope)
0177     {
0178       return *new c2_linear_p<float_type>(x0, y0, slope);
0179     }
0180     /// make a *new object
0181     static c2_quadratic_p<float_type>& quadratic(float_type x0, float_type y0, float_type xcoef,
0182                                                  float_type x2coef)
0183     {
0184       return *new c2_quadratic_p<float_type>(x0, y0, xcoef, x2coef);
0185     }
0186     /// make a *new object
0187     static c2_power_law_p<float_type>& power_law(float_type scale, float_type power)
0188     {
0189       return *new c2_power_law_p<float_type>(scale, power);
0190     }
0191     /// make a *new object
0192     static c2_inverse_function_p<float_type>&
0193     inverse_function(const c2_function<float_type>& source)
0194     {
0195       return *new c2_inverse_function_p<float_type>(source);
0196     }
0197 
0198 #if 0
0199 /// \brief handle template for inverse_integrated_density_bins
0200 /// \brief <float_type, Final<float_type> >(bincenters, binheights)
0201 template <template <typename f_t> class Final > 
0202     static interpolating_function_p<float_type> 
0203     & inverse_integrated_density_bins(const std::vector<float_type> &bincenters,
0204                 const std::vector<float_type> &binheights)
0205                 throw(c2_exception) 
0206       {
0207         return ::inverse_integrated_density_bins<float_type, Final<float_type> >
0208                         (bincenters, binheights);
0209       }
0210 /// \brief handle template for inverse_integrated_density_function
0211 /// \brief <float_type, Final<float_type> >(bincenters, binheights)
0212 template <template <typename f_t> class Final > 
0213     static interpolating_function_p<float_type>
0214     & inverse_integrated_density_function(
0215                 const std::vector<float_type> &bincenters,
0216                 const c2_function<float_type> &binheights)
0217                 throw(c2_exception) 
0218       {
0219         return ::inverse_integrated_density_function<float_type,
0220                                                      Final<float_type> >
0221                         (bincenters, binheights);
0222       }
0223 #endif
0224 };
0225 
0226 #endif