From ca0b66fae9324364a06616bba7bb28d2da39f994 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 7 Jul 2021 17:14:52 -0600 Subject: [PATCH] Use std::numeric_limits::lowest() instead of -max(). --- include/deal.II/lac/eigen.h | 2 +- include/deal.II/lac/solver_gmres.h | 4 ++-- include/deal.II/lac/solver_richardson.h | 4 ++-- include/deal.II/numerics/error_estimator.templates.h | 8 ++++---- source/base/mpi.cc | 2 +- source/base/patterns.cc | 2 +- source/grid/grid_refinement.cc | 2 +- tests/arpack/step-36_ar.cc | 2 +- tests/arpack/step-36_ar_shift.cc | 2 +- tests/arpack/step-36_ar_with_iterations.cc | 2 +- tests/simplex/step-31.cc | 4 ++-- 11 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/deal.II/lac/eigen.h b/include/deal.II/lac/eigen.h index a02949b757..91ee6b5fa1 100644 --- a/include/deal.II/lac/eigen.h +++ b/include/deal.II/lac/eigen.h @@ -321,7 +321,7 @@ EigenInverse::solve(double & value, x *= 1. / length; // Main loop - double res = -std::numeric_limits::max(); + double res = std::numeric_limits::lowest(); size_type iter = 0; for (; conv == SolverControl::iterate; iter++) { diff --git a/include/deal.II/lac/solver_gmres.h b/include/deal.II/lac/solver_gmres.h index 7e359925ab..ff6113d56c 100644 --- a/include/deal.II/lac/solver_gmres.h +++ b/include/deal.II/lac/solver_gmres.h @@ -825,7 +825,7 @@ SolverGMRES::solve(const MatrixType & A, unsigned int dim = 0; SolverControl::State iteration_state = SolverControl::iterate; - double last_res = -std::numeric_limits::max(); + double last_res = std::numeric_limits::lowest(); // switch to determine whether we want a left or a right preconditioner. at // present, left is default, but both ways are implemented @@ -1216,7 +1216,7 @@ SolverFGMRES::solve(const MatrixType & A, Vector y; // Iteration starts here - double res = -std::numeric_limits::max(); + double res = std::numeric_limits::lowest(); typename VectorMemory::Pointer aux(this->memory); aux->reinit(x); diff --git a/include/deal.II/lac/solver_richardson.h b/include/deal.II/lac/solver_richardson.h index 70d8d5c6d4..d8b68d9f83 100644 --- a/include/deal.II/lac/solver_richardson.h +++ b/include/deal.II/lac/solver_richardson.h @@ -197,7 +197,7 @@ SolverRichardson::solve(const MatrixType & A, { SolverControl::State conv = SolverControl::iterate; - double last_criterion = -std::numeric_limits::max(); + double last_criterion = std::numeric_limits::lowest(); unsigned int iter = 0; @@ -253,7 +253,7 @@ SolverRichardson::Tsolve(const MatrixType & A, const PreconditionerType &preconditioner) { SolverControl::State conv = SolverControl::iterate; - double last_criterion = -std::numeric_limits::max(); + double last_criterion = std::numeric_limits::lowest(); unsigned int iter = 0; diff --git a/include/deal.II/numerics/error_estimator.templates.h b/include/deal.II/numerics/error_estimator.templates.h index 10b0f65550..d320669e4b 100644 --- a/include/deal.II/numerics/error_estimator.templates.h +++ b/include/deal.II/numerics/error_estimator.templates.h @@ -514,7 +514,7 @@ namespace internal default: { Assert(false, ExcNotImplemented()); - return -std::numeric_limits::max(); + return std::numeric_limits::lowest(); } } } @@ -558,7 +558,7 @@ namespace internal default: { Assert(false, ExcNotImplemented()); - return -std::numeric_limits::max(); + return std::numeric_limits::lowest(); } } } @@ -604,7 +604,7 @@ namespace internal default: { Assert(false, ExcNotImplemented()); - return -std::numeric_limits::max(); + return std::numeric_limits::lowest(); } } } @@ -639,7 +639,7 @@ namespace internal default: { Assert(false, ExcNotImplemented()); - return -std::numeric_limits::max(); + return std::numeric_limits::lowest(); } } } diff --git a/source/base/mpi.cc b/source/base/mpi.cc index 4fda149c7e..8e4fa7d917 100644 --- a/source/base/mpi.cc +++ b/source/base/mpi.cc @@ -576,7 +576,7 @@ namespace Utilities // result with a default value already... MinMaxAvg dummy = {0., std::numeric_limits::max(), - -std::numeric_limits::max(), + std::numeric_limits::lowest(), 0, 0, 0.}; diff --git a/source/base/patterns.cc b/source/base/patterns.cc index 765506a585..eaf7063c2e 100644 --- a/source/base/patterns.cc +++ b/source/base/patterns.cc @@ -344,7 +344,7 @@ namespace Patterns - const double Double::min_double_value = -std::numeric_limits::max(); + const double Double::min_double_value = std::numeric_limits::lowest(); const double Double::max_double_value = std::numeric_limits::max(); const char *Double::description_init = "[Double"; diff --git a/source/grid/grid_refinement.cc b/source/grid/grid_refinement.cc index fe0a1c3e0a..d230b938a6 100644 --- a/source/grid/grid_refinement.cc +++ b/source/grid/grid_refinement.cc @@ -354,7 +354,7 @@ GridRefinement::refine_and_coarsen_fixed_number( if (refine_cells) { if (static_cast(refine_cells) == criteria.size()) - refine(tria, criteria, -std::numeric_limits::max()); + refine(tria, criteria, std::numeric_limits::lowest()); else { std::nth_element(tmp.begin(), diff --git a/tests/arpack/step-36_ar.cc b/tests/arpack/step-36_ar.cc index 48752d8dbf..67e6ddae5e 100644 --- a/tests/arpack/step-36_ar.cc +++ b/tests/arpack/step-36_ar.cc @@ -198,7 +198,7 @@ namespace Step36 double min_spurious_eigenvalue = std::numeric_limits::max(), - max_spurious_eigenvalue = -std::numeric_limits::max(); + max_spurious_eigenvalue = std::numeric_limits::lowest(); for (unsigned int i = 0; i < dof_handler.n_dofs(); ++i) if (constraints.is_constrained(i)) diff --git a/tests/arpack/step-36_ar_shift.cc b/tests/arpack/step-36_ar_shift.cc index d40dba1c86..a670d43e80 100644 --- a/tests/arpack/step-36_ar_shift.cc +++ b/tests/arpack/step-36_ar_shift.cc @@ -192,7 +192,7 @@ namespace Step36 double min_spurious_eigenvalue = std::numeric_limits::max(), - max_spurious_eigenvalue = -std::numeric_limits::max(); + max_spurious_eigenvalue = std::numeric_limits::lowest(); for (unsigned int i = 0; i < dof_handler.n_dofs(); ++i) if (constraints.is_constrained(i)) diff --git a/tests/arpack/step-36_ar_with_iterations.cc b/tests/arpack/step-36_ar_with_iterations.cc index 48752d8dbf..67e6ddae5e 100644 --- a/tests/arpack/step-36_ar_with_iterations.cc +++ b/tests/arpack/step-36_ar_with_iterations.cc @@ -198,7 +198,7 @@ namespace Step36 double min_spurious_eigenvalue = std::numeric_limits::max(), - max_spurious_eigenvalue = -std::numeric_limits::max(); + max_spurious_eigenvalue = std::numeric_limits::lowest(); for (unsigned int i = 0; i < dof_handler.n_dofs(); ++i) if (constraints.is_constrained(i)) diff --git a/tests/simplex/step-31.cc b/tests/simplex/step-31.cc index 5fa28f8ad1..116bf5adda 100644 --- a/tests/simplex/step-31.cc +++ b/tests/simplex/step-31.cc @@ -359,7 +359,7 @@ namespace Step31 if (timestep_number != 0) { double min_temperature = std::numeric_limits::max(), - max_temperature = -std::numeric_limits::max(); + max_temperature = std::numeric_limits::lowest(); for (const auto &cell : temperature_dof_handler.active_cell_iterators()) { fe_values.reinit(cell); @@ -381,7 +381,7 @@ namespace Step31 else { double min_temperature = std::numeric_limits::max(), - max_temperature = -std::numeric_limits::max(); + max_temperature = std::numeric_limits::lowest(); for (const auto &cell : temperature_dof_handler.active_cell_iterators()) { fe_values.reinit(cell); -- 2.39.5