Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Gouyon_R_
Beginner
172 Views

Problem with FFT code exemple and Visual Studio 2017

Hello

I am trying to run the FFT code exemple. I am using Visual Studio with the intel 2019 compiler

this is my code 
#include "pch.h"
#include <iostream>
#include "mkl_dfti.h"

int main()
{
	/* C example, float _Complex is defined in C9X */

	float _Complex x_in[32];
	float _Complex x_out[32];
	float y_in[32];
	float y_out[34];

	DFTI_DESCRIPTOR_HANDLE my_desc1_handle;
	DFTI_DESCRIPTOR_HANDLE my_desc2_handle;
	MKL_LONG status;
	//...put input data into x_in[0],...,x_in[31]; y_in[0],...,y_in[31]
	for (int i = 0; i < 32; i++)
	{
		x_in = cos(2 * 3.1415926535897932384626433832795*i * 4 / 32);
		
	}
	
	status = DftiCreateDescriptor(&my_desc1_handle, DFTI_SINGLE,
		DFTI_COMPLEX, 1, 32);
	status = DftiSetValue(my_desc1_handle, DFTI_PLACEMENT, DFTI_NOT_INPLACE);
	status = DftiCommitDescriptor(my_desc1_handle);
	status = DftiComputeForward(my_desc1_handle, x_in, x_out);
	status = DftiFreeDescriptor(&my_desc1_handle);
	/* result is x_out[0], ..., x_out[31]*/
	status = DftiCreateDescriptor(&my_desc2_handle, DFTI_SINGLE,
		DFTI_REAL, 1, 32);
	Status = DftiSetValue(My_Desc2_Handle, DFTI_PLACEMENT, DFTI_NOT_INPLACE);
	status = DftiCommitDescriptor(my_desc2_handle);
	status = DftiComputeForward(my_desc2_handle, y_in, y_out);
	status = DftiFreeDescriptor(&my_desc2_handle);
	/* result is given by y_out in CCS format*/
}

And I have problems with the float _Complex type.

I have set the '/Qstd=c99' option in my project but visual studio returns an error about this option. It says "the '/Qstd=c99' option is not valid for C++ compilations"

My program is not a c++ program

Any idea to solve this problem

Remi

0 Kudos
7 Replies
Viet_H_Intel
Moderator
172 Views

You have included iostream, which is C++ header.

Gouyon_R_
Beginner
172 Views

I have made a new project with no iostream and no pch.h. and rename my main fin in .c instead of .cpp

It has no effect the error is the same.

The problem is that it does not fin the definition of float _Complex

jimdempseyatthecove
Black Belt
172 Views

I do not see that you are including

#include <complex.h>

see: https://www.gnu.org/software/libc/manual/html_node/Complex-Numbers.html

Jim Dempsey

Gouyon_R_
Beginner
172 Views

I have tried but it's not working. I use the complex.h witch is in the ..\compilers_and_libraries_2019\compilers\include\ directory

I haver also tried without the '/Qstd=c99'  option and it does not work

 

Viet_H_Intel
Moderator
172 Views

I wonder if your test program works with cl?

Gouyon_R_
Beginner
172 Views

I have the solution from intel support

#include <stdlib.h>
#include <stdio.h>
#include "mkl.h"
#include <math.h>


int main()
{
	/* C example, float _Complex is defined in C9X */
	MKL_Complex8 x_in[32];
	MKL_Complex8 x_out[32];
	//float x_in[32];
	//float x_out[32];
	float y_in[32];
	float y_out[34];

	DFTI_DESCRIPTOR_HANDLE my_desc1_handle = 0;
	DFTI_DESCRIPTOR_HANDLE my_desc2_handle = 0;
	MKL_LONG status;
	//...put input data into x_in[0],...,x_in[31]; y_in[0],...,y_in[31]
	for (int i = 0; i < 32; i++)
	{
		x_in.real = cos(2 * 3.1415926535897932384626433832795*i * 4 / 32);
		x_in.imag = cos(2 * 3.1415926535897932384626433832795*i * 4 / 32);
	}

	status = DftiCreateDescriptor(&my_desc1_handle, DFTI_SINGLE, DFTI_COMPLEX, 1, 32);

	status = DftiSetValue(my_desc1_handle, DFTI_PLACEMENT, DFTI_NOT_INPLACE);

	status = DftiCommitDescriptor(my_desc1_handle);

	status = DftiComputeForward(my_desc1_handle, x_in, x_out);

	status = DftiFreeDescriptor(&my_desc1_handle);

	/* result is x_out[0], ..., x_out[31]*/
	status = DftiCreateDescriptor(&my_desc2_handle, DFTI_SINGLE, DFTI_REAL, 1, 32);

	status = DftiSetValue(my_desc2_handle, DFTI_PLACEMENT, DFTI_NOT_INPLACE);

	status = DftiCommitDescriptor(my_desc2_handle);

	status = DftiComputeForward(my_desc2_handle, y_in, y_out);

	status = DftiFreeDescriptor(&my_desc2_handle);

	return status;
}

 

Fowler__Austin
Beginner
172 Views

Where can I find mkl.h?

Reply