28 #ifndef TOMOPY_COMMON_H 29 #define TOMOPY_COMMON_H 34 #include <type_traits> 36 #include <pybind11/pybind11.h> 38 namespace py = pybind11;
42 # ifdef _tomographer_cxx_EXPORTS 43 # define TOMOGRAPHER_EXPORT __declspec(dllexport) 45 # define TOMOGRAPHER_EXPORT __declspec(dllimport) 48 # define TOMOGRAPHER_EXPORT __attribute__((visibility("default"))) 53 #ifndef TOMOGRAPHERPY_DEBUG_EIGEN_ASSERT_CAUSES_ABORT 54 # define TOMOGRAPHER_EIGEN_ASSERT_EXCEPTION 59 #pragma GCC visibility push(default) 60 #include <pybind11/eigen.h> 63 # error "TomographerPy requires enabled Eigen assertions, otherwise `TomographerCxxError` won't be raised as documented." 67 #pragma GCC visibility pop 69 #include <tomographer/tomographer_version.h> 73 #include <tomographerpy/pylogger.h> 154 auto tomographer_module = py::module::import(
"tomographer");
155 if (PyErr_Occurred() != NULL) {
156 throw py::error_already_set();
159 tomographer_module.attr(
"__version__").cast<
std::string>();
160 if (module_tomographer_version != TOMOGRAPHER_VERSION) {
162 "Error: Version of compiled tomographer python module ("+module_tomographer_version +
163 ") does not match version used to compile the current module (" +
std::string(TOMOGRAPHER_VERSION)
164 +
"). If you updated tomographer, please recompile all dependent modules." 171 const std::string module_tomographer_pybind11_ver =
172 tomographer_module.attr(
"version").attr(
"compile_info").attr(
"get")(
"pybind11",
"").cast<std::string>();
173 if (module_tomographer_pybind11_ver != this_pybind11_ver) {
175 "Error: Compiled tomographer's version of PyBind11 (" + module_tomographer_pybind11_ver +
176 ") does not match version used to compile the current module (" + this_pybind11_ver
177 +
"). Please recompile all modules using the same PyBind11 version." 180 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.