matrix.hpp
Go to the documentation of this file.
00001 // Copyright Jim Bosch 2010-2012.
00002 // Distributed under the Boost Software License, Version 1.0.
00003 //    (See accompanying file LICENSE_1_0.txt or copy at
00004 //          http://www.boost.org/LICENSE_1_0.txt)
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 } // namespace boost::numpy
00074 namespace python
00075 {
00076 namespace converter 
00077 {
00078 
00079 NUMPY_OBJECT_MANAGER_TRAITS(numpy::matrix);
00080 
00081 } // namespace boost::python::converter
00082 } // namespace boost::python
00083 } // namespace boost
00084 
00085 #endif // !BOOST_NUMPY_MATRIX_HPP_INCLUDED


boost_numpy
Author(s): Jim Bosch, Ankit Daftery
autogenerated on Fri Aug 28 2015 10:10:40