16#include <boost/mpl/and.hpp>
17#include <boost/mpl/if.hpp>
20namespace PythonInterface {
30template <
typename T>
struct is_matrix : boost::false_type {};
34template <
typename T>
struct is_matrix<Kernel::Matrix<T>> : boost::true_type {};
43template <
typename MatrixType,
typename ConversionPolicy>
struct MatrixRefToNumpyImpl {
44 inline PyObject *operator()(
const MatrixType &cmatrix)
const {
48 inline PyTypeObject
const *get_pytype()
const {
return ndarrayType(); }
51template <
typename T>
struct MatrixRefToNumpy_Requires_Reference_To_Matrix_Return_Type {};
66 template <
class T>
struct apply {
71 using type =
typename boost::mpl::if_c<boost::mpl::and_<std::is_reference<T>, is_matrix<non_const_type>>
::value,
72 MatrixRefToNumpyImpl<non_const_type, ConversionPolicy>,
73 MatrixRefToNumpy_Requires_Reference_To_Matrix_Return_Type<T>>
::type;
85template <
typename MatrixType>
struct MatrixToNumpyImpl {
86 inline PyObject *operator()(
const MatrixType &cvector)
const {
90 inline PyTypeObject
const *get_pytype()
const {
return ndarrayType(); }
93template <
typename T>
struct MatrixToNumpy_Requires_Matrix_Return_By_Value {};
108 using type =
typename boost::mpl::if_c<is_matrix<non_const_type>::value,
109 MatrixRefToNumpyImpl<non_const_type, Converters::Clone>,
110 MatrixToNumpy_Requires_Matrix_Return_By_Value<T>>
::type;
double value
The value of the point.
MANTID_PYTHONINTERFACE_CORE_DLL PyTypeObject * ndarrayType()
Return the type object for a numpy.NDArray.
Helper class which provides the Collimation Length for SANS instruments.
Converter that takes a Mantid Matrix and converts it into a numpy array.
typename std::remove_const< typename std::remove_reference< T >::type >::type non_const_type
typename boost::mpl::if_c< boost::mpl::and_< std::is_reference< T >, is_matrix< non_const_type > >::value, MatrixRefToNumpyImpl< non_const_type, ConversionPolicy >, MatrixRefToNumpy_Requires_Reference_To_Matrix_Return_Type< T > >::type type
Implements a return value policy that returns a numpy array from a Matrix.
typename std::remove_const< T >::type non_const_type
typename boost::mpl::if_c< is_matrix< non_const_type >::value, MatrixRefToNumpyImpl< non_const_type, Converters::Clone >, MatrixToNumpy_Requires_Matrix_Return_By_Value< T > >::type type
Implements a return value policy that returns a numpy array from a function returning a std::vector b...