[ng-spice-bugs] Bug in polyfit.c (fwd)


To ng-spice-devel@ieee.ing.uniroma1.it
From Paolo Nenzi <pnenzi@ieee.ing.uniroma1.it>
Date Fri, 13 Oct 2000 12:09:53 +0200 (CEST)
Delivered-To mailing list ng-spice-devel@ieee.ing.uniroma1.it
Mailing-List contact ng-spice-devel-help@ieee.ing.uniroma1.it; run by ezmlm
Reply-To ng-spice-devel@ieee.ing.uniroma1.it

Oops,

I think I did not noticed this message.

---------- Forwarded message ----------
Date: Sat, 30 Sep 2000 01:03:37 +0200
From: Daniele Gordini <dgordini@guest.deis.unibo.it>
Reply-To: ng-spice-bugs@ieee.ing.uniroma1.it
To: ng-spice-bugs@ieee.ing.uniroma1.it
Subject: [ng-spice-bugs] Bug in polyfit.c

Hello! 

I've found a little bug in ng-spice-rework-12.

Using the Fourier Analysis all the magnitudes of the
harmonic components are calculated as zero, so most of
the results show up as a meaningless NAN.
I've traced the bug to line 20 of the utility file
"src/maths/poly/polyfit.c", which reads:

memcpy((char *) ydata, (char *) mat2, n * sizeof
(double));

which is incorrect, it should be:

memcpy((char *) mat2, (char *) ydata, n * sizeof (double));

i.e. source and destination of the "memcpy" are swapped.
This causes the zeroing of the input data before the
data has a chance of being used.

Thank you for your job!

Best regards,
D. Gordini


Partial thread listing: