Thermal-FIST 1.5
Package for hadron resonance gas model applications
Loading...
Searching...
No Matches
NumericalIntegration.cpp
Go to the documentation of this file.
1/*
2 * Thermal-FIST package
3 *
4 * Copyright (c) 2014-2018 Volodymyr Vovchenko
5 *
6 * GNU General Public License (GPLv3 or later)
7 */
9
10namespace thermalfist {
11
12 namespace NumericalIntegration {
13
23 double Integrate2DLaguerre32Legendre32(double(*func)(double, double), double ay, double by)
24 {
25 // Integrate 2D function from 0 to infinity using Gauss-Laguerre integration
26 // with 32 points and from ay to by using Gauss-Legendre integration with 32 points
27 //
28
29 const double *xleg = coefficients_xleg32;
30 const double *wleg = coefficients_wleg32;
31 double x[32];
32 double w[32];
33
34
35 const double *xlag = coefficients_xlag32;
36 const double *wlag = coefficients_wlag32;
37
38 double sum = 0.;
39
40 for (int i = 0; i < 32; i++) {
41 for (int j = 0; j < 32; j++) {
42 x[j] = (by - ay) / 2.*xleg[j] + (by + ay) / 2.;
43 w[j] = (by - ay) / 2.*wleg[j];
44
45 sum += wlag[i] * w[j] * func(xlag[i], x[j]);
46 }
47 }
48 return sum;
49 }
50
51 void GetCoefs2DLaguerre32Legendre32(double ay, double by,
52 std::vector<double> *xlagp, std::vector<double> *wlagp,
53 std::vector<double> *xlegp, std::vector<double> *wlegp) {
54 std::vector<double> &xlag = *xlagp;
55 std::vector<double> &wlag = *wlagp;
56 std::vector<double> &xleg = *xlegp;
57 std::vector<double> &wleg = *wlegp;
58
59 xlag.resize(32);
60 wlag.resize(32);
61 xleg.resize(32);
62 wleg.resize(32);
63
64 const double *xlego = coefficients_xleg32;
65 const double *wlego = coefficients_wleg32;
66 const double *xlago = coefficients_xlag32;
67 const double *wlago = coefficients_wlag32;
68
69 for (int j = 0; j < 32; j++) {
70 xleg[j] = (by - ay) / 2.*xlego[j] + (by + ay) / 2.;
71 wleg[j] = (by - ay) / 2.*wlego[j];
72 xlag[j] = xlago[j];
73 wlag[j] = wlago[j];
74 }
75 }
76
77 void GetCoefs2DLegendre32Legendre32(double ay, double by, double a2y, double b2y,
78 std::vector<double> *xlegp1, std::vector<double> *wlegp1,
79 std::vector<double> *xlegp2, std::vector<double> *wlegp2) {
80 std::vector<double> &xleg1 = *xlegp1;
81 std::vector<double> &wleg1 = *wlegp1;
82 std::vector<double> &xleg2 = *xlegp2;
83 std::vector<double> &wleg2 = *wlegp2;
84
85 xleg1.resize(32);
86 wleg1.resize(32);
87 xleg2.resize(32);
88 wleg2.resize(32);
89
90 const double *xlego = coefficients_xleg32;
91 const double *wlego = coefficients_wleg32;
92
93 for (int j = 0; j < 32; j++) {
94 xleg1[j] = (by - ay) / 2.*xlego[j] + (by + ay) / 2.;
95 wleg1[j] = (by - ay) / 2.*wlego[j];
96 xleg2[j] = (b2y - a2y) / 2.*xlego[j] + (b2y + a2y) / 2.;
97 wleg2[j] = (b2y - a2y) / 2.*wlego[j];
98 }
99 }
100
101 void GetCoefsIntegrateLegendre32(double a, double b, std::vector<double> *xp, std::vector<double> *wp)
102 {
103 // Integrate function from a to b using Legendre-Gaussian integration
104 // with 5 points.
105 //
106 std::vector<double> &x = *xp;
107 std::vector<double> &w = *wp;
108
109 x.resize(32);
110 w.resize(32);
111
112 const double *xlego = coefficients_xleg32;
113 const double *wlego = coefficients_wleg32;
114
115
116 for (int i = 0; i < 32; i++) {
117 w[i] = (b - a) / 2.*wlego[i];
118 x[i] = (b - a) / 2.*xlego[i] + (b + a) / 2.;
119 }
120 }
121
122 void GetCoefsIntegrateLegendre10(double a, double b, std::vector<double> *xp, std::vector<double> *wp)
123 {
124 // Integrate function from a to b using Legendre-Gaussian integration
125 // with 40 points.
126 //
127 std::vector<double> &x = *xp;
128 std::vector<double> &w = *wp;
129
130 x.resize(10);
131 w.resize(10);
132
133 const double *xlego = coefficients_xleg10;
134 const double *wlego = coefficients_wleg10;
135
136 for (int i = 0; i < 10; i++) {
137 w[i] = (b - a) / 2.*wlego[i];
138 x[i] = (b - a) / 2.*xlego[i] + (b + a) / 2.;
139 }
140 }
141
142 void GetCoefsIntegrateLegendre5(double a, double b, std::vector<double> *xp, std::vector<double> *wp)
143 {
144 // Integrate function from a to b using Legendre-Gaussian integration
145 // with 32 points.
146 //
147 std::vector<double> &x = *xp;
148 std::vector<double> &w = *wp;
149
150 x.resize(5);
151 w.resize(5);
152
153 const double *xlego = coefficients_xleg5;
154 const double *wlego = coefficients_wleg5;
155
156 for (int i = 0; i < 5; i++) {
157 w[i] = (b - a) / 2.*wlego[i];
158 x[i] = (b - a) / 2.*xlego[i] + (b + a) / 2.;
159 }
160 }
161
162 void GetCoefsIntegrateLegendre40(double a, double b, std::vector<double> *xp, std::vector<double> *wp)
163 {
164 // Integrate function from a to b using Legendre-Gaussian integration
165 // with 40 points.
166 //
167 std::vector<double> &x = *xp;
168 std::vector<double> &w = *wp;
169
170 x.resize(40);
171 w.resize(40);
172
173
174 const double *xlego = coefficients_xleg40;
175 const double *wlego = coefficients_wleg40;
176
177 for (int i = 0; i < 40; i++) {
178 w[i] = (b - a) / 2.*wlego[i];
179 x[i] = (b - a) / 2.*xlego[i] + (b + a) / 2.;
180 }
181 }
182
183 void GetCoefsIntegrateLaguerre32(std::vector<double> *xp, std::vector<double> *wp)
184 {
185 // Integrate function from 0 to infinity using Gauss-Laguerre integration
186 // with 32 points
187 //
188 std::vector<double> &x = *xp;
189 std::vector<double> &w = *wp;
190
191 x.resize(32);
192 w.resize(32);
193
194 const double *xlago = coefficients_xlag32;
195 const double *wlago = coefficients_wlag32;
196
197 for (int i = 0; i < 32; i++) {
198 w[i] = wlago[i];
199 x[i] = xlago[i];
200 }
201 }
202
203 } // namespace NumericalIntegration
204
205} // namespace thermalfist
Contains various Gauss-Legendre and Gauss-Laguerre quadratures used in numerical integrations.
const double coefficients_xleg10[10]
Nodes of the 10-point Gauss-Legendre quadrature.
void GetCoefs2DLaguerre32Legendre32(double ay, double by, std::vector< double > *xlag, std::vector< double > *wlag, std::vector< double > *xleg, std::vector< double > *wleg)
const double coefficients_wleg40[40]
Weights of the 40-point Gauss-Legendre quadrature.
const double coefficients_xleg32[32]
Nodes of the 32-point Gauss-Legendre quadrature.
const double coefficients_wleg32[32]
Weights of the 32-point Gauss-Legendre quadrature.
void GetCoefsIntegrateLegendre10(double a, double b, std::vector< double > *x, std::vector< double > *w)
const double coefficients_xleg40[40]
Nodes of the 40-point Gauss-Legendre quadrature.
const double coefficients_wlag32[32]
Weights of the 32-point Gauss-Laguerre quadrature.
void GetCoefsIntegrateLegendre32(double a, double b, std::vector< double > *x, std::vector< double > *w)
void GetCoefs2DLegendre32Legendre32(double ax, double bx, double ay, double by, std::vector< double > *xleg1, std::vector< double > *wleg1, std::vector< double > *xleg2, std::vector< double > *wleg2)
void GetCoefsIntegrateLegendre5(double a, double b, std::vector< double > *x, std::vector< double > *w)
const double coefficients_wleg10[10]
Weights of the 10-point Gauss-Legendre quadrature.
void GetCoefsIntegrateLaguerre32(std::vector< double > *x, std::vector< double > *w)
const double coefficients_wleg5[5]
Weights of the 5-point Gauss-Legendre quadrature.
const double coefficients_xleg5[5]
Nodes of the 5-point Gauss-Legendre quadrature.
void GetCoefsIntegrateLegendre40(double a, double b, std::vector< double > *x, std::vector< double > *w)
double Integrate2DLaguerre32Legendre32(double(*func)(double, double), double ay, double by)
const double coefficients_xlag32[32]
Nodes of the 32-point Gauss-Laguerre quadrature.
The main namespace where all classes and functions of the Thermal-FIST library reside.
Definition CosmicEoS.h:9