Go to the documentation of this file.00001
00002
00003
00004
00005 #ifndef BOOST_NUMPY_MATRIX_HPP_INCLUDED
00006 #define BOOST_NUMPY_MATRIX_HPP_INCLUDED
00007
00013 #include <boost/python.hpp>
00014 #include <boost/numpy/numpy_object_mgr_traits.hpp>
00015 #include <boost/numpy/ndarray.hpp>
00016
00017 namespace boost
00018 {
00019 namespace numpy
00020 {
00021
00032 class matrix : public ndarray
00033 {
00034 static python::object construct(object_cref obj, dtype const & dt, bool copy);
00035 static python::object construct(object_cref obj, bool copy);
00036 public:
00037
00038 BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(matrix, ndarray);
00039
00041 explicit matrix(python::object const & obj, dtype const & dt, bool copy=true)
00042 : ndarray(python::extract<ndarray>(construct(obj, dt, copy))) {}
00043
00045 explicit matrix(python::object const & obj, bool copy=true)
00046 : ndarray(python::extract<ndarray>(construct(obj, copy))) {}
00047
00049 matrix view(dtype const & dt) const;
00050
00052 matrix copy() const;
00053
00055 matrix transpose() const;
00056
00057 };
00058
00063 template <typename Base = python::default_call_policies>
00064 struct as_matrix : Base {
00065 static PyObject * postcall(PyObject *, PyObject * result) {
00066 python::object a = python::object(python::handle<>(result));
00067 numpy::matrix m(a, false);
00068 Py_INCREF(m.ptr());
00069 return m.ptr();
00070 }
00071 };
00072
00073 }
00074 namespace python
00075 {
00076 namespace converter
00077 {
00078
00079 NUMPY_OBJECT_MANAGER_TRAITS(numpy::matrix);
00080
00081 }
00082 }
00083 }
00084
00085 #endif // !BOOST_NUMPY_MATRIX_HPP_INCLUDED