16 #ifndef R8BUTIL_INCLUDED 17 #define R8BUTIL_INCLUDED 32 return( 4.34294481903251828 * log( re * re + im * im + 1e-100 ));
50 double& prevg_log,
const double prec,
const double maxstep,
51 const double minstep = 1e-11 )
53 double curg_log = 4.34294481903251828 * log( curg + 1e-100 );
54 curg_log += ( prevg_log - curg_log ) * 0.7;
56 const double slope = fabs( curg_log - prevg_log );
62 step =
max(
min( step, maxstep ), minstep );
85 const int fltlen,
double& ming,
double& minth,
const double thend )
87 const double maxstep = minth * 2e-3;
105 const double curg = re * re + im * im;
141 const int fltlen,
double& maxg,
double& maxth,
const double thend )
143 const double maxstep = maxth * 1e-4;
144 double premaxth = maxth;
145 double premaxg = maxg;
146 double postmaxth = maxth;
147 double postmaxg = maxg;
149 double prevth = maxth;
151 double curth = maxth;
158 bool WasPeak =
false;
159 int AfterPeakCount = 0;
171 const double curg = re * re + im * im;
185 if( AfterPeakCount == 0 )
191 if( AfterPeakCount == 5 )
197 for( k = 0; k < 2; k++ )
199 double l = ( k == 0 ? premaxth : maxth );
200 double curgl = ( k == 0 ? premaxg : maxg );
201 double r = ( k == 0 ? maxth : postmaxth );
202 double curgr = ( k == 0 ? maxg : postmaxg );
206 const double c = ( l + r ) * 0.5;
210 const double curg = re * re + im * im;
271 const int fltlen,
const double maxg,
double& th,
const double thend )
280 const double c = ( l + r ) * 0.5;
291 const double curg = re * re + im * im;
306 #endif // R8BUTIL_INCLUDED void updateScanStep(double &step, const double curg, double &prevg_log, const double prec, const double maxstep, const double minstep=1e-11)
An utility function that performs frequency response scanning step update based on the current magnit...
Definition: r8butil.h:49
void findFIRFilterResponseMinLtoR(const double *const flt, const int fltlen, double &ming, double &minth, const double thend)
Function locates normalized frequency at which the minimum filter gain is reached.
Definition: r8butil.h:84
double convertResponseToLog(const double re, const double im)
Definition: r8butil.h:30
The "base" inclusion file with basic classes and functions.
void calcFIRFilterResponse(const double *flt, int fltlen, const double th, double &re0, double &im0, const int fltlat=0)
Function calculates frequency response of the specified FIR filter at the specified circular frequenc...
Definition: r8bbase.h:824
void findFIRFilterResponseMaxLtoR(const double *const flt, const int fltlen, double &maxg, double &maxth, const double thend)
Function locates normalized frequency at which the maximal filter gain is reached.
Definition: r8butil.h:140
T max(const T &v1, const T &v2)
Definition: r8bbase.h:1134
T min(const T &v1, const T &v2)
Definition: r8bbase.h:1118
#define M_PI
The macro equals to "pi" constant, fits 53-bit floating point mantissa.
Definition: r8bbase.h:94
void findFIRFilterResponseLevelRtoL(const double *const flt, const int fltlen, const double maxg, double &th, const double thend)
Function locates normalized frequency at which the specified maximum filter gain is reached...
Definition: r8butil.h:270
The "r8brain-free-src" library namespace.
Definition: CDSPBlockConvolver.h:21