How to pass a ublas::matrix to a C API

S

sanjeev.p3

I need to pass ublas::matrix data to a legacy C API which expects
input in the form:

void doSomething(double* data,...);

If I have a std::vector<double> myA this is easy. I do:

doSomething(&myA[0],...);

I am not sure what to do with my ublas::matrix<double> myB?

I tried:

matrix_column<matrix<double> > x1(myB, 0); //get a proxy to the
1st column
doSomething(&x1[0],...);

but this results in a "differs in levels of indirection from
'boost::numeric::ublas::matrix_column<M>" error. Is there a way to do
this without copying to another data strucutre before passing?

Thanks,
Sanjeev
 
C

carvalho.miguel

I need to pass ublas::matrix data to a legacy C API which expects
input in the form:

void doSomething(double* data,...);

If I have a std::vector<double> myA this is easy. I do:

doSomething(&myA[0],...);

I am not sure what to do with my ublas::matrix<double> myB?

I tried:

matrix_column<matrix<double> > x1(myB, 0); //get a proxy to the
1st column
doSomething(&x1[0],...);

but this results in a "differs in levels of indirection from
'boost::numeric::ublas::matrix_column<M>" error. Is there a way to do
this without copying to another data strucutre before passing?

Thanks,
Sanjeev

have you tried matrix_row instead?
if it still doesnt work, maybe ublas has an internal design which
doesnt allowed that kind of argument passing, which means you will
have to create a vector (or array for that matter) for each row or
column of the matrix before sending it to the function (using a for
loop).
cant be of better help, since my understanding of ublas is very
limited (aka havent worked much with it).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top