Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

From Ipp32f* to double**

apolo74
Beginner
563 Views
Hi there,

I need some help here, is it possible to go from a Ipp32f* to a double**??? I'm trying to plot a 3D surface using QwtPlot3D and the loadFromData function ask my data to be like a double pointer. In other words, they are expecting a matrix and not a vector like I have my Ipp data. Let's say that my IPP vector has 20 elements (1x20) and the loadFormData function expects something like data[5][4].

So my question is, is there any way to transform an IPP vector into a double** without creating a loop within a loop to assign element by element the values of the matrix???

Thanks for your help,

Boris
0 Kudos
3 Replies
Thomas_B_3
Beginner
563 Views
Hi Boris,

I think, that you will have to go through two loops. The reason is, that you need to convert an array of 32-bit data (Ipp32f) into 64-bit data (double); first loop. Then you can assign the individual pointers in your array of double** to map the correspondings vectors in your converted 1D-array; second short loop.

Best regards, TJ
0 Kudos
apolo74
Beginner
563 Views
Hi TJ,

thanks for the reply... let's say that I work with Ipp64f* instead of Ipp32f* to avoid the transformation between float and double, do I still need to assign one by one the values between my vector and the double pointer? I just wanted to avoid loops and allocation and deallocation of the double pointer.


Ipp64f xx[5*4] = { 10, 0, 5, 0, 10,
0, 0, 4, 0, 0,
0, 0, 3, 0, 0,
10, 0, 2, 0, 10};
double **x;
x = new double*[4];
for(int i=0; i<5; i++)
x = new double[4];

// --- these are the loops I'd love to avoid ---
for(int i=0; i<4; i++)
for(int j=0; j<5; j++)
x = xx[5*i+j];

.... [do something with the double pointer] ...

for( int i=0; i<5; i++)
delete x;
delete []x;

Boris
0 Kudos
Thomas_B_3
Beginner
563 Views
Hi Boris,

I was thinking of something like this (I didn't test it):

Ipp64f xx[5*4] = { 10, 0, 5, 0, 10,
0, 0, 4, 0, 0,
0, 0, 3, 0, 0,
10, 0, 2, 0, 10};
double **x;
x = new double*[4];

// --- these are the loops I'd love to avoid ---
for(int i=0; i<4; i++)
x = &xx[5*i];

.... [do something with the double pointer] ...

delete []x;

With this approach you avoid copying your data. **x is pointing to your "original" data but by accessing via x it appears to be reorganised as a matrix.


Best regards,
TJ
0 Kudos
Reply