MCPcopy Create free account
hub / github.com/numpy/numpy / herme2poly

Function herme2poly

numpy/polynomial/hermite_e.py:143–197  ·  view source on GitHub ↗

Convert a Hermite series to a polynomial. Convert an array representing the coefficients of a Hermite series, ordered from lowest degree to highest, to an array of the coefficients of the equivalent polynomial (relative to the "standard" basis) ordered from lowest to highest de

(c)

Source from the content-addressed store, hash-verified

141
142
143def herme2poly(c):
144 """
145 Convert a Hermite series to a polynomial.
146
147 Convert an array representing the coefficients of a Hermite series,
148 ordered from lowest degree to highest, to an array of the coefficients
149 of the equivalent polynomial (relative to the "standard" basis) ordered
150 from lowest to highest degree.
151
152 Parameters
153 ----------
154 c : array_like
155 1-D array containing the Hermite series coefficients, ordered
156 from lowest order term to highest.
157
158 Returns
159 -------
160 pol : ndarray
161 1-D array containing the coefficients of the equivalent polynomial
162 (relative to the "standard" basis) ordered from lowest order term
163 to highest.
164
165 See Also
166 --------
167 poly2herme
168
169 Notes
170 -----
171 The easy way to do conversions between polynomial basis sets
172 is to use the convert method of a class instance.
173
174 Examples
175 --------
176 >>> from numpy.polynomial.hermite_e import herme2poly
177 >>> herme2poly([ 2., 10., 2., 3.])
178 array([0., 1., 2., 3.])
179
180 """
181 from .polynomial import polyadd, polysub, polymulx
182
183 [c] = pu.as_series([c])
184 n = len(c)
185 if n == 1:
186 return c
187 if n == 2:
188 return c
189 else:
190 c0 = c[-2]
191 c1 = c[-1]
192 # i is the current degree of c1
193 for i in range(n - 1, 1, -1):
194 tmp = c0
195 c0 = polysub(c[i - 2], c1*(i - 1))
196 c1 = polyadd(tmp, polymulx(c1))
197 return polyadd(c0, polymulx(c1))
198
199#
200# These are constant arrays are of integer type so as to be compatible

Callers

nothing calls this directly

Calls 3

polymulxFunction · 0.85
polysubFunction · 0.70
polyaddFunction · 0.70

Tested by

no test coverage detected