|
Boost : |
From: elaine_y_at_[hidden]
Date: 2001-08-27 12:12:17
Hi,
I have the basic functionality of creating an empty vector and being
able to pass the vectors from c++ to python. Now, I want to be able
to do it the other way. I'm having trouble fleshing out
matrix_double_wrapper::matrix_double_wrapper(PyObject* self,
python::tuple tuple)
: std::vector< std::vector<double> >(tuple.size())
{
std::vector< std::vector<double> >::iterator vd = begin();
for (int i = 0; i < tuple.size(); i++) {
std::vector<double> vrow;
// what to do next?
// tuple[i].get() gives me a reference
// how can I convert that reference to a tuple?
// then, I could parse that tuple to create a
// vector I could add to my row vector.
// python::tuple row = tuple[i].get() converted to tuple
for (int j=0; j<row.size(); j++){
vrow.push_back(BOOST_PYTHON_CONVERSION::from_python(row[i].get(),
python::type<double>()));
}
vd[i] = vrow;
}
}
The other alternative I see is to do something like
vd[i] = BOOST_PYTHON_CONVERSION::from_python(tuple[i].get(),
python::type< vector<double> >());
I did create a wrapper for vector<double> which works. However,
the above didn't work though it compiled. Not sure why.
Thanks,
Elaine
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk