ITAFFT.cpp 1.69 KB
Newer Older
Jonas Stienen's avatar
Jonas Stienen committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <ITAFFT.h>
#include "ITAFFTRealization.h"

#include <ITAException.h>

#ifdef ITAFFT_WITH_FFTW3
#include "FFTW3Backend.h"
#else
#define FFTW_MEASURE 0
#define FFTW_ESTIMATE 1<<6
#endif

#ifdef ITAFFT_WITH_MKL10
#include "MKL10Backend.h"
#endif


18 19 20
ITAFFT::ITAFFT() : m_pRealization( NULL )
{
}
Jonas Stienen's avatar
Jonas Stienen committed
21

22 23 24 25
ITAFFT::ITAFFT( int type, int size, float* in, float* out, int iPlannungMethod )
	: m_pRealization( NULL )
{
	plan( type, size, in, out, iPlannungMethod );
Jonas Stienen's avatar
Jonas Stienen committed
26 27 28 29 30 31 32
}

ITAFFT::~ITAFFT()
{
	delete m_pRealization;
}

33 34 35
bool ITAFFT::isPlanned()
{
	return ( m_pRealization != NULL );
Jonas Stienen's avatar
Jonas Stienen committed
36 37
}

38 39
void ITAFFT::plan( int type, int size, float* in, float* out, int iPlannungMethod )
{
Jonas Stienen's avatar
Jonas Stienen committed
40 41 42 43
	// Falls bereits geplant wurde, wird der alte Plan verworfen
	delete m_pRealization;

	unsigned int uiFlags = 0;
44
	if( iPlannungMethod == PLAN_USING_MEASUREMENT )
Jonas Stienen's avatar
Jonas Stienen committed
45
		uiFlags |= FFTW_MEASURE;
46
	if( iPlannungMethod == PLAN_USING_ESTIMATION )
Jonas Stienen's avatar
Jonas Stienen committed
47 48 49 50 51 52 53
		uiFlags |= FFTW_ESTIMATE;

#ifdef ITAFFT_WITH_FFTW3
	m_pRealization = FFTW3Backend::getInstance()->plan(type, size, in, out, uiFlags);
#endif

#ifdef ITAFFT_WITH_MKL10
54
	m_pRealization = MKL10Backend::getInstance()->plan( type, size, in, out, uiFlags );
Jonas Stienen's avatar
Jonas Stienen committed
55 56
#endif

57 58
	if( m_pRealization == NULL )
		ITA_EXCEPT1( UNKNOWN, "Planning of the FFT failed" );
Jonas Stienen's avatar
Jonas Stienen committed
59 60
}

61
void ITAFFT::execute()
Jonas Stienen's avatar
Jonas Stienen committed
62
{
63 64
	if( m_pRealization == NULL )
		ITA_EXCEPT1( MODAL_EXCEPTION, "Attempt to execute unplanned ITAFFT" );
Jonas Stienen's avatar
Jonas Stienen committed
65 66 67
	m_pRealization->execute();
}

68
void ITAFFT::execute( float* in, float* out )
Jonas Stienen's avatar
Jonas Stienen committed
69
{
70 71 72
	if( m_pRealization == NULL )
		ITA_EXCEPT1( MODAL_EXCEPTION, "Attempt to execute unplanned ITAFFT" );
	m_pRealization->execute( in, out );
Jonas Stienen's avatar
Jonas Stienen committed
73 74 75
}

std::string ITAFFT::toString() {
76
	return ( m_pRealization == NULL ? std::string( "unplanned ITAFFT" ) : m_pRealization->toString() );
Jonas Stienen's avatar
Jonas Stienen committed
77
}