fix wrong write and read in not allocated memory
This commit is contained in:
parent
b8a9ca9df4
commit
2377d3a64f
|
|
@ -355,11 +355,10 @@ com_psd(wordlist *wl)
|
|||
vec_new(f);
|
||||
freq = f->v_realdata;
|
||||
|
||||
for (i = 0; i < fpts; i++)
|
||||
#ifdef HAVE_LIBFFTW3
|
||||
for (i = 0; i <= fpts; i++)
|
||||
freq[i] = i*1./span;
|
||||
#else
|
||||
for (i = 0; i <= fpts; i++)
|
||||
freq[i] = i*1./span*length/N;
|
||||
#endif
|
||||
|
||||
|
|
@ -449,7 +448,7 @@ com_psd(wordlist *wl)
|
|||
#endif
|
||||
|
||||
printf("Total noise power up to Nyquist frequency %5.3e Hz:\n%e V^2 (or A^2), \nnoise voltage or current %e V (or A)\n",
|
||||
freq[fpts], noipower, sqrt(noipower));
|
||||
freq[fpts-1], noipower, sqrt(noipower));
|
||||
|
||||
/* smoothing with rectangular window of width "smooth",
|
||||
plotting V/sqrt(Hz) or I/sqrt(Hz) */
|
||||
|
|
@ -473,7 +472,7 @@ com_psd(wordlist *wl)
|
|||
}
|
||||
for (j = fpts-hsmooth; j < fpts; j++) {
|
||||
sum = 0.;
|
||||
for (jj = 0; jj < smooth; jj++)
|
||||
for (jj = 0; jj < hsmooth; jj++)
|
||||
sum += fdvec[i][j-hsmooth+jj].cx_real;
|
||||
sum /= (fpts - j + hsmooth - 1);
|
||||
reald[j] = (sqrt(sum)/scaling);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ f_alpha(int n_pts, int n_exp, double X[], double Q_d, double alpha)
|
|||
ha = alpha/2.0;
|
||||
// Q_d = sqrt(Q_d); /* find the deviation of the noise */
|
||||
#ifdef HAVE_LIBFFTW3
|
||||
length = 2 * (n_pts/2 + 1);
|
||||
length = n_pts + 2;
|
||||
#else
|
||||
length = n_pts;
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue