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:
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++



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: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,


2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.


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


Leave a Comment

Please sign in to add a comment. Not a member? Join today