Michele De Stefano's C++ Utilities
mds_utils::python::ublas Namespace Reference

Contains several utilities for interfacing Python with Boost's uBLAS. More...

Functions

template<class M >
std::enable_if< mds_utils::ublas::is_matrix< M >::value, M >::type get (PyObject *po)
 "From python" converter for Boost uBLAS matrices. More...
 
template<class ublas_mat_T >
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. More...
 
template<class M >
std::enable_if< mds_utils::ublas::is_compressed_matrix< M >::value, M >::type get (PyObject *po)
 "From python" converter for Boost uBLAS compressed matrices. More...
 
template<class ublas_mat_T >
std::enable_if< mds_utils::ublas::is_compressed_matrix< ublas_mat_T >::value, PyObject * >::type to_python (const ublas_mat_T &mat)
 "To python" converter for Boost uBLAS matrices. More...
 
template<class ublas_vec_T >
std::enable_if< mds_utils::ublas::is_vector< ublas_vec_T >::value, ublas_vec_T >::type get (PyObject *po)
 "From python" converter for Boost uBLAS vectors. More...
 
template<class ublas_vec_T >
std::enable_if< mds_utils::ublas::is_vector< ublas_vec_T >::value, PyObject * >::type to_python (const ublas_vec_T &v)
 "To python" converter for Boost uBLAS vectors. More...
 

Detailed Description

Contains several utilities for interfacing Python with Boost's uBLAS.

Some of these utilities require the NumPy package to be installed.

Author
Michele De Stefano
Date
13/05/2014

Function Documentation

template<class M >
std::enable_if< mds_utils::ublas::is_matrix<M>::value,M>::type mds_utils::python::ublas::get ( PyObject *  po)
inline

"From python" converter for Boost uBLAS matrices.

Primary template for extracting a value from a Python object.

Template Parameters
MThe data type of a dense uBLAS matrix.
Parameters
poThe Numpy array object to convert from.
Returns
Boost uBLAS dense matrix corresponding to the Numpy array to be converted.
Author
Michele De Stefano
Date
22/06/2014

Definition at line 56 of file matrix.hpp.

template<class ublas_vec_T >
std::enable_if< mds_utils::ublas::is_vector<ublas_vec_T>::value,ublas_vec_T>::type mds_utils::python::ublas::get ( PyObject *  po)
inline

"From python" converter for Boost uBLAS vectors.

Primary template for extracting a value from a Python object.

Template Parameters
ublas_vec_TThe data type of a dense uBLAS vector.
Parameters
poThe Numpy array object to be converted.
Returns
Boost uBLAS dense vector corresponding to the Numpy array to be converted.
Author
Michele De Stefano
Date
30/06/2014

Definition at line 64 of file vector.hpp.

template<class M >
std::enable_if< mds_utils::ublas::is_compressed_matrix<M>::value,M>::type mds_utils::python::ublas::get ( PyObject *  po)
inline

"From python" converter for Boost uBLAS compressed matrices.

Primary template for extracting a value from a Python object.

Template Parameters
MThe data type of a uBLAS compressed_matrix.
Parameters
poThe Numpy array object to convert from.
Returns
A Boost uBLAS compressed matrix corresponding to the Numpy array to be converted.
Remarks
Works with real and complex data types.
Author
Michele De Stefano
Date
24/06/2014

Definition at line 87 of file matrix_sparse.hpp.

References mds_utils::python::Obj::attr(), mds_utils::python::Obj::get_ownership(), and mds_utils::python::len().

template<class ublas_mat_T >
std::enable_if< mds_utils::ublas::is_matrix<ublas_mat_T>::value, PyObject* >::type mds_utils::python::ublas::to_python ( const ublas_mat_T &  mat)
inline

"To python" converter for Boost uBLAS matrices.

Template Parameters
ublas_mat_TThe data type of a dense uBLAS matrix.
Author
Michele De Stefano
Date
30/06/2014

Definition at line 108 of file matrix.hpp.

template<class ublas_vec_T >
std::enable_if< mds_utils::ublas::is_vector<ublas_vec_T>::value, PyObject* >::type mds_utils::python::ublas::to_python ( const ublas_vec_T &  v)
inline

"To python" converter for Boost uBLAS vectors.

This is the implementation that gets activated when dealing with real scalar data types.

Template Parameters
ublas_vec_TThe data type of a dense uBLAS vector.
Author
Michele De Stefano
Date
30/06/2014

Definition at line 120 of file vector.hpp.

template<class ublas_mat_T >
std::enable_if< mds_utils::ublas::is_compressed_matrix<ublas_mat_T>::value, PyObject* >::type mds_utils::python::ublas::to_python ( const ublas_mat_T &  mat)
inline

"To python" converter for Boost uBLAS matrices.

This is the implementation that gets activated when dealing with real scalar data types.

Template Parameters
ublas_mat_TThe data type of a dense uBLAS matrix.
Author
Michele De Stefano
Date
30/06/2014

Definition at line 162 of file matrix_sparse.hpp.

References mds_utils::python::Obj::attr(), mds_utils::python::Obj::get_ownership(), mds_utils::python::Sequence_Base< Derived >::set(), and mds_utils::python::Obj::transfer().