ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4INCLHornerFormEvaluator.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4INCLHornerFormEvaluator.hh
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 //
26 // INCL++ intra-nuclear cascade model
27 // Alain Boudard, CEA-Saclay, France
28 // Joseph Cugnon, University of Liege, Belgium
29 // Jean-Christophe David, CEA-Saclay, France
30 // Pekka Kaitaniemi, CEA-Saclay, France, and Helsinki Institute of Physics, Finland
31 // Sylvie Leray, CEA-Saclay, France
32 // Davide Mancusi, CEA-Saclay, France
33 //
34 #define INCLXX_IN_GEANT4_MODE 1
35 
36 #include "globals.hh"
37 
45 #ifndef G4INCLHORNERFORMEVALUATOR_HH
46 #define G4INCLHORNERFORMEVALUATOR_HH
47 
48 namespace G4INCL {
49 
50  template<G4int N>
52  protected:
54  public:
55  G4double &operator[](G4int i) { return a[i]; }
56  const G4double &operator[](G4int i) const { return a[i]; }
57  };
58 
59  struct HornerC1 : public HornerCoefficients<1> {
61  const G4double a0
62  ) {
63  a[0] = a0;
64  }
65  };
66 
67  struct HornerC2 : public HornerCoefficients<2> {
69  const G4double a0,
70  const G4double a1
71  ) {
72  a[0] = a0;
73  a[1] = a1;
74  }
75  };
76 
77  struct HornerC3 : public HornerCoefficients<3> {
79  const G4double a0,
80  const G4double a1,
81  const G4double a2
82  ) {
83  a[0] = a0;
84  a[1] = a1;
85  a[2] = a2;
86  }
87  };
88 
89  struct HornerC4 : public HornerCoefficients<4> {
91  const G4double a0,
92  const G4double a1,
93  const G4double a2,
94  const G4double a3
95  ) {
96  a[0] = a0;
97  a[1] = a1;
98  a[2] = a2;
99  a[3] = a3;
100  }
101  };
102 
103  struct HornerC5 : public HornerCoefficients<5> {
105  const G4double a0,
106  const G4double a1,
107  const G4double a2,
108  const G4double a3,
109  const G4double a4
110  ) {
111  a[0] = a0;
112  a[1] = a1;
113  a[2] = a2;
114  a[3] = a3;
115  a[4] = a4;
116  }
117  };
118 
119  struct HornerC6 : public HornerCoefficients<6> {
121  const G4double a0,
122  const G4double a1,
123  const G4double a2,
124  const G4double a3,
125  const G4double a4,
126  const G4double a5
127  ) {
128  a[0] = a0;
129  a[1] = a1;
130  a[2] = a2;
131  a[3] = a3;
132  a[4] = a4;
133  a[5] = a5;
134  }
135  };
136 
137  struct HornerC7 : public HornerCoefficients<7> {
139  const G4double a0,
140  const G4double a1,
141  const G4double a2,
142  const G4double a3,
143  const G4double a4,
144  const G4double a5,
145  const G4double a6
146  ) {
147  a[0] = a0;
148  a[1] = a1;
149  a[2] = a2;
150  a[3] = a3;
151  a[4] = a4;
152  a[5] = a5;
153  a[6] = a6;
154  }
155  };
156 
157  struct HornerC8 : public HornerCoefficients<8> {
159  const G4double a0,
160  const G4double a1,
161  const G4double a2,
162  const G4double a3,
163  const G4double a4,
164  const G4double a5,
165  const G4double a6,
166  const G4double a7
167  ) {
168  a[0] = a0;
169  a[1] = a1;
170  a[2] = a2;
171  a[3] = a3;
172  a[4] = a4;
173  a[5] = a5;
174  a[6] = a6;
175  a[7] = a7;
176  }
177  };
178 
179  template<G4int M>
181  template<G4int N>
182  static G4double eval(const G4double x, HornerCoefficients<N> const &coeffs) {
183  return coeffs[N-M] + x * HornerEvaluator<M-1>::eval(x, coeffs);
184  }
185  };
186 
187  template<>
188  struct HornerEvaluator<1> {
189  template<G4int N>
190  static G4double eval(const G4double, HornerCoefficients<N> const &coeffs) {
191  return coeffs[N-1];
192  }
193  };
194 
195 }
196 
197 #endif