GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
genie::alvarezruso::integrationtools Namespace Reference

Functions

void SG20R (const double a, const double b, const unsigned int n, const unsigned int nsamp, double *x, unsigned int &np, double *w)
 
std::complex< double > RG201D (const double A, const double B, const unsigned int N, const unsigned int nsamp, const std::complex< double > CF[])
 
void RG202D (const double a, const double b, unsigned int n, unsigned int l, unsigned int m, std::vector< std::vector< std::complex< double > > > &cf, const unsigned int nsamp, std::vector< std::complex< double > > &cres)
 
void SG48R (const double a, const double b, const unsigned int n, const unsigned int nsamp, double *x, unsigned int &np, double *w)
 
std::complex< double > RG481D (const double A, const double B, const unsigned int N, const unsigned int nsamp, const std::complex< double > CF[])
 
void RG482D (const double a, const double b, unsigned int n, unsigned int l, unsigned int m, std::vector< std::vector< std::complex< double > > > &cf, const unsigned int nsamp, std::vector< std::complex< double > > &cres)
 
void SGNR (const double a, const double b, const unsigned int n, const unsigned int nsamp, double *x, unsigned int &np, double *w)
 
std::complex< double > RGN1D (const double A, const double B, const unsigned int N, const unsigned int nsamp, const std::complex< double > CF[])
 
void RGN2D (const double a, const double b, unsigned int n, unsigned int l, unsigned int m, std::vector< std::vector< std::complex< double > > > &cf, const unsigned int nsamp, std::vector< std::complex< double > > &cres)
 

Function Documentation

cdouble genie::alvarezruso::integrationtools::RG201D ( const double  A,
const double  B,
const unsigned int  N,
const unsigned int  nsamp,
const std::complex< double >  CF[] 
)

Definition at line 61 of file IntegrationTools.cxx.

References genie::units::A, and genie::utils::kinematics::W().

Referenced by RGN1D().

62 {
63  // Gaussian-Legendre integration of the function defined by CF
64  const double W[10] = {.0176140071,.0406014298,.0626720483,.0832767415,.1019301198,.1181945319,.1316886384,.1420961093,.1491729864,.1527533871};
65  cdouble CR(0.0, 0.0);
66  int I1 = -nsamp;
67  int I2, J1, J2;
68  for(unsigned int i = 1; i <= N; ++i)
69  {
70  I1 += nsamp;
71  I2 = I1 + nsamp+1;
72  for(unsigned int j = 1; j <= 10; ++j)
73  {
74  J1 = I1 + j;
75  J2 = I2 - j;
76  CR += W[j-1] * (CF[J1-1]+CF[J2-1]);
77  }
78  }
79  //CRES=CR*0.5*(B-A)/float(N)
80  cdouble CRES = CR*0.5*(B-A)/Double_t(N);
81  return CRES;
82 }
double W(const Interaction *const i)
Definition: KineUtils.cxx:1101
static constexpr double A
Definition: Units.h:74
std::complex< double > cdouble
void genie::alvarezruso::integrationtools::RG202D ( const double  a,
const double  b,
unsigned int  n,
unsigned int  l,
unsigned int  m,
std::vector< std::vector< std::complex< double > > > &  cf,
const unsigned int  nsamp,
std::vector< std::complex< double > > &  cres 
)

Definition at line 85 of file IntegrationTools.cxx.

References a, and genie::units::m.

Referenced by RGN2D().

88 {
89  // This is a fast integrator based on a Gauss-Legendre method. This only support two-dimensional integration
90  n = 2; l = 0; m = 3;
91 
92  static const double w[10] = {.0176140071,.0406014298,.0626720483,.0832767415,.1019301198,.1181945319,.1316886384,.1420961093,.1491729864,.1527533871};
93 
94  std::vector<cdouble> cr(4, cdouble(0.0,0.0));
95 
96  int i1 = -nsamp;
97  int i2;
98  int j1;
99  int j2;
100 
101  for(unsigned int i = 0; i != n; ++i)
102  {
103  i1 += nsamp;
104  i2 = i1 + nsamp-1;
105  for(unsigned int j = 0; j != 10; ++j)
106  {
107  j1 = i1 + j;
108  j2 = i2 - j;
109 
110  for(unsigned int ll = l; ll <= m; ++ll)
111  {
112  cr[ll] += w[j] * ( cf[ll][j1] + cf[ll][j2] );
113  }
114  }
115  }
116 
117  for(unsigned int i = 0; i != 4; ++i)
118  {
119  cres[i] = cr[i] * 0.5 * (b-a) / static_cast<double>(n);
120  }
121 }
std::complex< double > cdouble
static constexpr double b
Definition: Units.h:78
const double a
static constexpr double m
Definition: Units.h:71
cdouble genie::alvarezruso::integrationtools::RG481D ( const double  A,
const double  B,
const unsigned int  N,
const unsigned int  nsamp,
const std::complex< double >  CF[] 
)

Definition at line 158 of file IntegrationTools.cxx.

References genie::units::A, and genie::utils::kinematics::W().

Referenced by RGN1D().

159 {
160  // Gaussian-Legendre integration of the function defined by CF
161  static const double W[24] = {0.0031533460, 0.0073275539, 0.0114772345, 0.0155793157, 0.0196161604,
162  0.0235707608, 0.0274265097, 0.0311672278, 0.0347772225, 0.0382413510, 0.0415450829, 0.0446745608,
163  0.0476166584, 0.0503590355, 0.0528901894, 0.0551995036, 0.0572772921, 0.0591148396, 0.0607044391,
164  0.0620394231, 0.0631141922, 0.0639242385, 0.0644661644, 0.0647376968 };
165  cdouble CR(0.0, 0.0);
166  int I1 = -nsamp;
167  int I2, J1, J2;
168  for(unsigned int i = 1; i <= N; ++i)
169  {
170  I1 += nsamp;
171  I2 = I1 + nsamp+1;
172  for(unsigned int j = 1; j <= 24; ++j)
173  {
174  J1 = I1 + j;
175  J2 = I2 - j;
176  CR += W[j-1] * (CF[J1-1]+CF[J2-1]);
177  }
178  }
179  //CRES=CR*0.5*(B-A)/float(N)
180  cdouble CRES = CR*0.5*(B-A)/Double_t(N);
181  return CRES;
182 }
double W(const Interaction *const i)
Definition: KineUtils.cxx:1101
static constexpr double A
Definition: Units.h:74
std::complex< double > cdouble
void genie::alvarezruso::integrationtools::RG482D ( const double  a,
const double  b,
unsigned int  n,
unsigned int  l,
unsigned int  m,
std::vector< std::vector< std::complex< double > > > &  cf,
const unsigned int  nsamp,
std::vector< std::complex< double > > &  cres 
)

Definition at line 185 of file IntegrationTools.cxx.

References a, and genie::units::m.

Referenced by RGN2D().

188 {
189  // This is a fast integrator based on a Gauss-Legendre method. This only support two-dimensional integration
190  n = 2; l = 0; m = 3;
191 
192  static const double w[24] = {0.0031533460, 0.0073275539, 0.0114772345, 0.0155793157, 0.0196161604,
193  0.0235707608, 0.0274265097, 0.0311672278, 0.0347772225, 0.0382413510, 0.0415450829, 0.0446745608,
194  0.0476166584, 0.0503590355, 0.0528901894, 0.0551995036, 0.0572772921, 0.0591148396, 0.0607044391,
195  0.0620394231, 0.0631141922, 0.0639242385, 0.0644661644, 0.0647376968 };
196 
197  std::vector<cdouble> cr(4, cdouble(0.0,0.0));
198 
199  int i1 = -nsamp;
200  int i2;
201  int j1;
202  int j2;
203 
204  for(unsigned int i = 0; i != n; ++i)
205  {
206  i1 += nsamp;
207  i2 = i1 + nsamp-1;
208  for(unsigned int j = 0; j != 24; ++j)
209  {
210  j1 = i1 + j;
211  j2 = i2 - j;
212 
213  for(unsigned int ll = l; ll <= m; ++ll)
214  {
215  cr[ll] += w[j] * ( cf[ll][j1] + cf[ll][j2] );
216  }
217  }
218  }
219 
220  for(unsigned int i = 0; i != 4; ++i)
221  {
222  cres[i] = cr[i] * 0.5 * (b-a) / static_cast<double>(n);
223  }
224 }
std::complex< double > cdouble
static constexpr double b
Definition: Units.h:78
const double a
static constexpr double m
Definition: Units.h:71
cdouble genie::alvarezruso::integrationtools::RGN1D ( const double  A,
const double  B,
const unsigned int  N,
const unsigned int  nsamp,
const std::complex< double >  CF[] 
)

Definition at line 243 of file IntegrationTools.cxx.

References RG201D(), and RG481D().

Referenced by genie::alvarezruso::AREikonalSolution::Element().

244 {
245  if (nsamp==20) {
246  return integrationtools::RG201D(A, B, N, nsamp, CF);
247  }
248  else if (nsamp==48) {
249  return integrationtools::RG481D(A, B, N, nsamp, CF);
250  }
251  else {
252  std::cerr<<"IntegrationTools/RGN1D >> Unsupported nuclear sampling: "<<nsamp<<std::endl;
253  exit(-1);
254  }
255 }
std::complex< double > RG201D(const double A, const double B, const unsigned int N, const unsigned int nsamp, const std::complex< double > CF[])
static constexpr double A
Definition: Units.h:74
std::complex< double > RG481D(const double A, const double B, const unsigned int N, const unsigned int nsamp, const std::complex< double > CF[])
void genie::alvarezruso::integrationtools::RGN2D ( const double  a,
const double  b,
unsigned int  n,
unsigned int  l,
unsigned int  m,
std::vector< std::vector< std::complex< double > > > &  cf,
const unsigned int  nsamp,
std::vector< std::complex< double > > &  cres 
)

Definition at line 257 of file IntegrationTools.cxx.

References RG202D(), and RG482D().

Referenced by genie::alvarezruso::AlvarezRusoCOHPiPDXSec::NuclearCurrent().

260 {
261  if (nsamp==20) {
262  integrationtools::RG202D(a, b, n, l, m, cf, nsamp, cres);
263  }
264  else if (nsamp==48) {
265  integrationtools::RG482D(a, b, n, l, m, cf, nsamp, cres);
266  }
267  else {
268  std::cerr<<"IntegrationTools/RGN2D >> Unsupported nuclear sampling: "<<nsamp<<std::endl;
269  exit(-1);
270  }
271 }
static constexpr double b
Definition: Units.h:78
const double a
void RG202D(const double a, const double b, unsigned int n, unsigned int l, unsigned int m, std::vector< std::vector< std::complex< double > > > &cf, const unsigned int nsamp, std::vector< std::complex< double > > &cres)
void RG482D(const double a, const double b, unsigned int n, unsigned int l, unsigned int m, std::vector< std::vector< std::complex< double > > > &cf, const unsigned int nsamp, std::vector< std::complex< double > > &cres)
static constexpr double m
Definition: Units.h:71
void genie::alvarezruso::integrationtools::SG20R ( const double  a,
const double  b,
const unsigned int  n,
const unsigned int  nsamp,
double *  x,
unsigned int &  np,
double *  w 
)

Definition at line 32 of file IntegrationTools.cxx.

References a.

Referenced by SGNR().

34 {
35  static const double y[10] = {.9931285991, .9639719272, .9122344282, .8391169718, .7463319064, .6360536807, .5108670019, .3737060887, .2277858511, .0765265211 };
36  np = 20 * n;
37  double dint = (b - a) / double(n);
38  double delt = dint * 0.5;
39  double orig = a - delt;
40  int i1 = -nsamp;
41  int i2, j1, j2;
42  double dorig;
43  for(unsigned int i = 1; i <= n; i++)
44  {
45  orig += dint;
46  dorig = orig + orig;
47  i1 += nsamp;
48  i2 = i1 + nsamp+1;
49  for(unsigned int j = 1; j <= 10; j++)
50  {
51  j1 = i1 + j;
52  j2 = i2 - j;
53  x[j1-1] = orig - delt * y[j-1];
54  x[j2-1] = dorig - x[j1-1];
55  }
56  }
57 }
static constexpr double b
Definition: Units.h:78
const double a
void genie::alvarezruso::integrationtools::SG48R ( const double  a,
const double  b,
const unsigned int  n,
const unsigned int  nsamp,
double *  x,
unsigned int &  np,
double *  w 
)

Definition at line 127 of file IntegrationTools.cxx.

References a.

Referenced by SGNR().

129 {
130  static const double y[24] = {0.9987710072, 0.9935301722, 0.9841245873, 0.9705915925, 0.9529877031,
131  0.9313866907, 0.9058791367, 0.8765720202, 0.8435882616, 0.8070662040, 0.7671590325, 0.7240341309,
132  0.6778723796, 0.6288673967, 0.5772247260, 0.5231609747, 0.4669029047, 0.4086864819, 0.3487558862,
133  0.2873624873, 0.2247637903, 0.1612223560, 0.0970046992, 0.0323801709};
134  np = 48 * n;
135  double dint = (b - a) / double(n);
136  double delt = dint * 0.5;
137  double orig = a - delt;
138  int i1 = -nsamp;
139  int i2, j1, j2;
140  double dorig;
141  for(unsigned int i = 1; i <= n; i++)
142  {
143  orig += dint;
144  dorig = orig + orig;
145  i1 += nsamp;
146  i2 = i1 + nsamp+1;
147  for(unsigned int j = 1; j <= 24; j++)
148  {
149  j1 = i1 + j;
150  j2 = i2 - j;
151  x[j1-1] = orig - delt * y[j-1];
152  x[j2-1] = dorig - x[j1-1];
153  }
154  }
155 }
static constexpr double b
Definition: Units.h:78
const double a
void genie::alvarezruso::integrationtools::SGNR ( const double  a,
const double  b,
const unsigned int  n,
const unsigned int  nsamp,
double *  x,
unsigned int &  np,
double *  w 
)

Definition at line 228 of file IntegrationTools.cxx.

References SG20R(), and SG48R().

Referenced by genie::alvarezruso::AREikonalSolution::Element(), and genie::alvarezruso::ARSampledNucleus::FillSamplePoints().

230 {
231  if (nsamp==20) {
232  integrationtools::SG20R(a, b, n, nsamp, x, np, w);
233  }
234  else if (nsamp==48) {
235  integrationtools::SG48R(a, b, n, nsamp, x, np, w);
236  }
237  else {
238  std::cerr<<"IntegrationTools/SGNR >> Unsupported nuclear sampling: "<<nsamp<<std::endl;
239  exit(-1);
240  }
241 }
void SG20R(const double a, const double b, const unsigned int n, const unsigned int nsamp, double *x, unsigned int &np, double *w)
static constexpr double b
Definition: Units.h:78
const double a
void SG48R(const double a, const double b, const unsigned int n, const unsigned int nsamp, double *x, unsigned int &np, double *w)