28 #ifndef TOMOPY_COMMON_H 29 #define TOMOPY_COMMON_H 34 #include <pybind11/pybind11.h> 36 namespace py = pybind11;
40 # ifdef _tomographer_cxx_EXPORTS 41 # define TOMOGRAPHER_EXPORT __declspec(dllexport) 43 # define TOMOGRAPHER_EXPORT __declspec(dllimport) 46 # define TOMOGRAPHER_EXPORT __attribute__((visibility("default"))) 51 #ifndef TOMOGRAPHERPY_DEBUG_EIGEN_ASSERT_CAUSES_ABORT 52 # define TOMOGRAPHER_EIGEN_ASSERT_EXCEPTION 57 #pragma GCC visibility push(default) 58 #include <pybind11/eigen.h> 61 # error "TomographerPy requires enabled Eigen assertions, otherwise `TomographerCxxError` won't be raised as documented." 65 #pragma GCC visibility pop 67 #include <tomographer/tomographer_version.h> 71 #include <tomographerpy/pylogger.h> 152 auto tomographer_module = py::module::import(
"tomographer");
153 if (PyErr_Occurred() != NULL) {
154 throw py::error_already_set();
157 tomographer_module.attr(
"__version__").cast<
std::string>();
158 if (module_tomographer_version != TOMOGRAPHER_VERSION) {
160 "Error: Version of compiled tomographer python module ("+module_tomographer_version +
161 ") does not match version used to compile the current module (" +
std::string(TOMOGRAPHER_VERSION)
162 +
"). If you updated tomographer, please recompile all dependent modules." 169 const std::string module_tomographer_pybind11_ver =
170 tomographer_module.attr(
"version").attr(
"compile_info").attr(
"get")(
"pybind11",
"").cast<std::string>();
171 if (module_tomographer_pybind11_ver != this_pybind11_ver) {
173 "Error: Compiled tomographer's version of PyBind11 (" + module_tomographer_pybind11_ver +
174 ") does not match version used to compile the current module (" + this_pybind11_ver
175 +
"). Please recompile all modules using the same PyBind11 version." 178 return tomographer_module;
Eigen::Matrix< RealScalar, Eigen::Dynamic, Eigen::Dynamic > RealMatrixType
Shorthand, a 2-D Eigen::Matrix of RealScalar's.
Eigen::Matrix< ComplexScalar, Eigen::Dynamic, Eigen::Dynamic > CplxMatrixType
Shorthand, a 2-D Eigen::Matrix of ComplexScalar's.
int CountIntType
Integer type for template arguments (`long' in case of long random walks) – deprecated.
double RealType
Floating-point type for template arguments – deprecated.
std::complex< RealScalar > ComplexScalar
A shorthand for std::complex<RealScalar>
int FreqCountIntType
Integer type used for counting the number of measurement outcomes.
Some C++ utilities, with a tad of C++11 tricks.
double RealScalar
Real type for general calculation precisions (density matrix elements, log-likelihood value calculati...
int TaskCountIntType
Integer type used for counting the number of tasks.
Define tools for Eigen's eigen_assert() to throw an exception instead of assert'ing.
Eigen::Matrix< CountIntType, Eigen::Dynamic, 1 > CountIntVectorType
Shorthand, a 1-D Eigen::Matrix of CountIntType's – deprecated.
C++ Classes and Utilities for Python Modules.
int IterCountIntType
Integer type used for iteration counts in the random walk.
Eigen::Matrix< RealScalar, Eigen::Dynamic, 1 > RealVectorType
Shorthand, a 1-D Eigen::Matrix of RealScalar's.
py::module import_tomographer()
Import tomographer definitions into other Python modules.
Eigen::Matrix< ComplexScalar, Eigen::Dynamic, 1 > CplxVectorType
Shorthand, a 1-D Eigen::Matrix of ComplexScalar's.
Utilities for logging messages.
double CountRealType
Real type for averaged and/or normalized histograms.
int HistCountIntType
Integer type used for histogram counts.