c++lapacke

why imaginary part of complex variables in lapacke does not work?


I am using TDM gcc 64bit compiler in windows

My headers

#include "lapacke.h"
#include "lapacke_config.h"

I have a simple code like this

lapack_complex_double x = {8.0, 6.0};
printf( "x =  (%6.2f,%6.2f)\n", x.real, x.imag);

first of all, it gives me the following error and warning

warning: excess elements in scalar initializer
lapack_complex_double x = {8.0, 6.0};
&
error: request for member 'real' in something, not a structure or union
printf( "x =  (%6.2f,%6.2f)\n", x.real, x.imag);

I changed the code as follows

lapack_complex_double x = {8.0, 6.0};
printf( "x =  (%6.2f,%6.2f)\n", lapack_complex_double_real(x),
lapack_complex_double_imag(x) );

the code was compiled with the same mentioned warning, but the result is

x =  (  8.00,  0.00)

It seems that the warning is an important error.


Solution

  • You're right that warning is an important error it's telling you that's not how you initialise complex types using the lapacke library. You need to use:

    x = lapack_make_complex_float(8.0, 6.0);
    

    see the example in this question. This should get this working for you.

    Compiling lapacke example code?