X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=include%2Ffilter.h;h=a0c4b4b15c57a7e627a51f4b15aec63026c06bb1;hb=d158a6da6ec776fe98961f73f2ea74cf55de4700;hp=274d7920443ec1f7b5a8e7d67db607eab0ac1042;hpb=a95e41ac40cd2f3a4401d921618604cf33f2a904;p=ctsim.git diff --git a/include/filter.h b/include/filter.h index 274d792..a0c4b4b 100644 --- a/include/filter.h +++ b/include/filter.h @@ -1,29 +1,212 @@ +/***************************************************************************** +** FILE IDENTIFICATION +** +** Name: filter.h +** Purpose: Signal filter header file +** Programmer: Kevin Rosenberg +** Date Started: June 2000 +** +** This is part of the CTSim program +** Copyright (C) 1983-2000 Kevin Rosenberg +** +** $Id: filter.h,v 1.18 2000/08/03 09:57:33 kevin Exp $ +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License (version 2) as +** published by the Free Software Foundation. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +******************************************************************************/ + +#ifndef FILTER_H +#define FILTER_H + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#ifdef HAVE_FFTW +#include +#include +#endif + +#include + + class SignalFilter { public: - SignalFilter (const FilterType filt_type, double bw, double xmin, double xmax, int n, double param, const DomainType domain, const int numInt); + static const int FILTER_INVALID; + static const int FILTER_ABS_BANDLIMIT; // filter times |x| + static const int FILTER_ABS_SINC; + static const int FILTER_ABS_G_HAMMING; + static const int FILTER_ABS_COSINE; + static const int FILTER_SHEPP; + static const int FILTER_BANDLIMIT; + static const int FILTER_SINC; + static const int FILTER_G_HAMMING; + static const int FILTER_COSINE; + static const int FILTER_TRIANGLE; + + static const int FILTER_METHOD_INVALID; + static const int FILTER_METHOD_CONVOLUTION; + static const int FILTER_METHOD_FOURIER; + static const int FILTER_METHOD_FOURIER_TABLE; + static const int FILTER_METHOD_FFT; +#if HAVE_FFTW + static const int FILTER_METHOD_FFTW; + static const int FILTER_METHOD_RFFTW; +#endif + + static const int DOMAIN_INVALID; + static const int DOMAIN_FREQUENCY; + static const int DOMAIN_SPATIAL; + + static const int FREQUENCY_FILTER_INVALID; + static const int FREQUENCY_FILTER_DIRECT_FREQUENCY; + static const int FREQUENCY_FILTER_INVERSE_SPATIAL; + + SignalFilter (const char* filterName, const char* filterMethodName,double bw, double signalIncrement, int n, double param, const char* domainName, const char* frequencyFilterName, const int zeropad = 0, const int preinterpolationFactor = 1); + + SignalFilter (const int filt_type, int filterMethodID, double bw, double signalIncrement, int n, double param, const int domain, int filterFilterID, const int zeropad = 0, const int preinterpolationFactor = 1); + + SignalFilter (const char* filterName, const char* domainName, double bw, double param); ~SignalFilter (void); double* getFilter (void) const { return m_vecFilter; } - double convolve (const double f[], const double dx, const int n, const int np, const FunctionSymmetry func_type) const; + int getNFilterPoints (void) const + { return m_nFilterPoints; } + + double convolve (const double f[], const double dx, const int n, const int np) const; + + double convolve (const float f[], const double dx, const int n, const int np) const; + + void filterSignal (const double input[], double output[]) const; + void filterSignal (const float input[], double output[]) const; + + static void finiteFourierTransform (const double input[], complex output[], const int n, const int direction); + static void finiteFourierTransform (const complex input[], complex output[], const int n, const int direction); + static void finiteFourierTransform (const complex input[], double output[], const int n, const int direction); + + void finiteFourierTransform (const double input[], complex output[], const int direction) const; + void finiteFourierTransform (const complex input[], complex output[], const int direction) const; + void finiteFourierTransform (const complex input[], double output[], const int direction) const; + + void setTraceLevel (int traceLevel) {m_traceLevel = traceLevel; } - double convolve (const float f[], const double dx, const int n, const int np, const FunctionSymmetry func_type) const; + bool fail(void) const {return m_fail;} + const string& failMessage(void) const {return m_failMessage;} - static double spatialResponseCalc (FilterType fType, double bw, double x, double param, int n); + const string& nameFilter(void) const { return m_nameFilter;} + const string& nameDomain(void) const { return m_nameDomain;} + const int idFilter(void) const { return m_idFilter;} + const int idDomain(void) const { return m_idDomain;} + const int idFrequencyFilter() const { return m_idFrequencyFilter;} + const double getFilterMin(void) const {return m_filterMin;} + const double getFilterMax(void) const {return m_filterMax;} + const double getFilterIncrement(void) const {return m_filterInc;} - static double spatialResponseAnalytic (FilterType fType, double bw, double x, double param); + double response (double x); - static double frequencyResponse (FilterType fType, double bw, double u, double param); + static double spatialResponse (int fType, double bw, double x, double param); + static double frequencyResponse (int fType, double bw, double u, double param); + + static double spatialResponseAnalytic (int fType, double bw, double x, double param); + + static double spatialResponseCalc (int fType, double bw, double x, double param, int nIntegral); + + static void setNumIntegral(int nIntegral) {N_INTEGRAL = nIntegral;} + + static const int getFilterCount() {return s_iFilterCount;} + static const char** getFilterNameArray() {return s_aszFilterName;} + static const char** getFilterTitleArray() {return s_aszFilterTitle;} + static int convertFilterNameToID (const char* const filterName); + static const char* convertFilterIDToName (const int idFilter); + static const char* convertFilterIDToTitle (const int idFilter); + + static const int getFilterMethodCount() {return s_iFilterMethodCount;} + static const char** getFilterMethodNameArray() {return s_aszFilterMethodName;} + static const char** getFilterMethodTitleArray() {return s_aszFilterMethodTitle;} + static int convertFilterMethodNameToID (const char* const filterMethodName); + static const char* convertFilterMethodIDToName (const int idFilterMethod); + static const char* convertFilterMethodIDToTitle (const int idFilterMethod); + + static const int getDomainCount() {return s_iDomainCount;} + static const char** getDomainNameArray() {return s_aszDomainName;} + static const char** getDomainTitleArray() {return s_aszDomainTitle;} + static int convertDomainNameToID (const char* const domainName); + static const char* convertDomainIDToName (const int idDomain); + static const char* convertDomainIDToTitle (const int idDomain); + static int convertFrequencyFilterNameToID (const char* const ffName); + static const char* convertFrequencyFilterIDToName (const int idFF); + static const char* convertFrequencyFilterIDToTitle (const int idFF); + private: - double *m_vecFilter; double m_bw; - FilterType m_filterType; - - double spatialResponseCalc (double x, double param, int n) const; + int m_nFilterPoints; + int m_nSignalPoints; + double m_signalInc; + double m_filterMin; + double m_filterMax; + double m_filterInc; + double* m_vecFilter; + double* m_vecFourierCosTable; + double* m_vecFourierSinTable; + complex* m_complexVecFilter; +#ifdef HAVE_FFTW + fftw_real* m_vecRealFftInput, *m_vecRealFftSignal; + rfftw_plan m_realPlanForward, m_realPlanBackward; + fftw_complex* m_vecComplexFftInput, *m_vecComplexFftSignal; + fftw_plan m_complexPlanForward, m_complexPlanBackward; +#endif + + bool m_fail; + string m_failMessage; + string m_nameFilter; + string m_nameFilterMethod; + string m_nameDomain; + string m_nameFrequencyFilter; + int m_idFilter; + int m_idFilterMethod; + int m_idFrequencyFilter; + int m_idDomain; + double m_filterParam; + int m_traceLevel; + int m_zeropad; + int m_nOutputPoints; + int m_preinterpolationFactor; + + static const char* s_aszFilterName[]; + static const char* s_aszFilterTitle[]; + static const int s_iFilterCount; + static const char* s_aszFilterMethodName[]; + static const char* s_aszFilterMethodTitle[]; + static const int s_iFilterMethodCount; + static const char* s_aszDomainName[]; + static const char* s_aszDomainTitle[]; + static const int s_iDomainCount; + static const char* s_aszFrequencyFilterName[]; + static const char* s_aszFrequencyFilterTitle[]; + static const int s_iFrequencyFilterCount; + + static int N_INTEGRAL; + + static const bool haveAnalyticSpatial (const int filterID); + + void init (const int filt_type, const int filterMethod, double bw, double signalIncrement, int n, double param, const int domain, const int frequencyFilter, const int zeropad, const int preInterpScale); + + double spatialResponseCalc (double x, double param) const; double spatialResponseAnalytic (double x, double param) const; @@ -36,3 +219,4 @@ class SignalFilter { }; +#endif