Skip to content

Commit 752da06

Browse files
committed
Add Algorithm: almost_equal (almostEqual)
1 parent d07b738 commit 752da06

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

src/Base/Algorithm.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* Copyright 2021-2025 The AMReX Community
2+
*
3+
* Authors: Axel Huebl
4+
* License: BSD-3-Clause-LBNL
5+
*/
6+
#include "pyAMReX.H"
7+
8+
#include <AMReX_Algorithm.H>
9+
10+
#include <type_traits>
11+
12+
13+
void init_Algorithm (py::module& m)
14+
{
15+
using namespace amrex;
16+
17+
m.def(
18+
"almost_equal",
19+
&almostEqual<Real>,
20+
py::arg("x"), py::arg("y"), py::arg("ulp")=2
21+
);
22+
23+
if constexpr (!std::is_same_v<Real, ParticleReal>)
24+
{
25+
m.def(
26+
"almost_equal",
27+
&almostEqual<ParticleReal>,
28+
py::arg("x"), py::arg("y"), py::arg("ulp")=2
29+
);
30+
}
31+
}

src/Base/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
foreach(D IN LISTS AMReX_SPACEDIM)
22
target_sources(pyAMReX_${D}d
33
PRIVATE
4+
Algorithm.cpp
45
AMReX.cpp
56
Arena.cpp
67
Array4.cpp

src/pyAMReX.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313

1414
// forward declarations of exposed classes
15+
void init_Algorithm(py::module&);
1516
void init_AMReX(py::module&);
1617
void init_Arena(py::module&);
1718
void init_Array4(py::module&);
@@ -90,6 +91,7 @@ PYBIND11_MODULE(amrex_3d_pybind, m) {
9091
init_AMReX(m);
9192
init_Arena(m);
9293
init_Dim3(m);
94+
init_Algorithm(m);
9395
init_IntVect(m);
9496
init_IndexType(m);
9597
init_RealVect(m);

0 commit comments

Comments
 (0)