Problems with Complex16 and complex matrices

Problems with Complex16 and complex matrices

I'm just learning to use C++, so this question migth be very basic.
I need to usesome LAPACKfunction so solve a LLS problem. As it is the simplest I tried with zgels. The main problem is that I don't know how to define matrices with complex16. The only examples I could find are the ones in:
http://developer.intel.com/support/performancetools/libraries/mkl/30484.htm#4
But they doesn't work! I used to work with complex, using the standard complex library. Is there any way I could still use this? I think I just need a simple example to understand how MKL works. As I said the examples I found doesn't work for me. I put the example I'm trying (in this case just to work with complex, with doubleI made itwork):

//Example 2: Calling a Complex BLAS Level 1 Function from C++

#include

#include

typedef struct{ double re; double im; } complex16;

extern "C" void zdotc (complex16*, int *, complex16 *, int *, complex16 *, int *);

#define N 5

void main()

{

int n, inca = 1, incb = 1, i;

complex16 a[N], b[N], c;

n = N;

for( i = 0; i < n; i++ ){

a[i].re = (double)i; a[i].im = (double)i * 2.0;

b[i].re = (double)(n - i); b[i].im = (double)i * 2.0;

}

zdotc(&c, &n, a, &inca, b, &incb );

printf( "The complex dot product is: ( %6.2f, %6.2f)
", c.re, c.im );

}

ERROR MESSAGE:
c:Documents and SettingsAdministratorMy DocumentsVisual Studio ProjectsIntel MKL testsExample2.cpp(7): error C2733: second C linkage of overloaded function 'zdotc' not allowed

If I comment the line of the linkage (It made the example to work with double) I get the following erro message:

c:Documents and SettingsAdministratorMy DocumentsVisual Studio ProjectsIntel MKL testsExample2.cpp(22): error C2664: 'zdotc' : cannot convert parameter 1 from 'complex16 *' to 'MKL_Complex16 *'

Could you please give me an example that work so I can analyze it and learn how
to use MKL with complex numbers? And just in case how to define a complex matix?

Sorry to post such a basic question, but I'm trying to learn by my own and, as most of you migth know, sometimes we need some help like this.

Thank you again,

Leandro.

2 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.

Leandro,

I just tried out these examples and they worked fine except for a couple of small matters. First of all, for some reason the examples have the line "#include ", with no file indicated. If this is replaced with "inlcude ", the line in the C++ example that declares zdotc() to be "extern "C"", can be removed, since mkl.h has all the necessary declarations in it for both C and C++.

Bruce

Deixar um comentário

Faça login para adicionar um comentário. Não é membro? Inscreva-se hoje mesmo!