7 #ifndef MDS_UTILS_PYTHON_UBLAS_MATRIX_HPP_INCLUDED     8 #define MDS_UTILS_PYTHON_UBLAS_MATRIX_HPP_INCLUDED    31 #include <boost/numeric/ublas/matrix.hpp>    33 #include <mds_utils/python/ublas/detail/common.hpp>    36 namespace mds_utils { 
namespace python { 
namespace ublas {
    54 inline typename std::enable_if<
    55     mds_utils::ublas::is_matrix<M>::value,M>::type
    63     if (!PyArray_Check(po)) {
    64         throw std::invalid_argument(
"Cannot convert to "    65             "boost::numeric::ublas::matrix: not a numpy array.");
    68     PyArrayObject   *m_po(reinterpret_cast<PyArrayObject*>(po));
    71     int                 ndim(PyArray_NDIM(m_po));
    74         throw std::invalid_argument(
"Cannot convert from an "    75             "array with num. of dims. different from 2.");
    78     npy_intp            *dims(PyArray_DIMS(m_po));
    80     M                   mout(dims[0],dims[1]);
    83         typename M::value_type,
    84         typename detail::ublas_to_npy_storage<
    85             typename M::orientation_category>::tag,NPY_ITER_READONLY>
    86                         it_beg(m_po),it_end(it_beg,
true);
    88     copy(it_beg,it_end,mout.data().begin());
   104 template<
class ublas_mat_T>
   105 inline typename std::enable_if<
   106     mds_utils::ublas::is_matrix<ublas_mat_T>::value,
   115         flags(detail::numpy_flags<
   116             typename ublas_mat_T::orientation_category>());
   120             boost::numeric_cast<npy_intp>(mat.size1()),
   121             boost::numeric_cast<npy_intp>(mat.size2())
   125         typename ublas_mat_T::value_type>::typenum);
   127     PyObject *pout(PyArray_New(&PyArray_Type,nd,dims,dtype,
   128         NULL,NULL,0,flags,NULL));
   131         throw std::runtime_error(
"Could not create output numpy array.");
   134     PyArrayObject   *m_po(reinterpret_cast<PyArrayObject*>(pout));
   136     typedef typename ublas_mat_T::value_type                    value_type;
   137     typedef typename detail::ublas_to_npy_storage<
   138             typename ublas_mat_T::orientation_category>::tag    storage;
   142     copy(mat.data().begin(),mat.data().end(),it_beg);
 Contains several utilities for interfacing Python with Boost's uBLAS. 
 
Iterator on a NumPy ndarray. 
 
Main namespace of all Michele De Stefano's C++ utilities. 
 
Contains utilities for the Boost uBLAS library. 
 
Contains utilities for the creation of NumPy extensions. 
 
std::enable_if< mds_utils::ublas::is_matrix< ublas_mat_T >::value, PyObject * >::type to_python(const ublas_mat_T &mat)
"To python" converter for Boost uBLAS matrices. 
 
Provides traits for a specific C/C++ datatype.