File indexing completed on 2025-01-18 09:58:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #define INCLXX_IN_GEANT4_MODE 1
0035
0036 #include "globals.hh"
0037
0038
0039
0040
0041
0042
0043
0044
0045 #ifndef G4INCLHORNERFORMEVALUATOR_HH
0046 #define G4INCLHORNERFORMEVALUATOR_HH
0047
0048 namespace G4INCL {
0049
0050 template<G4int N>
0051 class HornerCoefficients {
0052 protected:
0053 G4double a[N];
0054 public:
0055 G4double &operator[](G4int i) { return a[i]; }
0056 const G4double &operator[](G4int i) const { return a[i]; }
0057 };
0058
0059 struct HornerC1 : public HornerCoefficients<1> {
0060 HornerC1(
0061 const G4double a0
0062 ) {
0063 a[0] = a0;
0064 }
0065 };
0066
0067 struct HornerC2 : public HornerCoefficients<2> {
0068 HornerC2(
0069 const G4double a0,
0070 const G4double a1
0071 ) {
0072 a[0] = a0;
0073 a[1] = a1;
0074 }
0075 };
0076
0077 struct HornerC3 : public HornerCoefficients<3> {
0078 HornerC3(
0079 const G4double a0,
0080 const G4double a1,
0081 const G4double a2
0082 ) {
0083 a[0] = a0;
0084 a[1] = a1;
0085 a[2] = a2;
0086 }
0087 };
0088
0089 struct HornerC4 : public HornerCoefficients<4> {
0090 HornerC4(
0091 const G4double a0,
0092 const G4double a1,
0093 const G4double a2,
0094 const G4double a3
0095 ) {
0096 a[0] = a0;
0097 a[1] = a1;
0098 a[2] = a2;
0099 a[3] = a3;
0100 }
0101 };
0102
0103 struct HornerC5 : public HornerCoefficients<5> {
0104 HornerC5(
0105 const G4double a0,
0106 const G4double a1,
0107 const G4double a2,
0108 const G4double a3,
0109 const G4double a4
0110 ) {
0111 a[0] = a0;
0112 a[1] = a1;
0113 a[2] = a2;
0114 a[3] = a3;
0115 a[4] = a4;
0116 }
0117 };
0118
0119 struct HornerC6 : public HornerCoefficients<6> {
0120 HornerC6(
0121 const G4double a0,
0122 const G4double a1,
0123 const G4double a2,
0124 const G4double a3,
0125 const G4double a4,
0126 const G4double a5
0127 ) {
0128 a[0] = a0;
0129 a[1] = a1;
0130 a[2] = a2;
0131 a[3] = a3;
0132 a[4] = a4;
0133 a[5] = a5;
0134 }
0135 };
0136
0137 struct HornerC7 : public HornerCoefficients<7> {
0138 HornerC7(
0139 const G4double a0,
0140 const G4double a1,
0141 const G4double a2,
0142 const G4double a3,
0143 const G4double a4,
0144 const G4double a5,
0145 const G4double a6
0146 ) {
0147 a[0] = a0;
0148 a[1] = a1;
0149 a[2] = a2;
0150 a[3] = a3;
0151 a[4] = a4;
0152 a[5] = a5;
0153 a[6] = a6;
0154 }
0155 };
0156
0157 struct HornerC8 : public HornerCoefficients<8> {
0158 HornerC8(
0159 const G4double a0,
0160 const G4double a1,
0161 const G4double a2,
0162 const G4double a3,
0163 const G4double a4,
0164 const G4double a5,
0165 const G4double a6,
0166 const G4double a7
0167 ) {
0168 a[0] = a0;
0169 a[1] = a1;
0170 a[2] = a2;
0171 a[3] = a3;
0172 a[4] = a4;
0173 a[5] = a5;
0174 a[6] = a6;
0175 a[7] = a7;
0176 }
0177 };
0178
0179 template<G4int M>
0180 struct HornerEvaluator {
0181 template<G4int N>
0182 static G4double eval(const G4double x, HornerCoefficients<N> const &coeffs) {
0183 return coeffs[N-M] + x * HornerEvaluator<M-1>::eval(x, coeffs);
0184 }
0185 };
0186
0187 template<>
0188 struct HornerEvaluator<1> {
0189 template<G4int N>
0190 static G4double eval(const G4double, HornerCoefficients<N> const &coeffs) {
0191 return coeffs[N-1];
0192 }
0193 };
0194
0195 }
0196
0197 #endif