Garth Coghlan
2009-07-02 05:07:14 UTC
Hi all,
I have some functions that I want to wrap that look like this:
int foo(Matrix& A, Matrix& B);
where
typedef boost::numeric::ublas::matrix<double, column,
bounded_array<T> > Matrix;
I would like to wrap this function like so:
int fooWrap(numpy_matrix<double> A, numpy_matrix<double> B)
{
return foo(A, B);
}
However, the compiler doesn't allow that! I think the problem boils
down to the fact that my Matrix type uses a bounded_array<> Storage
type, but the numpy_matrix<> uses a numpy_array<> Storage type. So a
numpy_matrix<> is not substitutable for a Matrix.
One solution would be to template foo() by Storage type. But that means
I have to do through and change the existing code.
Currently I am simply copying the data into and out of a local Matrix
variable, but I'd like to avoid that if possible.
Another solution might be to somehow make a bounded_array<> that uses
the data in the numpy_array. But I can't see any way to do that.
Any suggestions?
Cheers,
Garth
I have some functions that I want to wrap that look like this:
int foo(Matrix& A, Matrix& B);
where
typedef boost::numeric::ublas::matrix<double, column,
bounded_array<T> > Matrix;
I would like to wrap this function like so:
int fooWrap(numpy_matrix<double> A, numpy_matrix<double> B)
{
return foo(A, B);
}
However, the compiler doesn't allow that! I think the problem boils
down to the fact that my Matrix type uses a bounded_array<> Storage
type, but the numpy_matrix<> uses a numpy_array<> Storage type. So a
numpy_matrix<> is not substitutable for a Matrix.
One solution would be to template foo() by Storage type. But that means
I have to do through and change the existing code.
Currently I am simply copying the data into and out of a local Matrix
variable, but I'd like to avoid that if possible.
Another solution might be to somehow make a bounded_array<> that uses
the data in the numpy_array. But I can't see any way to do that.
Any suggestions?
Cheers,
Garth