C-extension in Python -- returning results
Jive Dadson
jdadson at ix.netcom.com
Wed Nov 7 21:48:48 EST 2001
Have you tested this thing in a stand-alone C program on the same data
that's getting the failure under Python? I suspect your C code is
actually generating an indeterminant result. You can pepper your C code
with
assert(_finite(number));
That will assert false if "number" is not valid (NAN, INF, IND, or
whatever).
Just skimming over the C code, it appears that you are using Gaussian
elimination or some such technique. That probably won't get it.
Equations for fitting data to a polynomial are frequenlty
ill-conditioned. To have a fighting chance numerically, you probably
need to use singular value decomposition or some other more robust
technique. But even at that, the polynomial you finally get might be
alarmingly wild - not interpolating well at all. I suggest you might
want to re-think the model. Why a polynomial? Why specifically five
degrees? Is there some theoretical reason? You might consider using
some less parametrical approach like a neural network trained with
weight decay. Talk to the folks in sci.math.num-analysis. Also, the
folks in sci.stat.math are good at this sort of thing.
Jive
More information about the Python-list
mailing list