5 #ifndef BALL_MATHS_TFFT1D_H 6 #define BALL_MATHS_TFFT1D_H 8 #ifndef BALL_COMMON_EXCEPTION_H 12 #ifndef BALL_DATATYPE_REGULARDATA1D_H 36 template <
typename ComplexTraits>
38 :
public TRegularData1D<std::complex<typename ComplexTraits::ComplexPrecision> >
42 typedef std::complex<typename ComplexTraits::ComplexPrecision>
Complex;
67 TFFT1D(
Size ldn,
double stepPhys = 1.,
double origin = 0.,
bool inFourierSpace =
false);
169 Complex
getData(
const double pos)
const;
186 void setData(
double pos, Complex val);
200 const Complex&
operator [] (
const double pos)
const;
240 Complex
phase(
const double pos)
const;
284 template <
typename ComplexTraits>
295 template <
typename ComplexTraits>
315 for (
double pos=min; pos<=
max; pos+=step)
329 template <
typename ComplexTraits>
350 template <
typename ComplexTraits>
371 template <
typename ComplexTraits>
377 template <
typename ComplexTraits>
383 template <
typename ComplexTraits>
389 template <
typename ComplexTraits>
395 template <
typename ComplexTraits>
401 template <
typename ComplexTraits>
407 template <
typename ComplexTraits>
413 template <
typename ComplexTraits>
420 template <
typename ComplexTraits>
459 template <
typename ComplexTraits>
463 double normalization=1.;
467 result = (*this)[pos];
472 result = (*this)[pos]*
phase(pos);
477 result *= normalization;
482 template <
typename ComplexTraits>
491 if ((pos < min) || (pos > max))
496 double h = pos -
min;
497 double mod = fmod(h,step);
504 double before =
floor(h/step)*step+
min;
505 double after = ceil(h/step)*step+
min;
507 double t = (pos - before)/step;
509 result =
getData(before)*(
typename ComplexTraits::ComplexPrecision)(1.-t);
510 result +=
getData(after)*(
typename ComplexTraits::ComplexPrecision)t;
515 template <
typename ComplexTraits>
521 dummy =
Complex(val.real()*((
typename ComplexTraits::ComplexPrecision)pow((
typename ComplexTraits::ComplexPrecision)(
length_),(
int)
numFourierToPhys_)),
522 val.imag()*((
typename ComplexTraits::ComplexPrecision)pow((
typename ComplexTraits::ComplexPrecision)(
length_),(
int)
numFourierToPhys_)));
529 *(
typename ComplexTraits::ComplexPrecision)pow((
typename ComplexTraits::ComplexPrecision)
length_,(
int)
numFourierToPhys_);
537 template <
typename ComplexTraits>
556 if ((internalPos < 0) || (internalPos>=(
Index)
length_))
564 template <
typename ComplexTraits>
583 if ((internalPos < 0) || (internalPos>=(
Index)
length_))
591 template <
typename ComplexTraits>
602 template <
typename ComplexTraits>
673 template <
typename ComplexTraits>
674 const RegularData1D& operator << (RegularData1D& to, const TFFT1D<ComplexTraits>& from)
677 if (!from.isInFourierSpace())
680 Size lengthX = from.getMaxIndex()+1;
683 newGrid.
setOrigin(from.getPhysSpaceMin());
684 newGrid.
setDimension(from.getPhysSpaceMax()-from.getPhysSpaceMin());
687 double normalization = 1./(pow((
float)(lengthX),from.getNumberOfInverseTransforms()));
689 for (
Position i = 0; i < from.size(); i++)
691 newGrid[i] = from[i].real()*normalization;
703 Size lengthX = from.getMaxIndex()+1;
705 float stepFourierX = from.getFourierStepWidth();
708 newGrid.
setOrigin(from.getFourierSpaceMin());
709 newGrid.
setDimension(from.getFourierSpaceMax()-from.getFourierSpaceMin());
713 double normalization=1./sqrt(2.*
Constants::PI)/(pow((
float)(lengthX),from.getNumberOfInverseTransforms()));
719 for (
Position i = 0; i < from.size(); i++)
732 x-=(int)(lengthX/2.);
736 x+=(int)(lengthX/2.);
740 r = ((
float)xp * stepFourierX);
742 newGrid[i] = (from[i]*(
typename ComplexTraits::ComplexPrecision)normalization*from.phase(r)).real();
751 #endif // BALL_MATHS_TFFT1D_H
BALL_INLINE void setOrigin(const CoordinateType &origin)
T max(const T &a, const T &b)
Complex getData(const double pos) const
void setData(double pos, Complex val)
TFFT1D()
Default constructor.
const Complex & operator[](const Position &pos) const
ComplexTraits::FftwPlan planBackward_
Complex & operator[](const double pos)
ComplexTraits::FftwPlan planForward_
Complex getInterpolatedValue(const double pos) const
bool isInFourierSpace() const
double getPhysStepWidth() const
Complex phase(const double pos) const
double getPhysSpaceMax() const
T min(const T &a, const T &b)
BALL_INLINE void setDimension(const CoordinateType &dimension)
Complex & operator[](const Position &pos)
void setNumberOfFFTTransforms(Size num)
double getFourierSpaceMin() const
TFFT1D< BALL_FFTW_DEFAULT_TRAITS > FFT1D
BALL_INLINE size_type size() const
BALL_EXTERN_VARIABLE const double PI
PI.
double rint(double x)
round to integral value in floating-point format
void setNumberOfiFFTTransforms(Size num)
bool setPhysStepWidth(double new_width)
const TFFT1D & operator=(const TFFT1D &fft1d)
Assignment operator.
bool translate(double trans_origin)
double getGridCoordinates(Position position) const
const ValueType & operator[](const IndexType &index) const
TRegularData1D< std::complex< typename ComplexTraits::ComplexPrecision > > ComplexVector
double getPhysSpaceMin() const
Size getNumberOfInverseTransforms() const
bool operator==(const TFFT1D &fft1d) const
double getFourierStepWidth() const
BALL_EXTERN_VARIABLE const double h
virtual ~TFFT1D()
Destructor.
double getFourierSpaceMax() const
std::complex< typename ComplexTraits::ComplexPrecision > Complex
#define BALL_CREATE(name)