473,239 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,239 software developers and data experts.

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

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<doublemyA this is easy. I do:

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

I am not sure what to do with my ublas::matrix<doublemyB?

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

Aug 30 '07 #1
1 2309
On 30 Ago, 19:40, sanjeev...@gmail.com wrote:
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<doublemyA this is easy. I do:

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

I am not sure what to do with my ublas::matrix<doublemyB?

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).

Aug 30 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Sam | last post by:
Hello, in my coding work I'm going to using a lot of matix manipulation, just basic matrix addition, multiplication, Gaussian method solving for roots, least square... But I don't know if there's...
8
by: DeMarcus | last post by:
Hi, Is there any kind of "std::matrix<>" in the STL that is optimized for matrix operations, or do I have to do a std::vector< std::vector<someType> > myMatrix; Best regards Daniel
9
by: Pat | last post by:
Given A, B and C I would like to calculate the sum of each entry: A=B+C for each i,j The easiest way is to use for-loop, but I think the performance is not good. Is it possible to find...
15
by: christopher diggins | last post by:
Here is some code I wrote for Matrix multiplication for arbitrary dimensionality known at compile-time. I am curious how practical it is. For instance, is it common to know the dimensionality of...
7
by: check.checkta | last post by:
Hi, I'd like to implement a simple matrix class. I'd like to overload operator so that it returns as a vector (either the stl vector or some other Vector class of my own). The reason I want...
20
by: Frank-O | last post by:
Hi , Recently I have been commited to the task of "translating" some complex statistical algorithms from Matlab to C++. The goal is to be three times as fast as matlab ( the latest) . I've...
1
by: utab | last post by:
Dear all, I have a question regarding an assignment operation This is the statement: "If you know for sure that the left hand expression and the right hand expression have no common storage,...
14
by: Matt | last post by:
Hello. I'm after some general advice. At the moment i have some code that should run a FOR loop a set number of times. Each time the structure stamps is read in as follows: for( i = 0 ; i <...
0
by: brekehan | last post by:
Anyone know an easy way to compare to boost matrices using the same template argument for equality? boost::numeric::ublas::matrix<doublea(2, 2); boost::numeric::ublas::matrix<doubleb(4, 4); ...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.