Style, and removing old SVN/CSV changelog lines

parent 50a3588d
/*
* ITAFFT, eine Wrapper-Bibliothek für schnelle Fouriertransformationen
*
* Autor: Frank Wefers (Frank.Wefers@akustik.rwth-aachen.de)
*
* (c) Copyright Institut für Technische Akustik (ITA), RWTH Aachen
*
*/
// $Id: FFTW3Backend.cpp,v 1.3 2010-01-18 17:19:01 fwefers Exp $
#include "FFTW3Backend.h"
#include <cassert>
......@@ -18,48 +7,52 @@
ITACriticalSection csFFTW3BackendPlannerLock;
FFTW3Realization::FFTW3Realization(int type, int size, float* in, float* out, unsigned int uiFlags)
: m_plan(NULL), m_type(type), m_size(size), m_out(out)
FFTW3Realization::FFTW3Realization( int type, int size, float* in, float* out, unsigned int uiFlags )
: m_plan( NULL )
, m_type( type )
, m_size( size )
, m_out( out )
{
if ((size <= 0) || (in == NULL) || (out == NULL)) ITA_EXCEPT0(INVALID_PARAMETER);
if( ( size <= 0 ) || ( in == NULL ) || ( out == NULL ) ) ITA_EXCEPT0( INVALID_PARAMETER );
fftw_iodim dim, howmany_dim;
csFFTW3BackendPlannerLock.enter();
// [fwe 2010-07-20] Wichtiges Bugfix. Für out-of-place Transformationen die Eingabe unberührt lassen.
m_inplace = (in == out);
if (m_inplace) uiFlags |= FFTW_PRESERVE_INPUT;
m_inplace = ( in == out );
if( m_inplace ) uiFlags |= FFTW_PRESERVE_INPUT;
switch (type) {
switch( type )
{
case ITAFFT::FFT_R2C:
m_plan = fftwf_plan_dft_r2c_1d(size, in, (fftwf_complex*) out, uiFlags);
m_plan = fftwf_plan_dft_r2c_1d( size, in, ( fftwf_complex* ) out, uiFlags );
m_sInfo = "FFT_R2C [fftw3]";
break;
case ITAFFT::FFT_C2C:
m_plan = fftwf_plan_dft_1d(size, (fftwf_complex*) in, (fftwf_complex*) out, FFTW_FORWARD, uiFlags);
m_plan = fftwf_plan_dft_1d( size, ( fftwf_complex* ) in, ( fftwf_complex* ) out, FFTW_FORWARD, uiFlags );
m_sInfo = "FFT_C2C [fftw3]";
break;
case ITAFFT::IFFT_C2R:
m_plan = fftwf_plan_dft_c2r_1d(size, (fftwf_complex*) in, out, uiFlags);
m_plan = fftwf_plan_dft_c2r_1d( size, ( fftwf_complex* ) in, out, uiFlags );
m_sInfo = "IFFT_C2R [fftw3]";
break;
case ITAFFT::IFFT_C2C:
m_plan = fftwf_plan_dft_1d(size, (fftwf_complex*) in, (fftwf_complex*) out, FFTW_BACKWARD, uiFlags);
m_plan = fftwf_plan_dft_1d( size, ( fftwf_complex* ) in, ( fftwf_complex* ) out, FFTW_BACKWARD, uiFlags );
m_sInfo = "IFFT_C2C [fftw3]";
break;
case ITAFFT::SPLIT_FFT_R2C:
case ITAFFT::SPLIT_FFT_R2C:
dim.n = size;
dim.is = dim.os = 1;
howmany_dim.n = 1;
howmany_dim.is = howmany_dim.os = 1;
m_plan = fftwf_plan_guru_split_dft_r2c(1, &dim, 1, &howmany_dim, in, out, out+(size/2)+1, uiFlags);
m_plan = fftwf_plan_guru_split_dft_r2c( 1, &dim, 1, &howmany_dim, in, out, out + ( size / 2 ) + 1, uiFlags );
m_sInfo = "SPLIT_FFT_R2C [fftw3]";
break;
......@@ -70,7 +63,7 @@ FFTW3Realization::FFTW3Realization(int type, int size, float* in, float* out, un
howmany_dim.n = 1;
howmany_dim.is = howmany_dim.os = 1;
m_plan = fftwf_plan_guru_split_dft_c2r(1, &dim, 1, &howmany_dim, in, in+(size/2)+1, out, uiFlags);
m_plan = fftwf_plan_guru_split_dft_c2r( 1, &dim, 1, &howmany_dim, in, in + ( size / 2 ) + 1, out, uiFlags );
m_sInfo = "SPLIT_IFFT_C2R [fftw3]";
break;
......@@ -81,68 +74,79 @@ FFTW3Realization::FFTW3Realization(int type, int size, float* in, float* out, un
howmany_dim.n = 1;
howmany_dim.is = howmany_dim.os = 1;
m_plan = fftwf_plan_guru_split_dft_c2r(1, &dim, 1, &howmany_dim, in, in+(size/2)+1, out, uiFlags);
m_plan = fftwf_plan_guru_split_dft_c2r( 1, &dim, 1, &howmany_dim, in, in + ( size / 2 ) + 1, out, uiFlags );
m_sInfo = "NORMALIZED_SPLIT_IFFT_C2R [fftw3]";
break;
}
csFFTW3BackendPlannerLock.leave();
if (m_plan == NULL) ITA_EXCEPT0(UNKNOWN);
if( m_plan == NULL )
ITA_EXCEPT0( UNKNOWN );
}
FFTW3Realization::~FFTW3Realization() {
if (m_plan != NULL) fftwf_destroy_plan(m_plan);
FFTW3Realization::~FFTW3Realization()
{
if( m_plan != NULL )
fftwf_destroy_plan( m_plan );
}
void FFTW3Realization::execute() {
fftwf_execute(m_plan);
fftwf_execute( m_plan );
// Sonderfall NORMALIZED_SPLIT_IFFT_C2R: Hier noch die Normalisierung durchführen
if (m_type == ITAFFT::NORMALIZED_SPLIT_IFFT_C2R)
for (int i=0; i<m_size; i++) m_out[i] /= (float) m_size;
if( m_type == ITAFFT::NORMALIZED_SPLIT_IFFT_C2R )
for( int i = 0; i < m_size; i++ )
m_out[ i ] /= ( float ) m_size;
}
void FFTW3Realization::execute(float* in, float* out) {
if (m_inplace) {
if (in != out) ITA_EXCEPT1(INVALID_PARAMETER, "Attempt to execute in-place transform out-of-place");
} else {
if (in == out) ITA_EXCEPT1(INVALID_PARAMETER, "Attempt to execute out-of-place transform in-place");
void FFTW3Realization::execute( float* in, float* out )
{
if( m_inplace )
{
if( in != out ) ITA_EXCEPT1( INVALID_PARAMETER, "Attempt to execute in-place transform out-of-place" );
}
else
{
if( in == out ) ITA_EXCEPT1( INVALID_PARAMETER, "Attempt to execute out-of-place transform in-place" );
}
switch (m_type) {
switch( m_type )
{
case ITAFFT::FFT_R2C:
fftwf_execute_dft_r2c(m_plan, in, (fftwf_complex*) out);
fftwf_execute_dft_r2c( m_plan, in, ( fftwf_complex* ) out );
break;
case ITAFFT::IFFT_C2R:
fftwf_execute_dft_c2r(m_plan, (fftwf_complex*) in, out);
fftwf_execute_dft_c2r( m_plan, ( fftwf_complex* ) in, out );
break;
case ITAFFT::FFT_C2C:
case ITAFFT::IFFT_C2C:
fftwf_execute_dft(m_plan, (fftwf_complex*) in, (fftwf_complex*) out);
fftwf_execute_dft( m_plan, ( fftwf_complex* ) in, ( fftwf_complex* ) out );
break;
case ITAFFT::SPLIT_FFT_R2C:
fftwf_execute_split_dft_r2c(m_plan, in, out, (out+(m_size/2)+1));
fftwf_execute_split_dft_r2c( m_plan, in, out, ( out + ( m_size / 2 ) + 1 ) );
break;
case ITAFFT::SPLIT_IFFT_C2R:
fftwf_execute_split_dft_c2r(m_plan, in, (in+(m_size/2)+1), out);
fftwf_execute_split_dft_c2r( m_plan, in, ( in + ( m_size / 2 ) + 1 ), out );
break;
case ITAFFT::NORMALIZED_SPLIT_IFFT_C2R:
fftwf_execute_split_dft_c2r(m_plan, in, (in+(m_size/2)+1), out);
fftwf_execute_split_dft_c2r( m_plan, in, ( in + ( m_size / 2 ) + 1 ), out );
// Normalisierung durchführen
for (int i=0; i<m_size; i++) out[i] /= (float) m_size;
for( int i = 0; i < m_size; i++ ) out[ i ] /= ( float ) m_size;
break;
}
}
std::string FFTW3Realization::toString() {
std::string FFTW3Realization::toString()
{
return m_sInfo;
}
......@@ -150,12 +154,15 @@ std::string FFTW3Realization::toString() {
FFTW3Backend* FFTW3Backend::m_pInstance = NULL;
FFTW3Backend* FFTW3Backend::getInstance() {
if (m_pInstance == NULL) m_pInstance = new FFTW3Backend();
FFTW3Backend* FFTW3Backend::getInstance()
{
if( m_pInstance == NULL )
m_pInstance = new FFTW3Backend();
return m_pInstance;
}
ITAFFTRealization* FFTW3Backend::plan(int type, int size, float* in, float* out, unsigned int uiFlags) {
return new FFTW3Realization(type, size, in, out, uiFlags);
ITAFFTRealization* FFTW3Backend::plan( int type, int size, float* in, float* out, unsigned int uiFlags )
{
return new FFTW3Realization( type, size, in, out, uiFlags );
}
/*
* ITAFFT, eine Wrapper-Bibliothek fr schnelle Fouriertransformationen
* ----------------------------------------------------------------
*
* Autor: Frank Wefers (Frank.Wefers@akustik.rwth-aachen.de)
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2018
*
* (c) Copyright Institut fr Technische Akustik (ITA), RWTH Aachen
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
// $Id: FFTW3Backend.h,v 1.1 2009-12-14 10:19:17 fwefers Exp $
#ifndef INCLUDE_WATCHER_FFTW3_BACKEND
#define INCLUDE_WATCHER_FFTW3_BACKEND
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment