[C++-sig] std::complex<double>?
Neal D. Becker
nbecker at hns.com
Fri Jan 9 14:07:28 CET 2004
How do I reflect std::complex<double> into python?
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
#include <boost/python/implicit.hpp>
#include <complex>
using namespace boost::python;
BOOST_PYTHON_MODULE(hello)
{
class_<std::vector<double> >("DoubleVec")
.def(init<size_t>())
.def(vector_indexing_suite<std::vector<double> >())
;
class_<std::vector<std::complex<double> > >("CDoubleVec")
.def(init<size_t>())
.def(vector_indexing_suite<std::vector<std::complex<double> > >())
;
}
z=CDoubleVec(2)
>>> z
<hello.CDoubleVec object at 0x8446a54>
>>> z[0]
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: No Python class registered for C++ class std::complex<double>
I also will need std::complex<int>. What would I need for this?
More information about the Cplusplus-sig
mailing list