Commit 04f648f7 authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

new module

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 2155
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent eb78ffc5
# this is <Makefile>
# ----------------------------------------------------------------------------
# $Id: Makefile,v 1.6 2005-07-05 08:21:13 tforb Exp $
# $Id: Makefile,v 1.7 2006-07-12 06:14:17 tforb Exp $
#
# Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
#
......@@ -127,7 +127,7 @@ HEADERS=$(shell find . -name \*.h)
# in the binary version of the library
# (see below for the configuration of a preinstantiated version of template
# code)
SRC=fcommand.cc filter.cc polesnzeroes.cc
SRC=fcommand.cc filter.cc polesnzeroes.cc fftwaff.cc
# test programs are placed in a subdirectory
TESTS=$(wildcard tests/*.cc)
# whereever we find a README, we will use it
......
/*! \file fftwaff.cc
* \brief use fftw together with aff containers (implementation)
*
* ----------------------------------------------------------------------------
*
* $Id: fftwaff.cc,v 1.1 2006-07-12 06:14:18 tforb Exp $
* \author Thomas Forbriger
* \date 11/07/2006
*
* use fftw together with aff containers (implementation)
*
* Copyright (c) 2006 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 11/07/2006 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define TF_FFTWAFF_CC_VERSION \
"TF_FFTWAFF_CC V1.0 "
#define TF_FFTWAFF_CC_CVSID \
"$Id: fftwaff.cc,v 1.1 2006-07-12 06:14:18 tforb Exp $"
#include <fourier/fftwaff.h>
#include <tfxx/error.h>
#include <aff/seriesoperators.h>
namespace fourier {
/*! All Fourier transform stuff is collected here.
*/
namespace fft {
//! create plan
void DRFFTWAFF::create_plan_forward() const
{
if (Mplan_forward==0)
{
Mplan_forward=rfftw_create_plan(Msize, FFTW_FORWARD, 0);
TFXX_assert(Mplan_forward!=0,
"Error (DRFFTWAFF::create_plan_forward): "
"could not create plan!")
}
} // void DRFFTWAFF::create_plan_forward() const
/*----------------------------------------------------------------------*/
//! create plan
void DRFFTWAFF::create_plan_backward() const
{
if (Mplan_backward==0)
{
Mplan_backward=rfftw_create_plan(Msize, FFTW_FORWARD, 0);
TFXX_assert(Mplan_backward!=0,
"Error (DRFFTWAFF::create_plan_backward): "
"could not create plan!")
}
} // void DRFFTWAFF::create_plan_backward() const
/*----------------------------------------------------------------------*/
//! delete plan
DRFFTWAFF::~DRFFTWAFF()
{
if (Mplan_forward != 0) { rfftw_destroy_plan(Mplan_forward); }
if (Mplan_backward != 0) { rfftw_destroy_plan(Mplan_backward); }
} // DRFFTWAFF::~DRFFTWAFF()
/*----------------------------------------------------------------------*/
DRFFTWAFF::Tspectrum DRFFTWAFF::operator()(const Tseries::Tcoc& s) const
{
Tspectrum retval(this->Msize/2+1);
aff::Series<fftw_real> out(this->Msize);
aff::Series<fftw_real> in(this->Msize);
fftw_real* pout=out.pointer();
fftw_real* pin=in.pointer();
in.copyin(s);
this->create_plan_forward();
rfftw_one(Mplan_forward, pin, pout);
retval(0)=out(0);
for (int i=1; i<((Msize+1)/2); ++i)
{
retval(i)=Tcoeff(out(i),out(Msize-i));
}
if ((Msize % 2) == 0)
{
retval(Msize/2)=out(Msize/2);
}
return(retval);
} // Tspectrum DRFFTWAFF::operator()(const Tseries::Tcoc& s) const
/*----------------------------------------------------------------------*/
DRFFTWAFF::Tseries DRFFTWAFF::operator()(const Tspectrum::Tcoc& s) const
{
Tseries retval;
aff::Series<fftw_real> out(Msize);
aff::Series<fftw_real> in(Msize);
fftw_real* pout=out.pointer();
fftw_real* pin=in.pointer();
in(0)=s(0).real();
for (int i=1; i<((Msize+1)/2); ++i)
{
in(i)=s(i).real();
in(Msize-i)=s(i).imag();
}
if ((Msize % 2) == 0)
{
in(Msize/2)=s(Msize/2).real();
}
this->create_plan_backward();
rfftw_one(Mplan_backward, pin, pout);
retval.copyin(out);
return(retval);
} // Tseries DRFFTWAFF::operator()(const Tspectrum::Tcoc& s) const
/*----------------------------------------------------------------------*/
DRFFTWAFF::Tsample DRFFTWAFF::scale_series(const Tsample& dt) const
{
return(1./(Msize*dt));
} // Tsample DRFFTWAFF::scale_series(const Tsample& dt) const
/*----------------------------------------------------------------------*/
DRFFTWAFF::Tsample DRFFTWAFF::scale_spectrum(const Tsample& dt) const
{
return(dt);
} // Tsample DRFFTWAFF::scale_spectrum(const Tsample& dt) const
/*----------------------------------------------------------------------*/
DRFFTWAFF::Tspectrum
DRFFTWAFF::operator()(const Tseries::Tcoc& s,
const double& dt) const
{
Tspectrum retval=this->operator()(s);
retval *= this->scale_spectrum(dt);
return(retval);
}
/*----------------------------------------------------------------------*/
DRFFTWAFF::Tseries
DRFFTWAFF::operator()(const Tspectrum::Tcoc& s,
const double& dt) const
{
return(this->scale_series(dt)*
this->operator()(s));
}
} // namespace ftt
} // namespace fourier
/* ----- END OF fftwaff.cc ----- */
/*! \file fftwaff.h
* \brief use fftw together with aff containers (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: fftwaff.h,v 1.1 2006-07-12 06:14:18 tforb Exp $
* \author Thomas Forbriger
* \date 11/07/2006
*
* use fftw together with aff containers (prototypes)
*
* link with -lrfftw -lfftw -lm -laff
*
* Copyright (c) 2006 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 11/07/2006 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef TF_FFTWAFF_H_VERSION
#define TF_FFTWAFF_H_VERSION \
"TF_FFTWAFF_H V1.0 "
#define TF_FFTWAFF_H_CVSID \
"$Id: fftwaff.h,v 1.1 2006-07-12 06:14:18 tforb Exp $"
#include<complex>
#include<rfftw.h>
#include<aff/series.h>
namespace fourier {
/*! All Fourier transform stuff is collected here.
*/
namespace fft {
/*! A rigid class to do simple transforms using libdrfftw.a
*
* uses real double arrays
*/
class DRFFTWAFF {
public:
typedef double Tsample;
typedef std::complex<Tsample> Tcoeff;
typedef aff::Series<Tsample> Tseries;
typedef aff::Series<Tcoeff> Tspectrum;
DRFFTWAFF(const int& n):
Msize(n), Mplan_forward(0), Mplan_backward(0) { }
~DRFFTWAFF();
Tspectrum operator()(const Tseries::Tcoc& s) const;
Tseries operator()(const Tspectrum::Tcoc& s) const;
Tspectrum operator()(const Tseries::Tcoc& s, const Tsample& dt) const;
Tseries operator()(const Tspectrum::Tcoc& s, const Tsample& dt) const;
Tsample scale_series(const Tsample& dt) const;
Tsample scale_spectrum(const Tsample& dt) const;
int size() const { return(Msize); }
private:
void create_plan_forward() const;
void create_plan_backward() const;
int Msize;
mutable rfftw_plan Mplan_forward;
mutable rfftw_plan Mplan_backward;
}; // class DRFFTWAFF
} // namespace ftt
} // namespace fourier
#endif // TF_FFTWAFF_H_VERSION (includeguard)
/* ----- END OF fftwaff.h ----- */
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