Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

calling vzCIS within c++

Fabio_G_1
Beginner
623 Views

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){};
};

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

0 Kudos
4 Replies
mecej4
Honored Contributor III
623 Views

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.

0 Kudos
Fabio_G_1
Beginner
623 Views

MKL_Complex16 is compatible with std::complex<double>

http://software.intel.com/sites/products/documentation/hpc/mkl/lin/MKL_UG_coding_calls/Using_Complex_Types_in_C_C.htm

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.

0 Kudos
SergeyKostrov
Valued Contributor II
623 Views
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.
0 Kudos
Andrey_N_Intel
Employee
623 Views

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

0 Kudos
Reply