Menu

#835 FFT normalization of regular (non-DC/nyquist) bins is wrong.

v1.0 (example)
open
nobody
None
5
2026-03-06
2026-03-03
No

ngspice calculates the normalization factor scale=N/2 using

int fpts = N/2+1
scale = (double) fpts - 1.0;

But of of course (double) ((int)N/2) does not equal ((double)N)/2 when N is odd. This error is very small unless N is also small.

HeAttached is a netlist testcase, and a porposed patch to fix it.

2 Attachments

Discussion

  • geraldfournier

    geraldfournier - 2026-03-03

    This only applies to odd FFT.

     
  • geraldfournier

    geraldfournier - 2026-03-03

    Commit b522bcc6c correct Nyquist bin scaling for Green branch dwarning
    does not fix the bug.

    I provided a tested patch - which you didn't use.
    I provided a test for verifying the fix - which you didn't use to check your own fix.
    Why?

    You also labeled the fix as concerning the Green branch, when reality is that only FFTW has support for odd FFT.

     
  • geraldfournier

    geraldfournier - 2026-03-03

    Please revert b522bcc6c, and apply the patch I provided and tested.

     
  • geraldfournier

    geraldfournier - 2026-03-05

    I confirm that a31ac5420 fixed this issue.

     
  • geraldfournier

    geraldfournier - 2026-03-05

    dwarning, although I'm certainly glad you've started to use my patches, can you explain why you keep committing my patches and the fixes I identify under your own name rather than mine? it looks like you are taking credit for my work. Why?

     
  • Dietmar Warning

    Dietmar Warning - 2026-03-05

    No, I tried git apply and git am but both failed for unknown reasons. Perhaps a crossing with my commits the patch was not synchronize.
    I will try to revert or editing the commit.

     
  • Dietmar Warning

    Dietmar Warning - 2026-03-05

    Please generate an new patch next time from pre-master-46.
    I just resetted.

     
  • geraldfournier

    geraldfournier - 2026-03-05

    Thank you, I believe it was just an honest mistake.

    Please be more careful about giving proper credit in the future. There's little reward in doing free open-source work except credit.

     
  • Dietmar Warning

    Dietmar Warning - 2026-03-05

    I see on other computer that my reset and push --force has not brought the result even it was shown as successful. May be we can change it by cherry pick from pre-master to master.
    Normally the contributors work with own branches and make merge request's. That would be more safe and comfortable.

     

    Last edit: Dietmar Warning 2026-03-05
    • geraldfournier

      geraldfournier - 2026-03-06

      No need to rewrite git history. Please be more careful in the future. I'll rebase future patches as needed.

       

Log in to post a comment.

MongoDB Logo MongoDB