Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- Software
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library
- C++: how to convert from complex(double) to MKL_Complex16 and

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Paul_Margosian

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

01-07-2011
10:54 AM

464 Views

C++: how to convert from complex(double) to MKL_Complex16 and vice versa?

Want to use LAPACKE_zgesv to solve systems of equations

Have calculated relevant matrices in C++ using (standard) complex

Need to convert these to MKL_Complex16 in order to use zgesv, then convert back afterwards.

Have tried a fewguesses that seemed reasonable, but no luck. The official example for zgesv just loads complex constants and does not do variable type conversions, so it doesn't help.

Help! I'm stuck once again. New user blues.

Paul Margosian

Link Copied

4 Replies

barragan_villanueva_

Valued Contributor I

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

01-09-2011
09:21 AM

464 Views

Please add the following define-line in your C++ source file before including mkl.h header file

#define MKL_Complex16 complex

After that no conversion will be needed because MKL_Comlex16 typeis redefined to your complex

Note, that such redefinitions are to be consistent in order to get correct results after MKL routines.

Gennady_F_Intel

Moderator

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

01-09-2011
11:05 AM

464 Views

Paul,

the similar topic has been discussed here.

--Gennady

Paul_Margosian

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

01-11-2011
05:27 AM

464 Views

Thanks. A very nice trick.

Unfortunately: MKL_Complex16 and complex

One of many error messages revealed some details about how MKL_Complex16 is defined (a structuredefining "xxx.real" and "xxx.imag")

Just for the record, this is an example of what seems to work:

complex

MKL_Complex16 mkl_Z;

mkl_Z.real = real(myZ);

mkl_Z.imag = imag(myZ);

Did this with my input arrays (suitable loops and array formatting) for zgesv and compilation went OK.

Have not yet run this and checked outputs, so there is still a chance for additional puzzling problems.

Paul Margosian

barragan_villanueva_

Valued Contributor I

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

01-11-2011
11:51 PM

464 Views

Sorry, but I don't understand why you had problems if MKL_Complex16 was redefined.

Could you please send me small testcase to demonstrate this problem?

It will be helpful to make MKL-types more flexible and be freindlyin applications.

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

For more complete information about compiler optimizations, see our Optimization Notice.