Skip to content

Commit

Permalink
Cast result of weights() calls to the correct type.
Browse files Browse the repository at this point in the history
  • Loading branch information
jzmaddock committed Feb 1, 2024
1 parent c35f12c commit 87a905a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions include/boost/math/quadrature/gauss.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,7 @@ class gauss : public detail::gauss_detail<Real, N, detail::gauss_constant_catego
unsigned non_zero_start = 1;
K result = Real(0);
if (N & 1) {
result = f(Real(0)) * base::weights()[0];
result = f(Real(0)) * static_cast<Real>(base::weights()[0]);
}
else {
result = 0;
Expand All @@ -1196,8 +1196,8 @@ class gauss : public detail::gauss_detail<Real, N, detail::gauss_constant_catego
{
K fp = f(base::abscissa()[i]);
K fm = f(-base::abscissa()[i]);
result += (fp + fm) * base::weights()[i];
L1 += (abs(fp) + abs(fm)) * base::weights()[i];
result += (fp + fm) * static_cast<Real>(base::weights()[i]);
L1 += (abs(fp) + abs(fm)) * static_cast<Real>(base::weights()[i]);
}
if (pL1)
*pL1 = L1;
Expand Down
16 changes: 8 additions & 8 deletions include/boost/math/quadrature/gauss_kronrod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1787,13 +1787,13 @@ class gauss_kronrod : public detail::gauss_kronrod_detail<Real, N, detail::gauss
if (gauss_order & 1)
{
fp = f(value_type(0));
kronrod_result = fp * base::weights()[0];
gauss_result += fp * gauss<Real, (N - 1) / 2>::weights()[0];
kronrod_result = fp * static_cast<Real>(base::weights()[0]);
gauss_result += fp * static_cast<Real>(gauss<Real, (N - 1) / 2>::weights()[0]);
}
else
{
fp = f(value_type(0));
kronrod_result = fp * base::weights()[0];
kronrod_result = fp * static_cast<Real>(base::weights()[0]);
gauss_start = 1;
kronrod_start = 2;
}
Expand All @@ -1802,16 +1802,16 @@ class gauss_kronrod : public detail::gauss_kronrod_detail<Real, N, detail::gauss
{
fp = f(base::abscissa()[i]);
fm = f(-base::abscissa()[i]);
kronrod_result += (fp + fm) * base::weights()[i];
L1 += (abs(fp) + abs(fm)) * base::weights()[i];
gauss_result += (fp + fm) * gauss<Real, (N - 1) / 2>::weights()[i / 2];
kronrod_result += (fp + fm) * static_cast<Real>(base::weights()[i]);
L1 += (abs(fp) + abs(fm)) * static_cast<Real>(base::weights()[i]);
gauss_result += (fp + fm) * static_cast<Real>(gauss<Real, (N - 1) / 2>::weights()[i / 2]);
}
for (unsigned i = kronrod_start; i < base::abscissa().size(); i += 2)
{
fp = f(base::abscissa()[i]);
fm = f(-base::abscissa()[i]);
kronrod_result += (fp + fm) * base::weights()[i];
L1 += (abs(fp) + abs(fm)) * base::weights()[i];
kronrod_result += (fp + fm) * static_cast<Real>(base::weights()[i]);
L1 += (abs(fp) + abs(fm)) * static_cast<Real>(base::weights()[i]);
}
if (pL1)
*pL1 = L1;
Expand Down

0 comments on commit 87a905a

Please sign in to comment.