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

why passing DFTI_SINGLE into DftiCreateDescriptor gives garbage values?

raavi
Novice
280 Views

I have two questions.

1) why, when passing DFTI_SINGLE into DftiCreateDescriptor gives garbage values?

2) Though passing DFTI_DOUBLE into DftiCreateDescriptor gives sane values but the output does not match with Octave output.

MKL_LONG status;
DFTI_DESCRIPTOR_HANDLE backward_handle_2d = NULL;
MKL_Complex16 *fourier_2d_mkl       	  = NULL;        

MKL_LONG dims[2];

dims[0] 		= 2;
dims[1] 		= 23;

int count_2d    = dims[0]*dims[1];

status  		= DftiCreateDescriptor(&backward_handle_2d, DFTI_DOUBLE, DFTI_COMPLEX, 2, dims);
status  		= DftiCommitDescriptor(backward_handle_2d);



fourier_2d_mkl  = (MKL_Complex16*)mkl_malloc(count_2d * sizeof(MKL_Complex16), 64);

for (int i=0; i<count_2d; i++)
    { fourier_2d_mkl[i].real = 0.0; fourier_2d_mkl[i].imag = 0.0; }

fourier_2d_mkl[0].real  = -2.642292567870791e-17; fourier_2d_mkl[0].imag  =  2.457213459869541e-17;
fourier_2d_mkl[1].real  =  3.394204453993388e-15; fourier_2d_mkl[1].imag  =  6.465292243826133e-14;     
fourier_2d_mkl[2].real  =  7.250014158956356e-13; fourier_2d_mkl[2].imag  = -4.363287473914971e-12;
fourier_2d_mkl[3].real  = -1.428607589482790e-10; fourier_2d_mkl[3].imag  =  1.188079301204293e-10;    
fourier_2d_mkl[4].real  =  6.952990293826207e-09; fourier_2d_mkl[4].imag  =  7.124671255671636e-10;
fourier_2d_mkl[5].real  = -1.247732021241605e-07; fourier_2d_mkl[5].imag  = -1.525550389367994e-07;    
fourier_2d_mkl[6].real  = -3.680801028326798e-07; fourier_2d_mkl[6].imag  =  3.686621541467887e-06;    
fourier_2d_mkl[7].real  =  2.677103698936326e-05; fourier_2d_mkl[7].imag  = -2.208311063252299e-05;
fourier_2d_mkl[8].real  =  3.310982970348360e-06; fourier_2d_mkl[8].imag  =  4.060528725376024e-06;

fourier_2d_mkl[15].real  =  2.701945410474277e-05;fourier_2d_mkl[15].imag  = -2.177772108929361e-05;
fourier_2d_mkl[16].real =  3.685365224055048e-06; fourier_2d_mkl[16].imag =  3.817322139893435e-07;        
fourier_2d_mkl[17].real =  1.243931716409880e-07; fourier_2d_mkl[17].imag =  1.528359352830827e-07;
fourier_2d_mkl[18].real = -7.210215362767208e-10; fourier_2d_mkl[18].imag =  6.961508659626094e-09;    
fourier_2d_mkl[19].real = -1.449335800029190e-10; fourier_2d_mkl[19].imag =  1.184786074831728e-10;
fourier_2d_mkl[20].real = -4.345677649234239e-12; fourier_2d_mkl[20].imag = -8.023045583080176e-13;
fourier_2d_mkl[21].real = -2.174238868343064e-15; fourier_2d_mkl[21].imag = -6.468023321689881e-14;
fourier_2d_mkl[22].real = -2.648066946353768e-17; fourier_2d_mkl[22].imag = -2.943784428508000e-17;

fourier_2d_mkl[23].real = -1.647039786289660e-14; fourier_2d_mkl[23].imag =  1.531673055823963e-14;
fourier_2d_mkl[24].real =  9.328254025265415e-13; fourier_2d_mkl[24].imag =  1.660593228562294e-11;
fourier_2d_mkl[25].real =  9.970878341165177e-11; fourier_2d_mkl[25].imag = -4.852415762764660e-10;
fourier_2d_mkl[26].real = -7.587349566415179e-09; fourier_2d_mkl[26].imag =  5.641756309256826e-09;        
fourier_2d_mkl[27].real =  1.569897070996509e-07; fourier_2d_mkl[27].imag =  2.418811983812866e-08;
fourier_2d_mkl[28].real = -1.184957370080801e-06; fourier_2d_mkl[28].imag = -1.607459905410108e-06;
fourier_2d_mkl[29].real = -2.422333576942743e-06; fourier_2d_mkl[29].imag =  1.649413356788869e-05;
fourier_2d_mkl[30].real =  5.397110486561100e-05; fourier_2d_mkl[30].imag = -4.182910800968701e-05;
fourier_2d_mkl[31].real =  1.389085535845420e-05; fourier_2d_mkl[31].imag =  1.904852960287619e-05;

fourier_2d_mkl[38].real =  5.632425140135355e-05; fourier_2d_mkl[38].imag = -3.860245232056857e-05;
fourier_2d_mkl[39].real =  1.644525380084373e-05; fourier_2d_mkl[39].imag =  2.735362516264706e-06;
fourier_2d_mkl[40].real =  1.168718667543190e-06; fourier_2d_mkl[40].imag =  1.619167661329656e-06;
fourier_2d_mkl[41].real = -2.520504976062189e-08; fourier_2d_mkl[41].imag =  1.569498873744191e-07;
fourier_2d_mkl[42].real = -7.685758628322245e-09; fourier_2d_mkl[42].imag =  5.594175098567900e-09;
fourier_2d_mkl[43].real = -4.829524388709853e-10; fourier_2d_mkl[43].imag = -1.083259323876055e-10;
fourier_2d_mkl[44].real = -6.194460301224245e-13; fourier_2d_mkl[44].imag = -1.661409550202508e-11;
fourier_2d_mkl[45].real = -1.650639172375137e-14; fourier_2d_mkl[45].imag = -1.834970939618425e-14;

status  		= DftiComputeBackward(backward_handle_2d, fourier_2d_mkl);
status  		= DftiFreeDescriptor(&backward_handle_2d);         

int K   		= 8;

for (int j=0; j<dims[0]; j++)
{
    for (int i=0; i<dims[1]; i++)
    {
        int index  = i + ( j * dims[1] );        
        double phi = (2.0 * pi * i) / static_cast<double>(dims[1]);            

        std::complex<double> signal(fourier_2d_mkl[index].real, fourier_2d_mkl[index].imag);            

        std::complex<double> output = Internal::complex_multiply(signal, Internal::expi(-K * phi));         

        std::cout <<std::left <<output.real() << "\t" <<output.imag()<<std::endl;
    }
    std::cout << std::endl;
}             

mkl_free(fourier_2d_mkl);
0 Kudos
1 Reply
raavi
Novice
223 Views

Please close this post.

0 Kudos
Reply