[go: up one dir, main page]

File: machineprecision.cpp

package info (click to toggle)
iminuit 2.30.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,660 kB
  • sloc: cpp: 14,591; python: 11,177; makefile: 11; sh: 5
file content (36 lines) | stat: -rw-r--r-- 919 bytes parent folder | download
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
#include "pybind11.hpp"
#include <Minuit2/MnMachinePrecision.h>

namespace ROOT {
namespace Minuit2 {

bool operator==(const MnMachinePrecision& a, const MnMachinePrecision& b) {
  return a.Eps() == b.Eps() && a.Eps2() == b.Eps2();
}

} // namespace Minuit2
} // namespace ROOT

namespace py = pybind11;
using namespace ROOT::Minuit2;

void bind_machineprecision(py::module m) {
  py::class_<MnMachinePrecision>(m, "MnMachinePrecision")

      .def(py::init<>())

      .def_property("eps", &MnMachinePrecision::Eps, &MnMachinePrecision::SetPrecision)
      .def_property_readonly("eps2", &MnMachinePrecision::Eps2)

      .def(py::self == py::self)

      .def(py::pickle(
          [](const MnMachinePrecision& self) { return py::make_tuple(self.Eps()); },
          [](py::tuple tp) {
            MnMachinePrecision p;
            p.SetPrecision(tp[0].cast<double>());
            return p;
          }))

      ;
}