I think the problem is more complex to solve it with the proposed fix. I used fftw3 enabled. The first picture show the plot with actual git code and the provided test case (4ms). The second is the modified code in com_fft. The signal landed in wrong bin. Both results show an amplitude error because dividing by wrong sample count.
Obviously the fft scale is buggy. We have to check this in different functions, not only in com_fft. BTW - one question to your proposal: span = time[length-1] - time[0]; if (length > 1) { span += time[1] - time[0]; } Why add the first interval instead using the last? span = time[length] - time[0];
Thanks for testing this problem. But your proposal gives for the pathological case length=1 still a span of 0.
Can't see the pictures. Former post was OK.
I think it has to be checked with gcc and msc++ too. And may be the originator of this library https://tesch1.gitlab.io/cppduals is a better address.
Can you please provide an exported netlist from xschem. It would make the life easier.
The structure of your testbench is unusual and wrong: control section and swept voltage source inside subckt. Please break down your testcase to a much simpler spice netlist to demonstrate your problem. Schematics and PDF doc's will not help. Attached is a similar script for gm-Id plot. Perhaps it helps.
Correct vgs assignment - bug found by K. OHara