Skip to content

Commit d81c95c

Browse files
authored
Update polyvander.py
1 parent 1aae0bb commit d81c95c

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Interpolation/polyvander.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ def horner(x, a, k):
6363
Recursive Horner's rule
6464
6565
Evaluate efficiently the Vandermonde polynomial or its derivatives/antiderivatives.
66-
The vectorized version of this function, using numpy.vectorize, is used internally
67-
inside the polyvander function.
6866
6967
Parameters
7068
--------
@@ -80,8 +78,11 @@ def horner(x, a, k):
8078
Returns
8179
--------
8280
val : int, float, or complex
83-
The value of the k-th derivative/antiderivative of the polynomial given by at x.
81+
The value of the k-th derivative/antiderivative of the polynomial given by the coefficients a at x.
8482
"""
83+
if isinstance(x, list) or isinstance(x,tuple):
84+
x = np.asarray(x)/1.0
85+
8586
if type(x)==int:
8687
x /= 1.0
8788

@@ -98,7 +99,7 @@ def horner(x, a, k):
9899
val = np.full_like(x, factorial(k) * a[k])
99100
elif k == 0:
100101
if n==1:
101-
val = a[0]
102+
val = np.full_like(x, a[0])
102103
elif n==2:
103104
val = a[0] + x * a[1]
104105
else:
@@ -110,5 +111,3 @@ def horner(x, a, k):
110111
else:
111112
pass
112113
return val
113-
114-
vhorner = np.vectorize(horner, excluded=[1,2], signature='()->()')

0 commit comments

Comments
 (0)