GeopsyCore/FastPartialFourierTransform.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of GeopsyCore.
00004 **
00005 **  This library is free software; you can redistribute it and/or
00006 **  modify it under the terms of the GNU Lesser General Public
00007 **  License as published by the Free Software Foundation; either
00008 **  version 2.1 of the License, or (at your option) any later version.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00013 **  License for more details.
00014 **
00015 **  You should have received a copy of the GNU Lesser General Public
00016 **  License along with this library; if not, write to the Free Software
00017 **  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 **
00019 **  See http://www.geopsy.org for more information.
00020 **
00021 **  Created : 2009-04-11
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (LGIT, Grenoble, France)
00025 **
00026 ***************************************************************************/
00027 
00028 #ifndef FASTPARTIALFOURIERTRANSFORM_H
00029 #define FASTPARTIALFOURIERTRANSFORM_H
00030 
00031 #if 0
00032 
00033 #include <QGpCoreTools.h>
00034 #include "ComplexSignal.h"
00035 
00036 namespace GeopsyCore {
00037 
00038 class FastPartialFourierTransformKey : public AbstractNumericalKey
00039 {
00040   DECLARE_NUMERICALKEY(FastPartialFourierTransformKey)
00041 public:
00042   enum Direction {Forward, Backward};
00043 
00044   FastPartialFourierTransformKey(double deltaT, int nInSamples, int mOutSamples, int startIndex, Direction direction) {
00045     _deltaT=deltaT;
00046     _nInSamples=nInSamples;
00047     _mOutSamples=mOutSamples;
00048     _startIndex=startIndex;
00049     _direction=direction;
00050   }
00051   virtual bool operator==(const AbstractNumericalKey& o) {
00052     const FastPartialFourierTransformKey& mo=static_cast<const FastPartialFourierTransformKey&>(o);
00053     return _deltaT==mo._deltaT &&
00054            _nInSamples==mo._nInSamples &&
00055            _mOutSamples==mo._mOutSamples &&
00056            _startIndex==mo._startIndex &&
00057            _direction==mo._direction;
00058   }
00059   virtual int hash() const {return (int)floor(1.0/_deltaT)+_nInSamples+_mOutSamples+_startIndex+_direction;}
00060   inline virtual AbstractNumericalCache * createCache();
00061   inline virtual int byteCount() const;
00062 
00063   double deltaT() const {return _deltaT;}
00064   int nInSamples() const {return _nInSamples;}
00065   int mOutSamples() const {return _mOutSamples;}
00066   int startIndex() const {return _startIndex;}
00067   Direction direction() const {return _direction;}
00068 private:
00069   double _deltaT;
00070   int _nInSamples, _mOutSamples, _startIndex;
00071   Direction _direction;
00072 };
00073 
00074 class FastPartialFourierTransform : public AbstractNumericalCache
00075 {
00076 public:
00077   FastPartialFourierTransform(FastPartialFourierTransformKey * key);
00078   ~FastPartialFourierTransform();
00079 
00080   static inline const FastPartialFourierTransform * begin(double deltaT, int nInSamples, int mOutSamples, int startIndex,
00081                                                               FastPartialFourierTransformKey::Direction direction);
00082   virtual void init();
00083 
00084   static ComplexSignal * forward(const DoubleSignal * inSig, int nInSamples, int mOutSamples, int startIndex);
00085   static ComplexSignal * backward(const DoubleSignal * inSig, int nInSamples, int mOutSamples, int startIndex);
00086 private:
00087   int inIndex(int i) const {return _inIndexes[i];}
00088   int outIndex(int i) const {return _outIndexes[i];}
00089   const Complex& zFactor(int i) const {return _zFactors[i];}
00090   const Complex& fzFactor(int i) const {return _fzFactors[i];}
00091 
00092   int * _inIndexes, * _outIndexes;
00093   Complex * _zFactors;
00094   Complex * _fzFactors;
00095 };
00096 
00097 inline AbstractNumericalCache * FastPartialFourierTransformKey::createCache( )
00098 {
00099   return new FastPartialFourierTransform(this);
00100 }
00101 
00102 inline const FastPartialFourierTransform * FastPartialFourierTransform::begin(double deltaT, int nInSamples, int mOutSamples, int startIndex,
00103                                                                                      FastPartialFourierTransformKey::Direction direction)
00104 {
00105   return static_cast<const FastPartialFourierTransform *>(
00106       AbstractNumericalCache::begin(new FastPartialFourierTransformKey(deltaT, nInSamples, mOutSamples, startIndex, direction) ));
00107 }
00108 
00109 inline int FastPartialFourierTransformKey::byteCount() const
00110 {
00111   return 2*_nInSamples*(sizeof(int)+sizeof(Complex));
00112 }
00113 
00114 } // namespace GeopsyCore
00115 
00116 #endif
00117 
00118 #endif // FASTPARTIALFOURIERTRANSFORM_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines