17#include <boost/mpl/and.hpp>
18#include <boost/mpl/if.hpp>
21namespace PythonInterface {
31template <
typename T>
struct is_matrix : boost::false_type {};
35template <
typename T>
struct is_matrix<Kernel::Matrix<T>> : boost::true_type {};
44template <
typename MatrixType,
typename ConversionPolicy>
struct MatrixRefToNumpyImpl {
45 inline PyObject *operator()(
const MatrixType &cmatrix)
const {
49 inline PyTypeObject
const *get_pytype()
const {
return ndarrayType(); }
52template <
typename T>
struct MatrixRefToNumpy_Requires_Reference_To_Matrix_Return_Type {};
67 template <
class T>
struct apply {
72 using type =
typename boost::mpl::if_c<boost::mpl::and_<std::is_reference<T>, is_matrix<non_const_type>>
::value,
73 MatrixRefToNumpyImpl<non_const_type, ConversionPolicy>,
74 MatrixRefToNumpy_Requires_Reference_To_Matrix_Return_Type<T>>
::type;
86template <
typename MatrixType>
struct MatrixToNumpyImpl {
87 inline PyObject *operator()(
const MatrixType &cvector)
const {
91 inline PyTypeObject
const *get_pytype()
const {
return ndarrayType(); }
94template <
typename T>
struct MatrixToNumpy_Requires_Matrix_Return_By_Value {};
109 using type =
typename boost::mpl::if_c<is_matrix<non_const_type>::value,
110 MatrixRefToNumpyImpl<non_const_type, Converters::Clone>,
111 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...