calling vzCIS within c++

calling vzCIS within c++

Hi,

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

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

template<class T>class array{
   public:
   int n;
   T* x;
   array(){};
   ~array(){};
   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);
   vdCos(x.n,x.x,y.x);
   vzCIS(u.n,u.x,v.x);
   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.

Fabio

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

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>

http://software.intel.com/sites/products/documentation/hpc/mkl/lin/MKL_U...

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 http://software.intel.com/en-us/articles/use-of-intel-mkl-data-types-in-cc-applications which describes some aspects of use of Intel(R) MKL data types in C++ applications. Thanks, Andrey

Deixar um comentário

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