Skip to content

Commit

Permalink
On continue sur Gauss Legendre mais la sante dabord
Browse files Browse the repository at this point in the history
  • Loading branch information
Goul-tard committed Dec 23, 2024
1 parent d2e5234 commit 5ca3526
Show file tree
Hide file tree
Showing 3 changed files with 277 additions and 65 deletions.
83 changes: 34 additions & 49 deletions src/demeter/quadrature/gauss_legendre.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,6 @@

namespace Demeter {

//// nteta = 2
//template <>
//Eigen::ArrayXd GaussLegendre<2>::weights_(1);
//template <>
//Eigen::ArrayXd GaussLegendre<2>::costeta_(1);
//template <>
//Eigen::ArrayXd GaussLegendre<2>::teta_(1);
//template <>
//void GaussLegendre<2>::initialization() {
// weights_ << 2.00000;
// costeta_ << 0.57735;
// teta_ << 0.00000;
//}
//
//// nteta = 4
//template <>
//Eigen::ArrayXd GaussLegendre<4>::weights_(2);
//template <>
//Eigen::ArrayXd GaussLegendre<4>::costeta_(2);
//template <>
//Eigen::ArrayXd GaussLegendre<4>::teta_(1);
//template <>
//void GaussLegendre<2>::initialization() {
// weights_ << 0.652145, 0.347855;
// costeta_ << 0.339981, 0.861136;
// teta_ << 0.000000, 0.000000;
//}

// nteta = 2
template <>
Eigen::ArrayXd GaussLegendre<2>::weights_(1);
Expand All @@ -51,8 +23,8 @@ template <>
Eigen::ArrayXd GaussLegendre<2>::teta_(1);
template <>
void GaussLegendre<2>::initialization() {
weights_ << 0.00000;
costeta_ << 0.00000;
weights_ << 1.0000000;
costeta_ << 0.57735027;
teta_ << 0.00000;
}
// nteta = 4
Expand All @@ -64,8 +36,8 @@ template <>
Eigen::ArrayXd GaussLegendre<4>::teta_(2);
template <>
void GaussLegendre<4>::initialization() {
weights_ << 0.00000;
costeta_ << 0.00000;
weights_ << 0.65214515, 0.34785485;
costeta_ << 0.33998104, 0.86113631;
teta_ << 0.00000;
}
// nteta = 6
Expand All @@ -77,8 +49,8 @@ template <>
Eigen::ArrayXd GaussLegendre<6>::teta_(3);
template <>
void GaussLegendre<6>::initialization() {
weights_ << 0.00000;
costeta_ << 0.00000;
weights_ << 0.46791393, 0.36076157, 0.17132449;
costeta_ << 0.23861919, 0.66120939, 0.93246951;
teta_ << 0.00000;
}
// nteta = 8
Expand All @@ -90,8 +62,8 @@ template <>
Eigen::ArrayXd GaussLegendre<8>::teta_(4);
template <>
void GaussLegendre<8>::initialization() {
weights_ << 0.00000;
costeta_ << 0.00000;
weights_ << 0.36268378, 0.31370665, 0.22238103, 0.10122854;
costeta_ << 0.18343464, 0.52553241, 0.79666648, 0.96028986;
teta_ << 0.00000;
}
// nteta = 10
Expand All @@ -103,8 +75,8 @@ template <>
Eigen::ArrayXd GaussLegendre<10>::teta_(5);
template <>
void GaussLegendre<10>::initialization() {
weights_ << 0.00000;
costeta_ << 0.00000;
weights_ << 0.29552422, 0.26926672, 0.21908636, 0.14945135, 0.06667134;
costeta_ << 0.14887434, 0.43339539, 0.67940957, 0.86506337, 0.97390653;
teta_ << 0.00000;
}
// nteta = 12
Expand All @@ -116,8 +88,10 @@ template <>
Eigen::ArrayXd GaussLegendre<12>::teta_(6);
template <>
void GaussLegendre<12>::initialization() {
weights_ << 0.00000;
costeta_ << 0.00000;
weights_ << 0.24914705, 0.23349254, 0.20316743, 0.16007833, 0.10693933,
0.04717534;
costeta_ << 0.12523341, 0.3678315, 0.58731795, 0.76990267, 0.90411726,
0.98156063;
teta_ << 0.00000;
}
// nteta = 14
Expand All @@ -129,8 +103,10 @@ template <>
Eigen::ArrayXd GaussLegendre<14>::teta_(7);
template <>
void GaussLegendre<14>::initialization() {
weights_ << 0.00000;
costeta_ << 0.00000;
weights_ << 0.21526385, 0.20519846, 0.1855384, 0.15720317, 0.12151857,
0.08015809, 0.03511946;
costeta_ << 0.10805495, 0.31911237, 0.51524864, 0.6872929, 0.82720132,
0.92843488, 0.98628381;
teta_ << 0.00000;
}
// nteta = 16
Expand All @@ -142,8 +118,10 @@ template <>
Eigen::ArrayXd GaussLegendre<16>::teta_(8);
template <>
void GaussLegendre<16>::initialization() {
weights_ << 0.00000;
costeta_ << 0.00000;
weights_ << 0.18945061, 0.18260342, 0.16915652, 0.14959599, 0.12462897,
0.09515851, 0.06225352, 0.02715246;
costeta_ << 0.09501251, 0.28160355, 0.45801678, 0.61787624, 0.75540441,
0.8656312, 0.94457502, 0.98940093;
teta_ << 0.00000;
}
// nteta = 18
Expand All @@ -155,7 +133,8 @@ template <>
Eigen::ArrayXd GaussLegendre<18>::teta_(9);
template <>
void GaussLegendre<18>::initialization() {
weights_ << 0.00000;
weights_ << 0.16914238, 0.16427648, 0.15468468, 0.14064291, 0.12255521,
0.10094204, 0.07642573, 0.04971455, 0.02161601;
costeta_ << 0.00000;
teta_ << 0.00000;
}
Expand All @@ -168,8 +147,10 @@ template <>
Eigen::ArrayXd GaussLegendre<20>::teta_(10);
template <>
void GaussLegendre<20>::initialization() {
weights_ << 0.00000;
costeta_ << 0.00000;
weights_ << 0.15275339, 0.14917299, 0.14209611, 0.13168864, 0.11819453,
0.10193012, 0.08327674, 0.06267205, 0.04060143, 0.01761401;
costeta_ << 0.07652652, 0.22778585, 0.37370609, 0.510867, 0.63605368,
0.74633191, 0.83911697, 0.91223443, 0.96397193, 0.9931286;
teta_ << 0.00000;
}
// nteta = 22
Expand All @@ -181,8 +162,12 @@ template <>
Eigen::ArrayXd GaussLegendre<22>::teta_(11);
template <>
void GaussLegendre<22>::initialization() {
weights_ << 0.00000;
costeta_ << 0.00000;
weights_ << 0.13925187, 0.1365415 , 0.1311735 , 0.12325238, 0.1129323,
0.10041414, 0.08594161, 0.06979647, 0.05229334, 0.0337749,
0.014628;
costeta_ << 0.06973927, 0.20786043, 0.34193582, 0.46935584, 0.5876404,
0.69448726, 0.78781681, 0.86581258, 0.92695677, 0.9700605,
0.99429459;
teta_ << 0.00000;
}
// nteta = 24
Expand Down
43 changes: 27 additions & 16 deletions utils/gauss_legendre_weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,31 @@
a = 0
for i in range(24):
a +=2
print("// nteta = " + str(a))
print("template <>")
print("Eigen::ArrayXd GaussLegendre<"+str(a)+">::weights_("+str(round(a/2))+");")
print("template <>")
print("Eigen::ArrayXd GaussLegendre<"+str(a)+">::costeta_("+str(round(a/2))+");")
print("template <>")
print("Eigen::ArrayXd GaussLegendre<"+str(a)+">::teta_("+str(round(a/2))+");")
print("template <>")
print("void GaussLegendre<"+str(a)+">::initialization() {")
print(" weights_ << 0.00000;")
print(" costeta_ << 0.00000;")
print(" teta_ << 0.00000;")
print("}")
#roots, weights = roots_legendre(2)
#print(roots)
#roots, weights = roots_legendre(4)

# / ** Printing strings ** /
#print("// nteta = " + str(a))
#print("template <>")
#print("Eigen::ArrayXd GaussLegendre<"+str(a)+">::weights_("+str(round(a/2))+");")
#print("template <>")
#print("Eigen::ArrayXd GaussLegendre<"+str(a)+">::costeta_("+str(round(a/2))+");")
#print("template <>")
#print("Eigen::ArrayXd GaussLegendre<"+str(a)+">::teta_("+str(round(a/2))+");")
#print("template <>")
#print("void GaussLegendre<"+str(a)+">::initialization() {")
#print(" weights_ << 0.00000;")
#print(" costeta_ << 0.00000;")
#print(" teta_ << 0.00000;")
#print("}")

# / ** Printing data ** /
roots, weights = roots_legendre(a)
print("Half")
print("Weights")
print(weights[round(a/2):])
print("Roots")
print(roots[round(a/2):])
print(" ")

#print("Total")
#print(weights)
#print(roots)
Loading

0 comments on commit 5ca3526

Please sign in to comment.