123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #ifndef boost_python_numpy_matrix_hpp_
- #define boost_python_numpy_matrix_hpp_
- #include <boost/python.hpp>
- #include <boost/python/numpy/numpy_object_mgr_traits.hpp>
- #include <boost/python/numpy/ndarray.hpp>
- #include <boost/python/numpy/config.hpp>
- namespace boost { namespace python { namespace numpy {
- class BOOST_NUMPY_DECL matrix : public ndarray
- {
- static object construct(object_cref obj, dtype const & dt, bool copy);
- static object construct(object_cref obj, bool copy);
- public:
- BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(matrix, ndarray);
-
- explicit matrix(object const & obj, dtype const & dt, bool copy=true)
- : ndarray(extract<ndarray>(construct(obj, dt, copy))) {}
-
- explicit matrix(object const & obj, bool copy=true)
- : ndarray(extract<ndarray>(construct(obj, copy))) {}
-
- matrix view(dtype const & dt) const;
-
- matrix copy() const;
-
- matrix transpose() const;
- };
- template <typename Base = default_call_policies>
- struct as_matrix : Base
- {
- static PyObject * postcall(PyObject *, PyObject * result)
- {
- object a = object(handle<>(result));
- numpy::matrix m(a, false);
- Py_INCREF(m.ptr());
- return m.ptr();
- }
- };
- }
- namespace converter
- {
- NUMPY_OBJECT_MANAGER_TRAITS(numpy::matrix);
- }}}
- #endif
|