Enhancement-241 fixed an amplitude normalization that divided by the ZERO-PADDED transform size instead of the number of input samples -- in the `fft` COMMAND (frontend/com_fft.c). The identical mistake survived in maths/cmaths/cmath4.c, the vector-expression function reached by `let F = fft(v)`: a separate implementation of the same computation. Found by continuing the oracle campaign that produced E-241, and located with E-241's own discriminator, the DC bin. One signal, 4001 samples padded to 4096, DC offset 2.0: fft s ; the COMMAND -> mag(s)[0] = 2.000000 correct let F = fft(s) ; the FUNCTION -> mag(F)[0] = 1.953613 = 2.0 * 4001/4096 X[0] is the sum of the samples, D*length for a DC offset D, so dividing by the padded N reads back D*length/N. As E-241 put it: a DC value cannot depend on how many samples were taken. This is a contradiction, not a matter of convention. cx_fft holds TWO complete implementations -- one for complex input, one for real -- and each has an FFTW branch and a Green's radix-2 branch. In BOTH, the FFTW branch already used the input length while Green's used the padded size: real branch FFTW: scale = ((double)length)/2.0 Green: ((double)N)/2 <- wrong complex branch FFTW: scale = (double) fpts Green: (double) N <- wrong the correct version sitting a few lines from the wrong one inside the same function -- the same shape as `avg` disagreeing with `integ` in E-302. HAVE_LIBFFTW3 is undefined in this build, so Green's is the live path and the defect was reachable. oracle before after closed form real-input, DC bin 1.953613 2.000000 2.0 real-input, ifft(fft(x)) 2.3e-02 1.1e-16 0 complex-input, bin 0 0.9766780 0.9998683 0.9998683 The round trip is an INDEPENDENT confirmation: nothing here touches ifft, so its going from 2.3% error to machine precision is evidence from a direction the fix did not aim at -- the pair only inverts when the forward normalization is right. cx_ifft was audited and deliberately left alone for that reason. Every caller of the Green's radix-2 kernel was audited, not only the one that failed: com_fft.c's fft (x2) and spec/PSD (x2) are correct from E-241; cx_ifft is correct; trannoise/1-f-code.c cannot pad at all, since n_pts is grown to 2^n_exp by construction; and fft/ifft are the only transform functions in the expression table, so there is no spec twin to miss. Verification: examples/fftexpr_examples/verify_fftexpr.py -- 6 checks under both solvers, all against closed form (DC bin on both paths, round trip padded and unpadded, complex-input bin 0 against the analytic mean of an RC response). It scores 3/6 on the pre-fix binary, so it is a real regression guard. E-241's own suite (fftnorm_examples) and ifftreal_examples pass unchanged. Full sweep 241/241 OK. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|---|---|---|
| examples | ||
| m4 | ||
| man | ||
| paranoia_parallel | ||
| src | ||
| tests | ||
| visualc | ||
| .gitattributes | ||
| .gitignore | ||
| ANALYSES | ||
| AUTHORS | ||
| BUGS | ||
| COPYING | ||
| ChangeLog | ||
| DEVICES | ||
| Dockerfile | ||
| FAQ | ||
| INSTALL | ||
| INTERNALS | ||
| Install-Ubuntu.txt | ||
| Makefile.am | ||
| NEWS | ||
| README | ||
| README.SEEgenerator | ||
| README.cpl-gc | ||
| README.optran | ||
| README.shared-xspice | ||
| README.tcl | ||
| README.utf8 | ||
| README.vdmos | ||
| README.wavsim | ||
| README_OSDI.md | ||
| README_OSDI_howto | ||
| Stuarts_Poly_Notes | ||
| autogen.sh | ||
| build-for-mac-os.sh | ||
| compile_cyg_make_short_check_64.sh | ||
| compile_linux.sh | ||
| compile_linux_dist.sh | ||
| compile_linux_shared.sh | ||
| compile_macos_clang.sh | ||
| compile_macos_clang_M2.sh | ||
| compile_macos_clang_M2_shared.sh | ||
| compile_macos_gcc.sh | ||
| compile_macos_shared.sh | ||
| compile_min.sh | ||
| compile_min_shared.sh | ||
| configure.ac | ||
| cross-compile-shared.sh | ||
| cross-compile.sh | ||
| ngspice.pc.in | ||
README
README for NGSPICE ================== Ngspice is a mixed-level/mixed-signal circuit simulator. Its code is based on three open source software packages: Spice3f5, Cider1b1 and Xspice. Spice3 does not need any introduction, it is the ancestor of many commercial or open source circuit simulators. In over 30 years since its existence it has set several de-facto standards for simulating circuits. Cider couples the Spice3 circuit level simulator to a device simulator to provide greater simulation accuracy of critical devices. So you may create device models for diodes, bipolar, JFet and MOSFETs derived from their cross-sectional structures and materials. Xspice is an extension to Spice3 that provides code modelling support and simulation of digital components through an embedded event driven algorithm. Ngspice is, anyway, much more than the simple sum of the packages above, as many people contributed to the project with their experience, their bug fixes and their improvements. If you are interested, browse the site and discover what ngspice offers and what needs. If you think you can help, join the development team. Ngspice is an ongoing project, growing everyday from users contributions, suggestions and reports. What we will be able to do depends mostly on user interests, contributions and feedback. USER DISCUSSION FORUMS: ----------------------- For discussions on ngspice, there are five discussion forums, to be found at https://sourceforge.net/p/ngspice/discussion/. These typically provide quick answers to any question concerning ngspice. A new section on 'tips and examples' assembles useful tips provided by maintainers and users. MAILING LISTS: ------------- There are two mailing lists dedicated to the use and development of ngspice. * ngspice-users@lists.sourceforge.net: This list is the list for the users of the ngspice simulator. * ngspice-devel@lists.sourceforge.net: ngspice development issues. Developers and "want to be" developers should subscribe here. To subscribe the list(s), send a message to: <ngspice-users-subscribe@lists.sourceforge.net> <ngspice-devel-subscribe@lists.sourceforge.net> WEB SITEs: -------- This project is hosted on Sourceforge.net. The home page is https://ngspice.sourceforge.io The page offering source code, MS Windows executables, and user interaction is https://sourceforge.net/projects/ngspice