Skip to content

Commit 99ffa7f

Browse files
authored
Merge pull request #576 from lanl/jmm/its-called-cmath
[Trivial] move away from older style headers
2 parents 431d98f + b78a2d5 commit 99ffa7f

File tree

8 files changed

+18
-17
lines changed

8 files changed

+18
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- [[PR575]](https://github.com/lanl/singularity-eos/pull/575) Pin variant submodule to the same commit as the spackage
1818

1919
### Infrastructure (changes irrelevant to downstream codes)
20+
- [[PR576]](https://github.com/lanl/singularity-eos/pull/576) Clean up some header includes to use the C++ versions
2021
- [[PR559]](https://github.com/lanl/singularity-eos/pull/559) Document the intent of the virtual keyword in solvers
2122
- [[PR558]](https://github.com/lanl/singularity-eos/pull/558) Make EOSPAC CMake options depend on SINGULARITY_USE_EOSPAC option
2223
- [[PR573]](https://github.com/lanl/singularity-eos/pull/573) Add CMake option for address sanitizing

singularity-eos/base/root-finding-1d/root_finding.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424

2525
// #include <iostream> // debug
2626
// #include <iomanip>
27-
#include <assert.h>
28-
#include <math.h>
27+
#include <cmath>
28+
#include <cstdio>
2929
#include <ports-of-call/portability.hpp>
30-
#include <stdio.h>
30+
#include <ports-of-call/portable_errors.hpp>
3131
#include <tuple>
3232

3333
#define SINGULARITY_ROOT_DEBUG (0)
@@ -84,7 +84,7 @@ class RootCounts {
8484
counts_[i] = 0;
8585
}
8686
PORTABLE_INLINE_FUNCTION void increment(std::size_t i) const {
87-
assert(i < nbins_ && i >= 0);
87+
PORTABLE_REQUIRE(i < nbins_ && i >= 0, "Index in bounds");
8888
#ifdef PORTABILITY_STRATEGY_NONE
8989
counts_[i] += 1;
9090
#endif // PORTABILITY_STRATEGY_NONE
@@ -96,11 +96,11 @@ class RootCounts {
9696
return tot;
9797
}
9898
PORTABLE_INLINE_FUNCTION const Real &operator[](const std::size_t i) const {
99-
assert(i < nbins_ && i >= 0);
99+
PORTABLE_REQUIRE(i < nbins_ && i >= 0, "Index in bounds");
100100
return counts_[i];
101101
}
102102
PORTABLE_INLINE_FUNCTION Real &operator[](const std::size_t i) {
103-
assert(i < nbins_ && i >= 0);
103+
PORTABLE_REQUIRE(i < nbins_ && i >= 0, "Index in bounds");
104104
return counts_[i];
105105
}
106106
PORTABLE_INLINE_FUNCTION void print_counts() const {
@@ -362,7 +362,7 @@ PORTABLE_INLINE_FUNCTION Status findRoot(const T &f, const Real ytarget, Real xg
362362
status = bisect(f, ytarget, xguess, xmin, xmax, xtol, ytol, xroot, counts);
363363

364364
// Check for something horrible happening
365-
if (isnan(xroot) || isinf(xroot)) {
365+
if (std::isnan(xroot) || std::isinf(xroot)) {
366366
#if SINGULARITY_ROOT_DEBUG
367367
fprintf(stderr, "xroot is nan after bisection\n");
368368
#endif
@@ -396,7 +396,7 @@ PORTABLE_INLINE_FUNCTION Status secant(const T &f, const Real ytarget, const Rea
396396
x -= y / dy;
397397
if (x < xmin) x = xmin;
398398
if (x > xmax) x = xmax;
399-
if (isnan(x) || isinf(x)) {
399+
if (std::isnan(x) || std::isinf(x)) {
400400
// can't recover from this
401401
#if SINGULARITY_ROOT_DEBUG
402402
fprintf(stderr,
@@ -472,8 +472,8 @@ PORTABLE_INLINE_FUNCTION Status secant(const T &f, const Real ytarget, const Rea
472472
}
473473
#endif
474474

475-
const int secant_failed =
476-
(fabs(x - x_last) > xtol || fabs(frac_error) > ytol || isnan(x) || isinf(x));
475+
const int secant_failed = (std::abs(x - x_last) > xtol || std::abs(frac_error) > ytol ||
476+
std::isnan(x) || std::isinf(x));
477477
return secant_failed ? Status::FAIL : Status::SUCCESS;
478478
}
479479

@@ -577,7 +577,7 @@ PORTABLE_INLINE_FUNCTION Status bisect(const T &f, const Real ytarget, const Rea
577577

578578
xroot = 0.5 * (xl + xr);
579579

580-
if (isnan(xroot)) {
580+
if (std::isnan(xroot)) {
581581
#if SINGULARITY_ROOT_DEBUG
582582
Real il = f(xl);
583583
Real ir = f(xr);

singularity-eos/eos/modifiers/eos_unitsystem.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
#ifndef _SINGULARITY_EOS_EOS_EOS_UNITSYSTEM_HPP_
1616
#define _SINGULARITY_EOS_EOS_EOS_UNITSYSTEM_HPP_
1717

18-
#include "stdio.h"
1918
#include <cassert>
2019
#include <cmath>
20+
#include <cstdio>
2121
#include <cstdlib>
2222
#include <iostream>
2323
#include <limits>

singularity-eos/eos/modifiers/floored_energy.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#ifndef _SINGULARITY_EOS_EOS_FLOORED_ENERGY_
1616
#define _SINGULARITY_EOS_EOS_FLOORED_ENERGY_
1717

18-
#include "stdio.h"
18+
#include <cstdio>
1919
#include <cstdlib>
2020
#include <iostream>
2121

singularity-eos/eos/modifiers/ramps_eos.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
#ifndef _SINGULARITY_EOS_EOS_RAMPS_EOS_
1616
#define _SINGULARITY_EOS_EOS_RAMPS_EOS_
1717

18-
#include "stdio.h"
1918
#include <cassert>
2019
#include <cmath>
20+
#include <cstdio>
2121
#include <cstdlib>
2222
#include <iostream>
2323
#include <limits>

singularity-eos/eos/modifiers/relativistic_eos.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
#ifndef _SINGULARITY_EOS_EOS_RELATIVISTIC_EOS_
1616
#define _SINGULARITY_EOS_EOS_RELATIVISTIC_EOS_
1717

18-
#include "stdio.h"
1918
#include <cassert>
2019
#include <cmath>
20+
#include <cstdio>
2121
#include <cstdlib>
2222
#include <iostream>
2323
#include <limits>

singularity-eos/eos/modifiers/scaled_eos.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
#ifndef _SINGULARITY_EOS_EOS_SCALED_EOS_
1616
#define _SINGULARITY_EOS_EOS_SCALED_EOS_
1717

18-
#include "stdio.h"
1918
#include <cassert>
2019
#include <cmath>
20+
#include <cstdio>
2121
#include <cstdlib>
2222
#include <iostream>
2323
#include <limits>

singularity-eos/eos/modifiers/shifted_eos.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
#ifndef _SINGULARITY_EOS_EOS_SHIFTED_EOS_
1616
#define _SINGULARITY_EOS_EOS_SHIFTED_EOS_
1717

18-
#include "stdio.h"
1918
#include <cassert>
2019
#include <cmath>
20+
#include <cstdio>
2121
#include <cstdlib>
2222
#include <iostream>
2323
#include <limits>

0 commit comments

Comments
 (0)