calling vzCIS within c++

calling vzCIS within c++


I've got a problem in calling vzCIS from C++

#include <complex>
#include "mkl.h"

template<class T>class array{
   int n;
   T* x;
   array(int _n):n(_n),x(new T[n]){};

int main(){
   int n=32;
   array<double> x(n);
   array<double> y(n);
   //array<MKL_Complex16> u(n);
   //array<MKL_Complex16> v(n);
   array< std::complex<double> > u(n);
   array< std::complex<double> > v(n);
   return 0;

I compiled with icpc -mkl file.cpp and icpc gave me

error: argument of type "std::complex<double> *" is incompatible with parameter of type "MKL_Complex16 *"

Does someone have a solution? Tahnk you very much.


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

The third argument of vzCIS should be an array with type (Fortran's) DOUBLE COMPLEX or something compatible with it. Your code is trying to pass a real array instead.

MKL_Complex16 is compatible with std::complex<double>

and the version with comment out lines, i.e. array<MKL_Complex16>, does not work too. (with or without redefining MKL_Complex16).

mecej4: thank you now I've understand where is the problem.

If you look at mkl_types.h header file you will see that a declaration of MKL_Complex16 type is inside of #ifndef-#endif directives. It means, that in order to use that type you'll need to define the macro MKL_Complex16 before mkl.h or mkl_types.h header files:

#define MKL_Complex16
#include "mkl.h"

or as
#define MKL_Complex16
#include "mkl_types.h"

or as
#define MKL_Complex16 std::complex
#include "mkl.h"
and in the last example MKL's complex type will be re-defined by STL complex type.

Please, also have a look at the paper which describes some aspects of use of Intel(R) MKL data types in C++ applications. Thanks, Andrey

Leave a Comment

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