[Numpy-discussion] polynomial with negative exponents
LASAGNA DAVIDE
davide.lasagna at polito.it
Mon Dec 12 09:04:56 EST 2011
Hi,
I have written a class for polynomials with negative
exponents like:
p(x) = a0 + a1*x**-1 + ... + an*x**-n
The code is this one:
class NegativeExpPolynomial( object ):
def __init__ ( self, coeffs ):
self.coeffs = np.array( coeffs )
def __call__( self, x ):
return sum( (c*x**(-i) for i, c in enumerate(
self.coeffs ) ) )
where coeffs = [a0, a1, ..., an].
I find that the way i evaluate the polynomial is kind of
*slow*, especially for polynomial with order larger than
~200 and for arrays x large enough.
Do you have suggestions on how to speed up this code?
Regards,
Davide Lasagna
--
Phd Student
Dipartimento di Ingegneria Aeronautica a Spaziale
Politecnico di Torino, Italy
tel: 011/0906871
e-mail: davide.lasagna at polito.it; lasagnadavide at gmail.com
More information about the NumPy-Discussion
mailing list