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> 101 typedef Eigen::Matrix<std::complex<RealType>, Eigen::Dynamic, Eigen::Dynamic>
CplxMatrixType;
121 auto tomographer_module = py::module::import(
"tomographer");
122 if (PyErr_Occurred() != NULL) {
123 throw py::error_already_set();
126 tomographer_module.attr(
"__version__").cast<
std::string>();
127 if (module_tomographer_version != TOMOGRAPHER_VERSION) {
129 "Error: Version of compiled tomographer python module ("+module_tomographer_version +
130 ") does not match version used to compile the current module (" +
std::string(TOMOGRAPHER_VERSION)
131 +
"). If you updated tomographer, please recompile all dependent modules." 138 const std::string module_tomographer_pybind11_ver =
139 tomographer_module.attr(
"version").attr(
"compile_info").attr(
"get")(
"pybind11",
"").cast<std::string>();
140 if (module_tomographer_pybind11_ver != this_pybind11_ver) {
142 "Error: Compiled tomographer's version of PyBind11 (" + module_tomographer_pybind11_ver +
143 ") does not match version used to compile the current module (" + this_pybind11_ver
144 +
"). Please recompile all modules using the same PyBind11 version." 147 return tomographer_module;
double RealType
Real type for template arguments (double)
Eigen::Matrix< std::complex< RealType >, Eigen::Dynamic, 1 > CplxVectorType
Shorthand, a 1-D Eigen::Matrix of std::complex<RealType>'s.
Eigen::Matrix< RealType, Eigen::Dynamic, Eigen::Dynamic > RealMatrixType
Shorthand, a 2-D Eigen::Matrix of RealType's.
Some C++ utilities, with a tad of C++11 tricks.
Eigen::Matrix< RealType, Eigen::Dynamic, 1 > RealVectorType
Shorthand, a 1-D Eigen::Matrix of RealType's.
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.
long CountIntType
Integer type for template arguments (`long' in case of long random walks)
Eigen::Matrix< std::complex< RealType >, Eigen::Dynamic, Eigen::Dynamic > CplxMatrixType
Shorthand, a 2-D Eigen::Matrix of std::complex<RealType>'s.
C++ Classes and Utilities for Python Modules.
py::module import_tomographer()
Import tomographer definitions into other Python modules.
Utilities for logging messages.