
Thank you again for the quick reply! I will try what you have suggested.
One last question, If I have a header file to export with its
implementation file, how do I go about linking the object file with the
library that is created with bjam? When I start bjam to compile the
shared library it does not link nor compile the implementation file with
the shares library...
Ex.:
// Boost Includes
==============================================================
#include "boost/multi_array.hpp"
#include "boost/python.hpp"
#include "boost/cstdint.hpp"
// Includes
====================================================================
#include "Fstd.h"
#include "MatrixAlgorithm2D.h"
// Using
=======================================================================
using namespace boost::python;
// Module
======================================================================
BOOST_PYTHON_MODULE(matrix)
{
class_< Fstd >("Fstd", init< const Fstd& >())
.def(init< std::string >())
.def("getTT", &Fstd::getTT)
.def("getUV", &Fstd::getUV)
;
class_< MatrixAlgorithm2D >("MatrixAlgorithm2D", init< >())
.def(init< const MatrixAlgorithm2D& >())
.def("windChill", &MatrixAlgorithm2D::windChill)
.def("display_d", &MatrixAlgorithm2D::display_d)
.staticmethod("windChill")
.staticmethod("display_d")
;
class_
("const_multi_array_ref_2d");
implicitly_convertible
Sebastien Fortier wrote:
Thank you very much Daniel!
I had another question, is it possible to use multi_array and const_multi_array_ref together in python. What I mean is, if I create a multi_array from python through my c++ functions and I want to pass this array to another c++ function that uses a const_multi_array_ref how do I manage this in the interface file? is this possible?
I added class_
("const_multi_array_2d_ref"); to my interface file but the types seem to be incompatible.
You need to let Boost.Python know that the types are convertible:
implicitly_convertible< multi_array
, multi_array_ref ();
implicitly_convertible< multi_array
, const_multi_array_ref ();
Should do it. See http://www.boost.org/libs/python/doc/v2/implicit.html.
I would prefer to use the const_multi_array_ref with the multi_arrays to avoid copies...
If you already have multi_array's, why don't you just pass them by reference?
-- Sébastien Fortier