Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Erich_Zwyssig
Beginner
78 Views

[not important] mkl examples (complex_1d_double_ex1.c), allocating memory

Hija all

The mkl example (e.g.) complex_1d_double_ex1.c allocates memory as

/*
** Allocate array for input data
*/
x_in = (mkl_double_complex*)malloc(2*n*sizeof(double));
x_exp = (mkl_double_complex*)malloc(2*n*sizeof(double));

Would it not be 'nicer' to use?

//allocate memory
x = (mkl_double_complex*) malloc(n*sizeof(mkl_double_complex));
y = (mkl_double_complex*) malloc(n*sizeof(mkl_double_complex));


Thanks for your help

Erich
0 Kudos
1 Reply
barragan_villanueva_
Valued Contributor I
78 Views

Erich,

Strictly speaking, it would be nice to correctMKL examplesusing namely MKL complex types (see mkl_types.h). But currently, in DFTC exampes thereare introduced another additional types: mkl_double_complex and mkl_float_complex instead of using MKL_Complex16 and MKL_Complex8.

As to using sizeof(mkl_double_complex) instead of 2*sizeof(double), I guess, it's just a matter of taste.
Because these values are the same.

And if validation of results is made by calculation with complex numbers then they should be defined as complex. But currently in DFTC examples all support functions are implemented as interleaved real numbers (see source/dfti_example_support.c)
Reply