X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=include%2Ffilter.h;h=5527b3eaddabf57cd094809de8db781cf042d3e1;hb=27a474e0622ebb7229fd5705552021f63d8f932d;hp=19266a0edbce9e909d39bb127436f7de8a86fa68;hpb=00bead9fe7ab835c1584eac4ab586cc56742eaf3;p=ctsim.git diff --git a/include/filter.h b/include/filter.h index 19266a0..5527b3e 100644 --- a/include/filter.h +++ b/include/filter.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: filter.h,v 1.5 2000/06/30 02:03:27 kevin Exp $ +** $Id: filter.h,v 1.15 2000/07/20 11:17:31 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 @@ -28,6 +28,18 @@ #ifndef FILTER_H #define FILTER_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#ifdef HAVE_FFTW +#include +#include +#endif + +#include + + class SignalFilter { public: @@ -49,10 +61,12 @@ class SignalFilter { FILTER_METHOD_INVALID, FILTER_METHOD_CONVOLUTION, FILTER_METHOD_FOURIER, + FILTER_METHOD_FOURIER_TABLE, FILTER_METHOD_FFT, - FILTER_METHOD_FFT_ZEROPAD_2, - FILTER_METHOD_FFT_ZEROPAD_4, - FILTER_METHOD_FFT_ZEROPAD_6 +#if HAVE_FFTW + FILTER_METHOD_FFTW, + FILTER_METHOD_RFFTW, +#endif } FilterMethodID; typedef enum { @@ -61,43 +75,87 @@ class SignalFilter { DOMAIN_SPATIAL } DomainID; - static const char FILTER_ABS_BANDLIMIT_STR[]= "abs_bandlimit"; - static const char FILTER_ABS_SINC_STR[]= "abs_sinc"; - static const char FILTER_ABS_COS_STR[]= "abs_cos"; - static const char FILTER_ABS_HAMMING_STR[]= "abs_hamming"; - static const char FILTER_SHEPP_STR[]= "shepp"; - static const char FILTER_BANDLIMIT_STR[]= "bandlimit"; - static const char FILTER_SINC_STR[]= "sinc"; - static const char FILTER_COS_STR[]= "cos"; - static const char FILTER_HAMMING_STR[]= "hamming"; - static const char FILTER_TRIANGLE_STR[]= "triangle"; + // Filters + static const char FILTER_ABS_BANDLIMIT_STR[]; + static const char FILTER_ABS_SINC_STR[]; + static const char FILTER_ABS_COS_STR[]; + static const char FILTER_ABS_HAMMING_STR[]; + static const char FILTER_SHEPP_STR[]; + static const char FILTER_BANDLIMIT_STR[]; + static const char FILTER_SINC_STR[]; + static const char FILTER_COS_STR[]; + static const char FILTER_HAMMING_STR[]; + static const char FILTER_TRIANGLE_STR[]; + + static const char FILTER_ABS_BANDLIMIT_TITLE_STR[]; + static const char FILTER_ABS_SINC_TITLE_STR[]; + static const char FILTER_ABS_COS_TITLE_STR[]; + static const char FILTER_ABS_HAMMING_TITLE_STR[]; + static const char FILTER_SHEPP_TITLE_STR[]; + static const char FILTER_BANDLIMIT_TITLE_STR[]; + static const char FILTER_SINC_TITLE_STR[]; + static const char FILTER_COS_TITLE_STR[]; + static const char FILTER_HAMMING_TITLE_STR[]; + static const char FILTER_TRIANGLE_TITLE_STR[]; - static const char FILTER_METHOD_CONVOLUTION_STR[]= "convolution"; - static const char FILTER_METHOD_FOURIER_STR[]= "fourier"; - static const char FILTER_METHOD_FFT_STR[]= "fft"; - static const char FILTER_METHOD_FFT_ZEROPAD_2_STR[]="fft_zeropad2"; - static const char FILTER_METHOD_FFT_ZEROPAD_4_STR[]="fft_zeropad4"; - static const char FILTER_METHOD_FFT_ZEROPAD_6_STR[]="fft_zeropad6"; + // Filter Methods + static const char FILTER_METHOD_CONVOLUTION_STR[]; + static const char FILTER_METHOD_FOURIER_STR[]; + static const char FILTER_METHOD_FOURIER_TABLE_STR[]; + static const char FILTER_METHOD_FFT_STR[]; +#if HAVE_FFTW + static const char FILTER_METHOD_FFTW_STR[]; + static const char FILTER_METHOD_RFFTW_STR[]; +#endif + + static const char FILTER_METHOD_CONVOLUTION_TITLE_STR[]; + static const char FILTER_METHOD_FOURIER_TITLE_STR[]; + static const char FILTER_METHOD_FOURIER_TABLE_TITLE_STR[]; + static const char FILTER_METHOD_FFT_TITLE_STR[]; +#if HAVE_FFTW + static const char FILTER_METHOD_FFTW_TITLESTR[]; + static const char FILTER_METHOD_RFFTW_TITLE_STR[]; +#endif + + // Domains + static const char DOMAIN_FREQUENCY_STR[]; + static const char DOMAIN_SPATIAL_STR[]; - static const char DOMAIN_FREQUENCY_STR[]= "frequency"; - static const char DOMAIN_SPATIAL_STR[]= "spatial"; + static const char DOMAIN_FREQUENCY_TITLE_STR[]; + static const char DOMAIN_SPATIAL_TITLE_STR[]; - SignalFilter (const char* filterName, double bw, double xmin, double xmax, int n, double param, const char* domainName, const int numIntegral = 0); + SignalFilter (const char* filterName, const char* filterMethodName,double bw, double signalIncrement, int n, double param, const char* domainName, const int zeropad = 0, const int preinterpolationFactor = 1); - SignalFilter (const FilterID filt_type, double bw, double xmin, double xmax, int n, double param, const DomainID domain, const int numIntegral = 0); + SignalFilter (const FilterID filt_type, FilterMethodID filterMethodID, double bw, double signalIncrement, int n, double param, const DomainID domain, const int zeropad = 0, const int preinterpolationFactor = 1); - SignalFilter (const char* filterName, const char* domainName, double bw, double param, int numIntegral = 0); + SignalFilter (const char* filterName, const char* domainName, double bw, double param); ~SignalFilter (void); double* getFilter (void) const { return m_vecFilter; } + 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; } + bool fail(void) const {return m_fail;} const string& failMessage(void) const {return m_failMessage;} @@ -105,23 +163,41 @@ class SignalFilter { const string& nameDomain(void) const { return m_nameDomain;} const FilterID idFilter(void) const { return m_idFilter;} const DomainID idDomain(void) const { return m_idDomain;} + const double getFilterMin(void) const {return m_filterMin;} + const double getFilterMax(void) const {return m_filterMax;} + const double getFilterIncrement(void) const {return m_filterInc;} double response (double x); - static double spatialResponse (FilterID fType, double bw, double x, double param, int nIntegral = 0); + static double spatialResponse (FilterID fType, double bw, double x, double param); static double frequencyResponse (FilterID fType, double bw, double u, double param); - static double spatialResponseCalc (FilterID fType, double bw, double x, double param, int n); - static double spatialResponseAnalytic (FilterID fType, double bw, double x, double param); + static double spatialResponseCalc (FilterID fType, double bw, double x, double param, int nIntegral); + + static void setNumIntegral(int nIntegral) {N_INTEGRAL = nIntegral;} + private: double m_bw; - int m_nPoints; - double m_xmin; - double m_xmax; + 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; @@ -131,16 +207,24 @@ class SignalFilter { FilterMethodID m_idFilterMethod; DomainID m_idDomain; double m_filterParam; - int m_numIntegral; + int m_traceLevel; + int m_zeropad; + int m_nOutputPoints; + int m_preinterpolationFactor; - static FilterID convertFilterNameToID (const char* filterName); + static int N_INTEGRAL; + + static const bool haveAnalyticSpatial (const FilterID filterID); + static const FilterID convertFilterNameToID (const char* filterName); static const char* convertFilterIDToName (const FilterID filterID); + static const FilterMethodID convertFilterMethodNameToID (const char* filterMethodName); + static const char* convertFilterMethodIDToName (const FilterMethodID filterMethodID); static const DomainID convertDomainNameToID (const char* domainName); static const char* convertDomainIDToName (const DomainID domainID); - void init (const FilterID filt_type, double bw, double xmin, double xmax, int n, double param, const DomainID domain, const int numInt); + void init (const FilterID filt_type, const FilterMethodID filterMethod, double bw, double signalIncrement, int n, double param, const DomainID domain, const int zeropad, const int preInterpScale); -double spatialResponseCalc (double x, double param, int n) const; + double spatialResponseCalc (double x, double param) const; double spatialResponseAnalytic (double x, double param) const; @@ -153,5 +237,4 @@ double spatialResponseCalc (double x, double param, int n) const; }; - #endif