473,513 Members | 2,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2320
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
1858
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 a library which defines matrix and its manipulation. I know there must be one and it's somethere but I just have no experience. Thanks.
8
22592
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
1746
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 out some faster way to do that? Thanks.
15
13247
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 matricies at compile-time? Any help would be appreciated. Hopefully this code comes in useful for someone, let me know if you find it useful, or if...
7
2718
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 to do this is because it enables me to apply some functions of a vector to a row of of matrix, e.g., I have a function to compute the sum of vector:...
20
5186
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 used various techniques ( loop unrolling, loop jamming...) and tried some matrix libraries : newmat (slow for large matrix) , STL (fast but ..not...
1
1524
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, then assignment has no aliasing." This is from http://www.boost.org/libs/numeric/ublas/doc/
14
2147
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 < stamp_number ; i++ ) { printf("%g\n",stamps.scprod); .... Now on the first pass when i = 0 the whole loop runs fine. However
0
1365
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); if( a != b ) { // not equal }
0
7270
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7178
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7565
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7128
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5103
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3255
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3242
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.