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

first operating version

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.
tested in forward direction


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 2378
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 1b48fef8
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: fftwaff.cc,v 1.5 2007-09-12 10:26:33 tforb Exp $
* $Id: fftwaff.cc,v 1.6 2007-09-12 10:57:50 tforb Exp $
* \author Thomas Forbriger
* \date 11/07/2006
*
......@@ -20,7 +20,7 @@
#define TF_FFTWAFF_CC_VERSION \
"TF_FFTWAFF_CC V1.1"
#define TF_FFTWAFF_CC_CVSID \
"$Id: fftwaff.cc,v 1.5 2007-09-12 10:26:33 tforb Exp $"
"$Id: fftwaff.cc,v 1.6 2007-09-12 10:57:50 tforb Exp $"
#include <fourier/fftwaff.h>
#include <fourier/error.h>
......@@ -28,6 +28,7 @@
#include <tfxx/misc.h>
#include <aff/seriesoperators.h>
#include <aff/dump.h>
#include <cmath>
namespace fourier {
......@@ -67,9 +68,31 @@ namespace fourier {
//! delete plan.
DRFFTWAFF::~DRFFTWAFF()
{
this->delete_plans();
} // DRFFTWAFF::~DRFFTWAFF()
/*----------------------------------------------------------------------*/
//! prepare FFT settings for size n.
void DRFFTWAFF::set_size(const int& n) const
{
if (n != Msize)
{
Msize=n;
this->delete_plans();
}
} // DRFFTWAFF::~DRFFTWAFF()
/*----------------------------------------------------------------------*/
//! delete plans.
void DRFFTWAFF::delete_plans() const
{
if (Mplan_forward != 0) { rfftw_destroy_plan(Mplan_forward); }
if (Mplan_backward != 0) { rfftw_destroy_plan(Mplan_backward); }
Mplan_forward=0;
Mplan_backward=0;
} // DRFFTWAFF::~DRFFTWAFF()
/*----------------------------------------------------------------------*/
......@@ -81,10 +104,7 @@ namespace fourier {
DRFFTWAFF::Tspectrum DRFFTWAFF::operator()(const Tseries::Tcoc& s,
const bool& debug) const
{
TFXX_debug(debug, "DRFFTWAFF::operator()",
"check size of input series: "
<< s.size() << " == " << Msize);
FOURIER_assert(int(s.size()) == Msize, "series has wrong size!");
this->set_size(s.size());
Tspectrum retval(this->Msize/2+1);
aff::Series<fftw_real> out(this->Msize);
aff::Series<fftw_real> in(this->Msize);
......@@ -134,9 +154,14 @@ namespace fourier {
DRFFTWAFF::Tseries DRFFTWAFF::operator()(const Tspectrum::Tcoc& s,
const bool& debug) const
{
FOURIER_assert(int(s.size()) == (Msize+1/2),
"array of Fourier coefficients has wrong size!");
Tseries retval;
// adjust FFT size
int seriessize=s.size()*2-1;
// is Nyquits coefficients real?
if (std::abs(s(s.size()).imag()) < 1.e-8*std::abs(s(s.size()).real()))
{ --seriessize; }
this->set_size(seriessize);
Tseries retval(Msize);
aff::Series<fftw_real> out(Msize);
aff::Series<fftw_real> in(Msize);
fftw_real* pout=out.pointer();
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: fftwaff.h,v 1.4 2007-09-12 10:26:34 tforb Exp $
* $Id: fftwaff.h,v 1.5 2007-09-12 10:57:50 tforb Exp $
* \author Thomas Forbriger
* \date 11/07/2006
*
......@@ -26,7 +26,7 @@
#define TF_FFTWAFF_H_VERSION \
"TF_FFTWAFF_H V1.1"
#define TF_FFTWAFF_H_CVSID \
"$Id: fftwaff.h,v 1.4 2007-09-12 10:26:34 tforb Exp $"
"$Id: fftwaff.h,v 1.5 2007-09-12 10:57:50 tforb Exp $"
#include<complex>
#include<drfftw.h>
......@@ -43,6 +43,16 @@ namespace fourier {
* uses real double arrays
*
* How to use this class:
*
* You may create one instance of this class and use it to transform
* several signals in both directions in turn. The class itself takes care
* of the transform size and creates a new plan if necessary. FFTs are
* invoked by the bracket operators. You should use the class object like
* a function. The scaling operators (taking the sampling interval as one
* of their arguments) return a series or spectrum scaled appropriately to
* match the values of samples from the corresponding Fourier integral
* transform (usual convention with \f$dt\f$ and \f$df\f$
* integrals - not \f$d \omega\f$).
*/
class DRFFTWAFF {
public:
......@@ -52,6 +62,8 @@ namespace fourier {
typedef aff::Series<Tcoeff> Tspectrum;
DRFFTWAFF(const int& n):
Msize(n), Mplan_forward(0), Mplan_backward(0) { }
DRFFTWAFF():
Msize(0), Mplan_forward(0), Mplan_backward(0) { }
~DRFFTWAFF();
Tspectrum operator()(const Tseries::Tcoc& s,
const bool& debug=false) const;
......@@ -69,7 +81,9 @@ namespace fourier {
private:
void create_plan_forward() const;
void create_plan_backward() const;
int Msize;
void delete_plans() const;
void set_size(const int& n) const;
mutable int Msize;
mutable rfftw_plan Mplan_forward;
mutable rfftw_plan Mplan_backward;
}; // class DRFFTWAFF
......
Supports Markdown
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