-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathexpose_real.hpp
59 lines (39 loc) · 1.41 KB
/
expose_real.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright 2020-2025 Francesco Biscani ([email protected]), Dario Izzo ([email protected])
//
// This file is part of the heyoka.py library.
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef HEYOKA_PY_EXPOSE_REAL_HPP
#define HEYOKA_PY_EXPOSE_REAL_HPP
#include <heyoka/config.hpp>
#include <pybind11/pybind11.h>
#if defined(HEYOKA_HAVE_REAL)
#include <pybind11/numpy.h>
#include <Python.h>
#include <mp++/real.hpp>
#endif
namespace heyoka_py
{
namespace py = pybind11;
#if defined(HEYOKA_HAVE_REAL)
// The Python type that will represent mppp::real.
struct py_real {
PyObject_HEAD alignas(mppp::real) unsigned char m_storage[sizeof(mppp::real)];
};
// The Python type descriptor for py_real.
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
extern PyTypeObject py_real_type;
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
extern int npy_registered_py_real;
bool py_real_check(PyObject *);
mppp::real *get_real_val(PyObject *);
PyObject *pyreal_from_real(const mppp::real &);
PyObject *pyreal_from_real(mppp::real &&);
void pyreal_check_array(const py::array &, mpfr_prec_t = 0);
void pyreal_ensure_array(py::array &, mpfr_prec_t);
#endif
void expose_real(py::module_ &);
} // namespace heyoka_py
#endif