mirror of
https://github.com/mborgerding/kissfft.git
synced 2026-08-30 13:57:04 -04:00
Fix Medium Severity Coverity finding:
CWE-369 (Division or modulo by float zero) (https://cwe.mitre.org/data/definitions/369.html)
This commit is contained in:
+7
-1
@@ -25,6 +25,11 @@ using namespace std;
|
|||||||
template <class T>
|
template <class T>
|
||||||
void dotest(int nfft)
|
void dotest(int nfft)
|
||||||
{
|
{
|
||||||
|
if (nfft <= 0) {
|
||||||
|
cerr << "invalid nfft:" << nfft << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
typedef kissfft<T> FFT;
|
typedef kissfft<T> FFT;
|
||||||
typedef std::complex<T> cpx_type;
|
typedef std::complex<T> cpx_type;
|
||||||
|
|
||||||
@@ -59,7 +64,8 @@ void dotest(int nfft)
|
|||||||
complex<long double> dif = acc - x;
|
complex<long double> dif = acc - x;
|
||||||
difpower += norm(dif);
|
difpower += norm(dif);
|
||||||
}
|
}
|
||||||
cout << " RMSE:" << sqrt(difpower/totalpower) << "\t";
|
const long double denom = (totalpower > 0) ? totalpower : 1e-30L;
|
||||||
|
cout << " RMSE:" << sqrt(difpower/denom) << "\t";
|
||||||
|
|
||||||
double t0 = curtime();
|
double t0 = curtime();
|
||||||
int nits=20e6/nfft;
|
int nits=20e6/nfft;
|
||||||
|
|||||||
Reference in New Issue
Block a user