Skip to content

Commit

Permalink
SplineErrourBounds member functions can be declared const (#733)
Browse files Browse the repository at this point in the history
  • Loading branch information
tpadioleau authored Jan 2, 2025
1 parent 6245442 commit f666e23
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
3 changes: 2 additions & 1 deletion tests/splines/batched_2d_spline_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,8 @@ void Batched2dSplineTest()
double const max_norm_diff2 = evaluator.max_norm(0, 1);
double const max_norm_diff12 = evaluator.max_norm(1, 1);

SplineErrorBounds<evaluator_type<DDim<I1, I1, I2>, DDim<I2, I1, I2>>> error_bounds(evaluator);
SplineErrorBounds<evaluator_type<DDim<I1, I1, I2>, DDim<I2, I1, I2>>> const error_bounds(
evaluator);
EXPECT_LE(
max_norm_error,
std::
Expand Down
2 changes: 1 addition & 1 deletion tests/splines/batched_spline_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ void BatchedSplineTest()
double const max_norm_diff = evaluator.max_norm(1);
double const max_norm_int = evaluator.max_norm(-1);

SplineErrorBounds<evaluator_type<DDim<I, I>>> error_bounds(evaluator);
SplineErrorBounds<evaluator_type<DDim<I, I>>> const error_bounds(evaluator);
EXPECT_LE(
max_norm_error,
std::max(error_bounds.error_bound(dx<I>(ncells), s_degree_x), 1.0e-14 * max_norm));
Expand Down
2 changes: 1 addition & 1 deletion tests/splines/non_periodic_spline_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ void TestNonPeriodicSplineBuilderTestIdentity()
EXPECT_LE(max_norm_error_integ / max_norm_int, 1.0e-14);
EXPECT_LE(max_norm_error_quadrature_integ / max_norm_int, 1.0e-14);
} else {
SplineErrorBounds<evaluator_type> error_bounds(evaluator);
SplineErrorBounds<evaluator_type> const error_bounds(evaluator);
const double h = (xN - x0) / ncells;
EXPECT_LE(
max_norm_error,
Expand Down
2 changes: 1 addition & 1 deletion tests/splines/periodic_spline_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void TestPeriodicSplineBuilderTestIdentity()
double const max_norm_diff = evaluator.max_norm(1);
double const max_norm_int = evaluator.max_norm(-1);

SplineErrorBounds<evaluator_type> error_bounds(evaluator);
SplineErrorBounds<evaluator_type> const error_bounds(evaluator);
const double h = (xN - x0) / ncells;
EXPECT_LE(
max_norm_error,
Expand Down
2 changes: 1 addition & 1 deletion tests/splines/periodicity_spline_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void PeriodicitySplineBuilderTest()

double const max_norm = evaluator.max_norm();

SplineErrorBounds<evaluator_type<DDim<X>>> error_bounds(evaluator);
SplineErrorBounds<evaluator_type<DDim<X>>> const error_bounds(evaluator);
EXPECT_LE(
max_norm_error,
std::max(error_bounds.error_bound(dx<X>(ncells), s_degree_x), 1.0e-14 * max_norm));
Expand Down
15 changes: 11 additions & 4 deletions tests/splines/spline_error_bounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,35 @@ class SplineErrorBounds
public:
explicit SplineErrorBounds(Evaluator const& evaluator) : m_evaluator(evaluator) {}

double error_bound(double cell_width, int degree)
double error_bound(double cell_width, int degree) const
{
return tihomirov_error_bound(cell_width, degree, m_evaluator.max_norm(degree + 1));
}
double error_bound(double cell_width1, double cell_width2, int degree1, int degree2)

double error_bound(double cell_width1, double cell_width2, int degree1, int degree2) const
{
double const norm1 = m_evaluator.max_norm(degree1 + 1, 0);
double const norm2 = m_evaluator.max_norm(0, degree2 + 1);
return tihomirov_error_bound(cell_width1, degree1, norm1)
+ tihomirov_error_bound(cell_width2, degree2, norm2);
}
double error_bound_on_deriv(double cell_width, int degree)

double error_bound_on_deriv(double cell_width, int degree) const
{
return tihomirov_error_bound(cell_width, degree - 1, m_evaluator.max_norm(degree + 1));
}

double error_bound_on_deriv_1(double cell_width1, double cell_width2, int degree1, int degree2)
const
{
double const norm1 = m_evaluator.max_norm(degree1 + 1, 0);
double const norm2 = m_evaluator.max_norm(0, degree2 + 1);
return tihomirov_error_bound(cell_width1, degree1 - 1, norm1)
+ tihomirov_error_bound(cell_width2, degree2, norm2);
}

double error_bound_on_deriv_2(double cell_width1, double cell_width2, int degree1, int degree2)
const
{
double const norm1 = m_evaluator.max_norm(degree1 + 1, 0);
double const norm2 = m_evaluator.max_norm(0, degree2 + 1);
Expand All @@ -87,14 +93,15 @@ class SplineErrorBounds
* The error constant may be overestimated.
*******************************************************************************/
double error_bound_on_deriv_12(double cell_width1, double cell_width2, int degree1, int degree2)
const
{
double const norm1 = m_evaluator.max_norm(degree1 + 1, 1);
double const norm2 = m_evaluator.max_norm(1, degree2 + 1);
return tihomirov_error_bound(cell_width1, degree1 - 1, norm1)
+ tihomirov_error_bound(cell_width2, degree2 - 1, norm2);
}

double error_bound_on_int(double cell_width, int degree)
double error_bound_on_int(double cell_width, int degree) const
{
return tihomirov_error_bound(cell_width, degree + 1, m_evaluator.max_norm(degree + 1));
}
Expand Down

0 comments on commit f666e23

Please sign in to comment.