|
|
|||
File indexing completed on 2026-07-13 08:21:05
0001 0002 #ifndef G4HepEmInitUtils_HH 0003 #define G4HepEmInitUtils_HH 0004 0005 // 0006 // Utility methods used during the initialisation. 0007 // 0008 0009 class G4HepEmInitUtils { 0010 public: 0011 G4HepEmInitUtils() = delete; 0012 0013 // Fills the input vector arguments with `npoints` GL integral abscissas and 0014 // weights values (on [0,1] by default) 0015 static void GLIntegral(int npoints, double* abscissas, double* weights, double min=0.0, double max=1.0); 0016 0017 0018 0019 // receives `npoint` x,y data arrays and fills the `secderiv` array with the 0020 // second derivatives that can be used for a spline interpolation 0021 static void PrepareSpline(int npoint, double* xdata, double* ydata, double* secderiv); 0022 0023 // same as above, but both the ydata and second derivatives are stored in the 0024 // ydata array (compact [...,y_i, sd_i, y_{i+1}, sd_{i+1},...] with 2x`npoint`) 0025 static void PrepareSpline(int npoint, double* xdata, double* ydata); 0026 0027 0028 // get spline interpolation over a log-spaced xgrid previously prepared by 0029 // PrepareSpline (separate storrage of ydata and second deriavtive) 0030 // use the improved, robust spline interpolation that I put in G4 10.6 0031 static double GetSplineLog(int ndata, double* xdata, double* ydata, double* secderiv, double x, double logx, double logxmin, double invLDBin); 0032 0033 // get spline interpolation over a log-spaced xgrid previously prepared by 0034 // PrepareSpline (compact storrage of ydata and second deriavtive in ydata) 0035 // use the improved, robust spline interpolation that I put in G4 10.6 0036 static double GetSplineLog(int ndata, double* xdata, double* ydata, double x, double logx, double logxmin, double invLDBin); 0037 0038 // get spline interpolation over a log-spaced xgrid previously prepared by 0039 // PrepareSpline (compact storrage of xdata, ydata and second deriavtive in data) 0040 // use the improved, robust spline interpolation that I put in G4 10.6 0041 static double GetSplineLog(int ndata, double* data, double x, double logx, double logxmin, double invLDBin); 0042 0043 0044 // get spline interpolation over any xgrid: idx = i such xdata[i] <= x < xdata[i+1] 0045 // and x >= xdata[0] and x<xdata[ndata-1] 0046 // PrepareSpline (separate storrage of ydata and second deriavtive) 0047 // use the improved, robust spline interpolation that I put in G4 10.6 0048 static double GetSpline(double* xdata, double* ydata, double* secderiv, double x, int idx, int step=1); 0049 0050 // get spline interpolation if it was prepared with compact storrage of ydata 0051 // and second deriavtive in ydata 0052 // use the improved, robust spline interpolation that I put in G4 10.6 0053 static double GetSpline(double* xdata, double* ydata, double x, int idx); 0054 0055 // get spline interpolation if it was prepared with compact storrage of xdata, 0056 // ydata and second deriavtive in data 0057 static double GetSpline(double* data, double x, int idx); 0058 0059 0060 // finds the lower index of the x-bin in an ordered, increasing x-grid such 0061 // that x[i] <= x < x[i+1] 0062 static int FindLowerBinIndex(double* xdata, int num, double x, int step=1); 0063 0064 /** 0065 * Fills a pre-existing array with doubles uniformly spaced in log(x) 0066 * 0067 * @param[in] emin Inclusive lower bound 0068 * @param[in] emax Inclusive upper bound 0069 * @param[in] npoints Number of points in array, including upper/lower bounds 0070 * @param[out] log_min_value Logarithm of @param emin 0071 * @param[out] inverse_log_delta Inverse of logarithmic spacing between points 0072 * @param[out] grid pointer to array 0073 * 0074 * @pre @param grid must not by `nullptr` and have capacity for at least @param npoints `double`s 0075 * @post The [0,npoints-1] elements of @param grid will contain the data 0076 */ 0077 static void FillLogarithmicGrid(const double emin, const double emax, const int npoints, 0078 double& log_min_value, double& inverse_log_delta, double* grid); 0079 }; 0080 0081 #endif // G4HepEmInitUtils_HH
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|