ó 2ÄÈ[c@`s^dZddlmZmZmZddlZddlZddlj Z ddl m Z ddl mZddlmZdd d d d d ddddddddddddddddddd d!d"d#d$d%d&gZejZd'„Zd(„Zejd)dgƒZejdgƒZejdgƒZejddgƒZd*„Zd+„Zd,„Zd-„Zd.„Z d/„Z!d0„Z"d1d2„Z#dddd3„Z$dgdddd4„Z%e&d5„Z'd6„Z(d7„Z)d8„Z*d9„Z+d:„Z,d;„Z-d<„Z.de0dd=„Z1d>„Z2d?„Z3d@„Z4dA„Z5dB„Z6defdC„ƒYZ7dS(DsA Objects for dealing with Hermite_e series. This module provides a number of objects (mostly functions) useful for dealing with Hermite_e series, including a `HermiteE` class that encapsulates the usual arithmetic operations. (General information on how this module represents and works with such polynomials is in the docstring for its "parent" sub-package, `numpy.polynomial`). Constants --------- - `hermedomain` -- Hermite_e series default domain, [-1,1]. - `hermezero` -- Hermite_e series that evaluates identically to 0. - `hermeone` -- Hermite_e series that evaluates identically to 1. - `hermex` -- Hermite_e series for the identity map, ``f(x) = x``. Arithmetic ---------- - `hermemulx` -- multiply a Hermite_e series in ``P_i(x)`` by ``x``. - `hermeadd` -- add two Hermite_e series. - `hermesub` -- subtract one Hermite_e series from another. - `hermemul` -- multiply two Hermite_e series. - `hermediv` -- divide one Hermite_e series by another. - `hermeval` -- evaluate a Hermite_e series at given points. - `hermeval2d` -- evaluate a 2D Hermite_e series at given points. - `hermeval3d` -- evaluate a 3D Hermite_e series at given points. - `hermegrid2d` -- evaluate a 2D Hermite_e series on a Cartesian product. - `hermegrid3d` -- evaluate a 3D Hermite_e series on a Cartesian product. Calculus -------- - `hermeder` -- differentiate a Hermite_e series. - `hermeint` -- integrate a Hermite_e series. Misc Functions -------------- - `hermefromroots` -- create a Hermite_e series with specified roots. - `hermeroots` -- find the roots of a Hermite_e series. - `hermevander` -- Vandermonde-like matrix for Hermite_e polynomials. - `hermevander2d` -- Vandermonde-like matrix for 2D power series. - `hermevander3d` -- Vandermonde-like matrix for 3D power series. - `hermegauss` -- Gauss-Hermite_e quadrature, points and weights. - `hermeweight` -- Hermite_e weight function. - `hermecompanion` -- symmetrized companion matrix in Hermite_e form. - `hermefit` -- least-squares fit returning a Hermite_e series. - `hermetrim` -- trim leading coefficients from a Hermite_e series. - `hermeline` -- Hermite_e series of given straight line. - `herme2poly` -- convert a Hermite_e series to a polynomial. - `poly2herme` -- convert a polynomial to a Hermite_e series. Classes ------- - `HermiteE` -- A Hermite_e series class. See also -------- `numpy.polynomial` i(tdivisiontabsolute_importtprint_functionN(tnormalize_axis_indexi(t polyutils(t ABCPolyBaset hermezerothermeonethermext hermedomaint hermelinethermeaddthermesubt hermemulxthermemulthermedivthermepowthermevalthermederthermeintt herme2polyt poly2hermethermefromrootst hermevanderthermefitt hermetrimt hermerootstHermiteEt hermeval2dt hermeval3dt hermegrid2dt hermegrid3dt hermevander2dt hermevander3dthermecompaniont hermegausst hermeweightcC`setj|gƒ\}t|ƒd}d}x3t|ddƒD]}tt|ƒ||ƒ}q>W|S(sŠ poly2herme(pol) Convert a polynomial to a Hermite series. Convert an array representing the coefficients of a polynomial (relative to the "standard" basis) ordered from lowest degree to highest, to an array of the coefficients of the equivalent Hermite series, ordered from lowest to highest degree. Parameters ---------- pol : array_like 1-D array containing the polynomial coefficients Returns ------- c : ndarray 1-D array containing the coefficients of the equivalent Hermite series. See Also -------- herme2poly Notes ----- The easy way to do conversions between polynomial basis sets is to use the convert method of a class instance. Examples -------- >>> from numpy.polynomial.hermite_e import poly2herme >>> poly2herme(np.arange(4)) array([ 2., 10., 2., 3.]) iiiÿÿÿÿ(tput as_seriestlentrangeR R (tpoltdegtresti((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyRRs &c C`sãddlm}m}m}tj|gƒ\}t|ƒ}|dkrM|S|dkr]|S|d}|d}xXt|dddƒD]@}|}|||d||dƒ}||||ƒƒ}qˆW||||ƒƒSdS(s 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 degree. Parameters ---------- c : array_like 1-D array containing the Hermite series coefficients, ordered from lowest order term to highest. Returns ------- pol : ndarray 1-D array containing the coefficients of the equivalent polynomial (relative to the "standard" basis) ordered from lowest order term to highest. See Also -------- poly2herme Notes ----- The easy way to do conversions between polynomial basis sets is to use the convert method of a class instance. Examples -------- >>> from numpy.polynomial.hermite_e import herme2poly >>> herme2poly([ 2., 10., 2., 3.]) array([ 0., 1., 2., 3.]) i(tpolyaddtpolysubtpolymulxiiþÿÿÿiÿÿÿÿN(t polynomialR-R.R/R%R&R'R(( tcR-R.R/tntc0tc1R,ttmp((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyR€s&     iÿÿÿÿcC`s3|dkrtj||gƒStj|gƒSdS(sK Hermite series whose graph is a straight line. Parameters ---------- off, scl : scalars The specified line is given by ``off + scl*x``. Returns ------- y : ndarray This module's representation of the Hermite series for ``off + scl*x``. See Also -------- polyline, chebline Examples -------- >>> from numpy.polynomial.hermite_e import hermeline >>> from numpy.polynomial.hermite_e import hermeline, hermeval >>> hermeval(0,hermeline(3, 2)) 3.0 >>> hermeval(1,hermeline(3, 2)) 5.0 iN(tnptarray(tofftscl((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyR Ês cC`s t|ƒdkrtjdƒStj|gdtƒ\}|jƒg|D]}t| dƒ^qK}t|ƒ}x‰|dkrþt|dƒ\}}gt |ƒD]!}t |||||ƒ^q¤}|rït |d|dƒ|d>> from numpy.polynomial.hermite_e import hermefromroots, hermeval >>> coef = hermefromroots((-1, 0, 1)) >>> hermeval((-1, 0, 1), coef) array([ 0., 0., 0.]) >>> coef = hermefromroots((-1j, 1j)) >>> hermeval((-1j, 1j), coef) array([ 0.+0.j, 0.+0.j]) iittrimiiÿÿÿÿN( R'R6tonesR%R&tFalsetsortR tdivmodR(R(trootstrtpR2tmR,R5((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyRïs2  # 4 cC`sutj||gƒ\}}t|ƒt|ƒkrO||jc |7*|}n||jc |7*|}tj|ƒS(sæ Add one Hermite series to another. Returns the sum of two Hermite series `c1` + `c2`. The arguments are sequences of coefficients ordered from lowest order term to highest, i.e., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``. Parameters ---------- c1, c2 : array_like 1-D arrays of Hermite series coefficients ordered from low to high. Returns ------- out : ndarray Array representing the Hermite series of their sum. See Also -------- hermesub, hermemul, hermediv, hermepow Notes ----- Unlike multiplication, division, etc., the sum of two Hermite series is a Hermite series (without having to "reproject" the result onto the basis set) so addition, just like that of "standard" polynomials, is simply "component-wise." Examples -------- >>> from numpy.polynomial.hermite_e import hermeadd >>> hermeadd([1, 2, 3], [1, 2, 3, 4]) array([ 2., 4., 6., 4.]) (R%R&R'tsizettrimseq(R4tc2tret((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyR 2s& cC`s|tj||gƒ\}}t|ƒt|ƒkrO||jc |8*|}n | }||jc |7*|}tj|ƒS(sö Subtract one Hermite series from another. Returns the difference of two Hermite series `c1` - `c2`. The sequences of coefficients are from lowest order term to highest, i.e., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``. Parameters ---------- c1, c2 : array_like 1-D arrays of Hermite series coefficients ordered from low to high. Returns ------- out : ndarray Of Hermite series coefficients representing their difference. See Also -------- hermeadd, hermemul, hermediv, hermepow Notes ----- Unlike multiplication, division, etc., the difference of two Hermite series is a Hermite series (without having to "reproject" the result onto the basis set) so subtraction, just like that of "standard" polynomials, is simply "component-wise." Examples -------- >>> from numpy.polynomial.hermite_e import hermesub >>> hermesub([1, 2, 3, 4], [1, 2, 3]) array([ 0., 0., 0., 4.]) (R%R&R'RCRD(R4RERF((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyR bs& cC`sÏtj|gƒ\}t|ƒdkr;|ddkr;|Stjt|ƒdd|jƒ}|dd|d<|d|d>> from numpy.polynomial.hermite_e import hermemulx >>> hermemulx([1, 2, 3]) array([ 2., 7., 2., 3.]) iitdtype(R%R&R'R6temptyRGR((R1tprdR,((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyR “s#"" cC`sLtj||gƒ\}}t|ƒt|ƒkrB|}|}n |}|}t|ƒdkrw|d|}d}nÂt|ƒdkr¨|d|}|d|}n‘t|ƒ}|d|}|d|}xftdt|ƒdƒD]K}|}|d}t|| |||dƒ}t|t|ƒƒ}qêWt|t|ƒƒS(sP Multiply one Hermite series by another. Returns the product of two Hermite series `c1` * `c2`. The arguments are sequences of coefficients, from lowest order "term" to highest, e.g., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``. Parameters ---------- c1, c2 : array_like 1-D arrays of Hermite series coefficients ordered from low to high. Returns ------- out : ndarray Of Hermite series coefficients representing their product. See Also -------- hermeadd, hermesub, hermediv, hermepow Notes ----- In general, the (polynomial) product of two C-series results in terms that are not in the Hermite polynomial basis set. Thus, to express the product as a Hermite series, it is necessary to "reproject" the product onto said basis set, which may produce "unintuitive" (but correct) results; see Examples section below. Examples -------- >>> from numpy.polynomial.hermite_e import hermemul >>> hermemul([1, 2, 3], [0, 1, 2]) array([ 14., 15., 28., 7., 6.]) iiiiþÿÿÿiÿÿÿÿi(R%R&R'R(R R R (R4RER1txsR3tndR,R5((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyRÄs*'      c C`s@tj||gƒ\}}|ddkr7tƒ‚nt|ƒ}t|ƒ}||krm|d d|fS|dkr“||d|d dfStj||dd|jƒ}|}xmt||ddƒD]U}tdg|dg|ƒ}|d|d}|d ||d }|||>> from numpy.polynomial.hermite_e import hermediv >>> hermediv([ 14., 15., 28., 7., 6.], [0, 1, 2]) (array([ 1., 2., 3.]), array([ 0.])) >>> hermediv([ 15., 17., 28., 7., 6.], [0, 1, 2]) (array([ 1., 2., 3.]), array([ 1., 2.])) iÿÿÿÿiiRGN( R%R&tZeroDivisionErrorR'R6RHRGR(RRD( R4REtlc1tlc2tquotremR,RAtq((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyRs",      icC`sßtj|gƒ\}t|ƒ}||ks9|dkrHtdƒ‚n“|dk ro||krotdƒ‚nl|dkr”tjdgd|jƒS|dkr¤|S|}x*td|dƒD]}t ||ƒ}q¾W|SdS(s~Raise a Hermite series to a power. Returns the Hermite series `c` raised to the power `pow`. The argument `c` is a sequence of coefficients ordered from low to high. i.e., [1,2,3] is the series ``P_0 + 2*P_1 + 3*P_2.`` Parameters ---------- c : array_like 1-D array of Hermite series coefficients ordered from low to high. pow : integer Power to which the series will be raised maxpower : integer, optional Maximum power allowed. This is mainly to limit growth of the series to unmanageable size. Default is 16 Returns ------- coef : ndarray Hermite series of power. See Also -------- hermeadd, hermesub, hermemul, hermediv Examples -------- >>> from numpy.polynomial.hermite_e import hermepow >>> hermepow([1, 2, 3], 2) array([ 23., 28., 46., 12., 9.]) is%Power must be a non-negative integer.sPower is too largeiRGiN( R%R&tintt ValueErrortNoneR6R7RGR(R(R1tpowtmaxpowertpowerRIR,((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyRGs#   c C`s¼tj|ddddƒ}|jjdkrB|jtjƒ}ng||gD]}t|ƒ^qO\}}||krˆtdƒ‚n|dkr£tdƒ‚n||kr¾tdƒ‚nt||j ƒ}|dkrà|Stj ||dƒ}t |ƒ}||kr|d dSx‡t |ƒD]y}|d}||9}tj |f|jdd |jƒ} x0t |dd ƒD]} | || | | d>> from numpy.polynomial.hermite_e import hermeder >>> hermeder([ 1., 1., 1., 1.]) array([ 1., 2., 3.]) >>> hermeder([-0.25, 1., 1./2., 1./3., 1./4 ], m=2) array([ 1., 2., 3.]) tndminitcopys ?bBhHiIlLqQpPs'The order of derivation must be integeris,The order of derivation must be non-negativesThe axis must be integerRGiÿÿÿÿ(R6R7RGtchartastypetdoubleRRRSRtndimtmoveaxisR'R(RHtshape( R1RBR9taxistttcnttiaxisR2R,tdertj((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyR}s47+         & c C`sÁtj|ddddƒ}|jjdkrB|jtjƒ}ntj|ƒs]|g}ng||gD]}t|ƒ^qj\}}||kr£tdƒ‚n|dkr¾tdƒ‚nt |ƒ|krßtdƒ‚ntj |ƒdkrtd ƒ‚ntj |ƒdkr'td ƒ‚n||krBtd ƒ‚nt ||j ƒ}|dkrd|Stj ||dƒ}t |ƒdg|t |ƒ}x t|ƒD]ý} t |ƒ} ||9}| dkrÿtj|ddkƒrÿ|dc|| 7 m``, ``np.ndim(lbnd) != 0``, or ``np.ndim(scl) != 0``. See Also -------- hermeder Notes ----- Note that the result of each integration is *multiplied* by `scl`. Why is this important to note? Say one is making a linear change of variable :math:`u = ax + b` in an integral relative to `x`. Then :math:`dx = du/a`, so one will need to set `scl` equal to :math:`1/a` - perhaps not what one would have first thought. Also note that, in general, the result of integrating a C-series needs to be "reprojected" onto the C-series basis set. Thus, typically, the result of this function is "unintuitive," albeit correct; see Examples section below. Examples -------- >>> from numpy.polynomial.hermite_e import hermeint >>> hermeint([1, 2, 3]) # integrate once, value 0 at 0. array([ 1., 1., 1., 1.]) >>> hermeint([1, 2, 3], m=2) # integrate twice, value & deriv 0 at 0 array([-0.25 , 1. , 0.5 , 0.33333333, 0.25 ]) >>> hermeint([1, 2, 3], k=1) # integrate once, value 1 at 0. array([ 2., 1., 1., 1.]) >>> hermeint([1, 2, 3], lbnd=-1) # integrate once, value 0 at -1 array([-1., 1., 1., 1.]) >>> hermeint([1, 2, 3], m=2, k=[1, 2], lbnd=-1) array([ 1.83333333, 0. , 0.5 , 0.33333333, 0.25 ]) RXiRYs ?bBhHiIlLqQpPs(The order of integration must be integeris-The order of integration must be non-negativesToo many integration constantsslbnd must be a scalar.sscl must be a scalar.sThe axis must be integerRG(R6R7RGRZR[R\titerableRRRSR'R]RR^tlistR(tallRHR_R( R1RBtktlbndR9R`RaRbRcR,R2R5Re((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyRÔsJS +    !  %*! cC`sttj|ddddƒ}|jjdkrB|jtjƒ}nt|ttfƒritj |ƒ}nt|tj ƒr¡|r¡|j |j d |j ƒ}nt|ƒdkrÆ|d}d}n¢t|ƒdkrï|d}|d}nyt|ƒ}|d}|d}xVtd t|ƒdƒD];}|}|d}|| ||d}|||}q)W|||S( s= Evaluate an HermiteE series at points x. If `c` is of length `n + 1`, this function returns the value: .. math:: p(x) = c_0 * He_0(x) + c_1 * He_1(x) + ... + c_n * He_n(x) The parameter `x` is converted to an array only if it is a tuple or a list, otherwise it is treated as a scalar. In either case, either `x` or its elements must support multiplication and addition both with themselves and with the elements of `c`. If `c` is a 1-D array, then `p(x)` will have the same shape as `x`. If `c` is multidimensional, then the shape of the result depends on the value of `tensor`. If `tensor` is true the shape will be c.shape[1:] + x.shape. If `tensor` is false the shape will be c.shape[1:]. Note that scalars have shape (,). Trailing zeros in the coefficients will be used in the evaluation, so they should be avoided if efficiency is a concern. Parameters ---------- x : array_like, compatible object If `x` is a list or tuple, it is converted to an ndarray, otherwise it is left unchanged and treated as a scalar. In either case, `x` or its elements must support addition and multiplication with with themselves and with the elements of `c`. c : array_like Array of coefficients ordered so that the coefficients for terms of degree n are contained in c[n]. If `c` is multidimensional the remaining indices enumerate multiple polynomials. In the two dimensional case the coefficients may be thought of as stored in the columns of `c`. tensor : boolean, optional If True, the shape of the coefficient array is extended with ones on the right, one for each dimension of `x`. Scalars have dimension 0 for this action. The result is that every column of coefficients in `c` is evaluated for every element of `x`. If False, `x` is broadcast over the columns of `c` for the evaluation. This keyword is useful when `c` is multidimensional. The default value is True. .. versionadded:: 1.7.0 Returns ------- values : ndarray, algebra_like The shape of the return value is described above. See Also -------- hermeval2d, hermegrid2d, hermeval3d, hermegrid3d Notes ----- The evaluation uses Clenshaw recursion, aka synthetic division. Examples -------- >>> from numpy.polynomial.hermite_e import hermeval >>> coef = [1,2,3] >>> hermeval(1, coef) 3.0 >>> hermeval([[1,2],[3,4]], coef) array([[ 3., 14.], [ 31., 54.]]) RXiRYis ?bBhHiIlLqQpPiiþÿÿÿiÿÿÿÿi(i(R6R7RGRZR[R\t isinstancettupleRgtasarraytndarraytreshapeR_R]R'R((txR1ttensorR3R4RKR,R5((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyRRs,E          cC`smy%tj||fddƒ\}}Wntk rDtdƒ‚nXt||ƒ}t||dtƒ}|S(sI Evaluate a 2-D HermiteE series at points (x, y). This function returns the values: .. math:: p(x,y) = \sum_{i,j} c_{i,j} * He_i(x) * He_j(y) The parameters `x` and `y` are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scalars and they must have the same shape after conversion. In either case, either `x` and `y` or their elements must support multiplication and addition both with themselves and with the elements of `c`. If `c` is a 1-D array a one is implicitly appended to its shape to make it 2-D. The shape of the result will be c.shape[2:] + x.shape. Parameters ---------- x, y : array_like, compatible objects The two dimensional series is evaluated at the points `(x, y)`, where `x` and `y` must have the same shape. If `x` or `y` is a list or tuple, it is first converted to an ndarray, otherwise it is left unchanged and if it isn't an ndarray it is treated as a scalar. c : array_like Array of coefficients ordered so that the coefficient of the term of multi-degree i,j is contained in ``c[i,j]``. If `c` has dimension greater than two the remaining indices enumerate multiple sets of coefficients. Returns ------- values : ndarray, compatible object The values of the two dimensional polynomial at points formed with pairs of corresponding values from `x` and `y`. See Also -------- hermeval, hermegrid2d, hermeval3d, hermegrid3d Notes ----- .. versionadded:: 1.7.0 RYisx, y are incompatibleRq(R6R7t ExceptionRSRR<(RptyR1((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyR±s.% cC`s"t||ƒ}t||ƒ}|S(s× Evaluate a 2-D HermiteE series on the Cartesian product of x and y. This function returns the values: .. math:: p(a,b) = \sum_{i,j} c_{i,j} * H_i(a) * H_j(b) where the points `(a, b)` consist of all pairs formed by taking `a` from `x` and `b` from `y`. The resulting points form a grid with `x` in the first dimension and `y` in the second. The parameters `x` and `y` are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scalars. In either case, either `x` and `y` or their elements must support multiplication and addition both with themselves and with the elements of `c`. If `c` has fewer than two dimensions, ones are implicitly appended to its shape to make it 2-D. The shape of the result will be c.shape[2:] + x.shape. Parameters ---------- x, y : array_like, compatible objects The two dimensional series is evaluated at the points in the Cartesian product of `x` and `y`. If `x` or `y` is a list or tuple, it is first converted to an ndarray, otherwise it is left unchanged and, if it isn't an ndarray, it is treated as a scalar. c : array_like Array of coefficients ordered so that the coefficients for terms of degree i,j are contained in ``c[i,j]``. If `c` has dimension greater than two the remaining indices enumerate multiple sets of coefficients. Returns ------- values : ndarray, compatible object The values of the two dimensional polynomial at points in the Cartesian product of `x` and `y`. See Also -------- hermeval, hermeval2d, hermeval3d, hermegrid3d Notes ----- .. versionadded:: 1.7.0 (R(RpRsR1((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyRés2cC`sˆy+tj|||fddƒ\}}}Wntk rJtdƒ‚nXt||ƒ}t||dtƒ}t||dtƒ}|S(sª Evaluate a 3-D Hermite_e series at points (x, y, z). This function returns the values: .. math:: p(x,y,z) = \sum_{i,j,k} c_{i,j,k} * He_i(x) * He_j(y) * He_k(z) The parameters `x`, `y`, and `z` are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scalars and they must have the same shape after conversion. In either case, either `x`, `y`, and `z` or their elements must support multiplication and addition both with themselves and with the elements of `c`. If `c` has fewer than 3 dimensions, ones are implicitly appended to its shape to make it 3-D. The shape of the result will be c.shape[3:] + x.shape. Parameters ---------- x, y, z : array_like, compatible object The three dimensional series is evaluated at the points `(x, y, z)`, where `x`, `y`, and `z` must have the same shape. If any of `x`, `y`, or `z` is a list or tuple, it is first converted to an ndarray, otherwise it is left unchanged and if it isn't an ndarray it is treated as a scalar. c : array_like Array of coefficients ordered so that the coefficient of the term of multi-degree i,j,k is contained in ``c[i,j,k]``. If `c` has dimension greater than 3 the remaining indices enumerate multiple sets of coefficients. Returns ------- values : ndarray, compatible object The values of the multidimensional polynomial on points formed with triples of corresponding values from `x`, `y`, and `z`. See Also -------- hermeval, hermeval2d, hermegrid2d, hermegrid3d Notes ----- .. versionadded:: 1.7.0 RYisx, y, z are incompatibleRq(R6R7RrRSRR<(RpRstzR1((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyR s0+ cC`s1t||ƒ}t||ƒ}t||ƒ}|S(sV Evaluate a 3-D HermiteE series on the Cartesian product of x, y, and z. This function returns the values: .. math:: p(a,b,c) = \sum_{i,j,k} c_{i,j,k} * He_i(a) * He_j(b) * He_k(c) where the points `(a, b, c)` consist of all triples formed by taking `a` from `x`, `b` from `y`, and `c` from `z`. The resulting points form a grid with `x` in the first dimension, `y` in the second, and `z` in the third. The parameters `x`, `y`, and `z` are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scalars. In either case, either `x`, `y`, and `z` or their elements must support multiplication and addition both with themselves and with the elements of `c`. If `c` has fewer than three dimensions, ones are implicitly appended to its shape to make it 3-D. The shape of the result will be c.shape[3:] + x.shape + y.shape + z.shape. Parameters ---------- x, y, z : array_like, compatible objects The three dimensional series is evaluated at the points in the Cartesian product of `x`, `y`, and `z`. If `x`,`y`, or `z` is a list or tuple, it is first converted to an ndarray, otherwise it is left unchanged and, if it isn't an ndarray, it is treated as a scalar. c : array_like Array of coefficients ordered so that the coefficients for terms of degree i,j are contained in ``c[i,j]``. If `c` has dimension greater than two the remaining indices enumerate multiple sets of coefficients. Returns ------- values : ndarray, compatible object The values of the two dimensional polynomial at points in the Cartesian product of `x` and `y`. See Also -------- hermeval, hermeval2d, hermegrid2d, hermeval3d Notes ----- .. versionadded:: 1.7.0 (R(RpRsRtR1((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyR[s5cC`st|ƒ}||kr'tdƒ‚n|dkrBtdƒ‚ntj|ddddƒd}|df|j}|j}tj|d|ƒ}|dd|d<|dkr||d>> from numpy.polynomial.hermite_e import hermevander >>> x = np.array([-1, 0, 1]) >>> hermevander(x, 3) array([[ 1., -1., 0., 2.], [ 1., 0., -1., -0.], [ 1., 1., 0., -2.]]) sdeg must be integerisdeg must be non-negativeRYRXigRGiiÿÿÿÿ( RRRSR6R7R_RGRHR(R^(RpR*tidegtdimstdtyptvR,((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyR–s,      1c C`sg|D]}t|ƒ^q}gt||ƒD]$\}}||koP|dk^q/}|ddgkrztdƒ‚n|\}}tj||fddƒd\}}t||ƒ} t||ƒ} | d | dddd…f} | j| jd d ƒS( s›Pseudo-Vandermonde matrix of given degrees. Returns the pseudo-Vandermonde matrix of degrees `deg` and sample points `(x, y)`. The pseudo-Vandermonde matrix is defined by .. math:: V[..., (deg[1] + 1)*i + j] = He_i(x) * He_j(y), where `0 <= i <= deg[0]` and `0 <= j <= deg[1]`. The leading indices of `V` index the points `(x, y)` and the last index encodes the degrees of the HermiteE polynomials. If ``V = hermevander2d(x, y, [xdeg, ydeg])``, then the columns of `V` correspond to the elements of a 2-D coefficient array `c` of shape (xdeg + 1, ydeg + 1) in the order .. math:: c_{00}, c_{01}, c_{02} ... , c_{10}, c_{11}, c_{12} ... and ``np.dot(V, c.flat)`` and ``hermeval2d(x, y, c)`` will be the same up to roundoff. This equivalence is useful both for least squares fitting and for the evaluation of a large number of 2-D HermiteE series of the same degrees and sample points. Parameters ---------- x, y : array_like Arrays of point coordinates, all of the same shape. The dtypes will be converted to either float64 or complex128 depending on whether any of the elements are complex. Scalars are converted to 1-D arrays. deg : list of ints List of maximum degrees of the form [x_deg, y_deg]. Returns ------- vander2d : ndarray The shape of the returned matrix is ``x.shape + (order,)``, where :math:`order = (deg[0]+1)*(deg([1]+1)`. The dtype will be the same as the converted `x` and `y`. See Also -------- hermevander, hermevander3d. hermeval2d, hermeval3d Notes ----- .. versionadded:: 1.7.0 iis%degrees must be non-negative integersRYg.Niþÿÿÿiÿÿÿÿ(.N(iÿÿÿÿ( RRtzipRSR6R7RRTRoR_( RpRsR*tdRutidtis_validtdegxtdegytvxtvyRx((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyR Ôs2: %!cC`s:g|D]}t|ƒ^q}gt||ƒD]$\}}||koP|dk^q/}|dddgkr}tdƒ‚n|\}} } tj|||fddƒd\}}}t||ƒ} t|| ƒ} t|| ƒ} | d | dddd…df| ddddd…f}|j|jd d ƒS( s'Pseudo-Vandermonde matrix of given degrees. Returns the pseudo-Vandermonde matrix of degrees `deg` and sample points `(x, y, z)`. If `l, m, n` are the given degrees in `x, y, z`, then Hehe pseudo-Vandermonde matrix is defined by .. math:: V[..., (m+1)(n+1)i + (n+1)j + k] = He_i(x)*He_j(y)*He_k(z), where `0 <= i <= l`, `0 <= j <= m`, and `0 <= j <= n`. The leading indices of `V` index the points `(x, y, z)` and the last index encodes the degrees of the HermiteE polynomials. If ``V = hermevander3d(x, y, z, [xdeg, ydeg, zdeg])``, then the columns of `V` correspond to the elements of a 3-D coefficient array `c` of shape (xdeg + 1, ydeg + 1, zdeg + 1) in the order .. math:: c_{000}, c_{001}, c_{002},... , c_{010}, c_{011}, c_{012},... and ``np.dot(V, c.flat)`` and ``hermeval3d(x, y, z, c)`` will be the same up to roundoff. This equivalence is useful both for least squares fitting and for the evaluation of a large number of 3-D HermiteE series of the same degrees and sample points. Parameters ---------- x, y, z : array_like Arrays of point coordinates, all of the same shape. The dtypes will be converted to either float64 or complex128 depending on whether any of the elements are complex. Scalars are converted to 1-D arrays. deg : list of ints List of maximum degrees of the form [x_deg, y_deg, z_deg]. Returns ------- vander3d : ndarray The shape of the returned matrix is ``x.shape + (order,)``, where :math:`order = (deg[0]+1)*(deg([1]+1)*(deg[2]+1)`. The dtype will be the same as the converted `x`, `y`, and `z`. See Also -------- hermevander, hermevander3d. hermeval2d, hermeval3d Notes ----- .. versionadded:: 1.7.0 iis%degrees must be non-negative integersRYg.Niýÿÿÿiÿÿÿÿ(.NN(iÿÿÿÿ( RRRyRSR6R7RRTRoR_(RpRsRtR*RzRuR{R|R}R~tdegzRR€tvzRx((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyR!s3:+>cC`sâtj|ƒd}tj|ƒd}tj|ƒ}|jdkse|jjdkse|jdkrttdƒ‚n|jƒdkr•tdƒ‚n|jdkr³tdƒ‚n|jdkrÑtdƒ‚n|jdksï|jd krþtd ƒ‚nt |ƒt |ƒkr%td ƒ‚n|jdkrV|}|d}t ||ƒ}nDtj |ƒ}|d }t |ƒ}t ||ƒd d …|f}|j } |j } |d k r'tj|ƒd}|jdkrétdƒ‚nt |ƒt |ƒkrtdƒ‚n| |} | |} n|d krUt |ƒtj|jƒj}nt| jjtjƒr¤tjtj| jƒtj| jƒjdƒƒ} n!tjtj| ƒjdƒƒ} d| | dk= 1.11.0 a list of integers specifying the degrees of the terms to include may be used instead. rcond : float, optional Relative condition number of the fit. Singular values smaller than this relative to the largest singular value will be ignored. The default value is len(x)*eps, where eps is the relative precision of the float type, about 2e-16 in most cases. full : bool, optional Switch determining nature of return value. When it is False (the default) just the coefficients are returned, when True diagnostic information from the singular value decomposition is also returned. w : array_like, shape (`M`,), optional Weights. If not None, the contribution of each point ``(x[i],y[i])`` to the fit is weighted by `w[i]`. Ideally the weights are chosen so that the errors of the products ``w[i]*y[i]`` all have the same variance. The default value is None. Returns ------- coef : ndarray, shape (M,) or (M, K) Hermite coefficients ordered from low to high. If `y` was 2-D, the coefficients for the data in column k of `y` are in column `k`. [residuals, rank, singular_values, rcond] : list These values are only returned if `full` = True resid -- sum of squared residuals of the least squares fit rank -- the numerical rank of the scaled Vandermonde matrix sv -- singular values of the scaled Vandermonde matrix rcond -- value of `rcond`. For more details, see `linalg.lstsq`. Warns ----- RankWarning The rank of the coefficient matrix in the least-squares fit is deficient. The warning is only raised if `full` = False. The warnings can be turned off by >>> import warnings >>> warnings.simplefilter('ignore', RankWarning) See Also -------- chebfit, legfit, polyfit, hermfit, polyfit hermeval : Evaluates a Hermite series. hermevander : pseudo Vandermonde matrix of Hermite series. hermeweight : HermiteE weight function. linalg.lstsq : Computes a least-squares fit from the matrix. scipy.interpolate.UnivariateSpline : Computes spline fits. Notes ----- The solution is the coefficients of the HermiteE series `p` that minimizes the sum of the weighted squared errors .. math:: E = \sum_j w_j^2 * |y_j - p(x_j)|^2, where the :math:`w_j` are the weights. This problem is solved by setting up the (typically) overdetermined matrix equation .. math:: V(x) * c = w * y, where `V` is the pseudo Vandermonde matrix of `x`, the elements of `c` are the coefficients to be solved for, and the elements of `y` are the observed values. This equation is then solved using the singular value decomposition of `V`. If some of the singular values of `V` are so small that they are neglected, then a `RankWarning` will be issued. This means that the coefficient values may be poorly determined. Using a lower order fit will usually get rid of the warning. The `rcond` parameter can also be set to a value smaller than its default, but the resulting fit may be spurious and have large contributions from roundoff error. Fits using HermiteE series are probably most useful when the data can be approximated by ``sqrt(w(x)) * p(x)``, where `w(x)` is the HermiteE weight. In that case the weight ``sqrt(w(x[i])`` should be used together with data values ``y[i]/sqrt(w(x[i])``. The weight function is available as `hermeweight`. References ---------- .. [1] Wikipedia, "Curve fitting", http://en.wikipedia.org/wiki/Curve_fitting Examples -------- >>> from numpy.polynomial.hermite_e import hermefit, hermeval >>> x = np.linspace(-10, 10) >>> err = np.random.randn(len(x))/10 >>> y = hermeval(x, [1, 2, 3]) + err >>> hermefit(x, y, 2) array([ 1.01690445, 1.99951418, 2.99948696]) gitiuis0deg must be an int or non-empty 1-D array of intsexpected deg >= 0sexpected 1D vector for xsexpected non-empty vector for xisexpected 1D or 2D array for ys$expected x and y to have same lengthiÿÿÿÿNsexpected 1D vector for ws$expected x and w to have same lengthRGs!The fit may be poorly conditionedt stacklevel( R6RmR]RGtkindRCt TypeErrortminRSR'RR=tTRTtfinfotepst issubclassttypetcomplexfloatingtsqrttsquaretrealtimagtsumtlatlstsqtzerosR_twarningstwarnR%t RankWarning(RpRsR*trcondtfulltwtlmaxtordertvantlhstrhsR9R1tresidstranktstcctmsg((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyRTsj|0         "7!+,  cC`sƒtj|gƒ\}t|ƒdkr6tdƒ‚nt|ƒdkrhtj|d |dggƒSt|ƒd}tj||fd|jƒ}tjddtj tj |dddƒƒfƒ}tj j |ƒddd…}|j dƒdd|d…}|j dƒ|d|d…}tj tj d|ƒƒ|d <||d <|dd…dfc||d |d8<|S( s™ Return the scaled companion matrix of c. The basis polynomials are scaled so that the companion matrix is symmetric when `c` is an HermiteE basis polynomial. This provides better eigenvalue estimates than the unscaled case and for basis polynomials the eigenvalues are guaranteed to be real if `numpy.linalg.eigvalsh` is used to obtain them. Parameters ---------- c : array_like 1-D array of HermiteE series coefficients ordered from low to high degree. Returns ------- mat : ndarray Scaled companion matrix of dimensions (deg, deg). Notes ----- .. versionadded:: 1.7.0 is.Series must have maximum degree of at least 1.iiRGgð?iÿÿÿÿN.(R%R&R'RSR6R7R•RGthstackRŽtarangetmultiplyt accumulateRo(R1R2tmatR9ttoptbot((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyR"s 5   ,cC`s•tj|gƒ\}t|ƒdkr=tjgd|jƒSt|ƒdkrltj|d |dgƒSt|ƒ}tj|ƒ}|j ƒ|S(sS Compute the roots of a HermiteE series. Return the roots (a.k.a. "zeros") of the polynomial .. math:: p(x) = \sum_i c[i] * He_i(x). Parameters ---------- c : 1-D array_like 1-D array of coefficients. Returns ------- out : ndarray Array of the roots of the series. If all the roots are real, then `out` is also real, otherwise it is complex. See Also -------- polyroots, legroots, lagroots, hermroots, chebroots Notes ----- The root estimates are obtained as the eigenvalues of the companion matrix, Roots far from the origin of the complex plane may have large errors due to the numerical instability of the series for such values. Roots with multiplicity greater than 1 will also show larger errors as the value of the series near such points is relatively insensitive to errors in the roots. Isolated roots near the origin can be improved by a few iterations of Newton's method. The HermiteE series basis polynomials aren't powers of `x` so the results of this function may seem unintuitive. Examples -------- >>> from numpy.polynomial.hermite_e import hermeroots, hermefromroots >>> coef = hermefromroots([-1, 0, 1]) >>> coef array([ 0., 2., 0., 1.]) >>> hermeroots(coef) array([-1., 0., 1.]) iRGii( R%R&R'R6R7RGR"R“teigvalsR=(R1RBR@((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyRKs/  cC`sà|dkr9tj|jƒtjtjdtjƒƒSd}dtjtjdtjƒƒ}t|ƒ}xct|dƒD]Q}|}| tj|d|ƒ}|||tjd|ƒ}|d}qW|||S(s£ Evaluate a normalized HermiteE polynomial. Compute the value of the normalized HermiteE polynomial of degree ``n`` at the points ``x``. Parameters ---------- x : ndarray of double. Points at which to evaluate the function n : int Degree of the normalized HermiteE function to be evaluated. Returns ------- values : ndarray The shape of the return value is described above. Notes ----- .. versionadded:: 1.10.0 This function is needed for finding the Gauss points and integration weights for high degrees. The values of the standard HermiteE functions overflow when n >= 207. iiggð?i(R6R;R_RŽtpitfloatR((RpR2R3R4RKR,R5((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyt_normed_hermite_e_n†s -# c C`sFt|ƒ}||ks$|dkr3tdƒ‚ntjdg|dgƒ}t|ƒ}tj|ƒ}t||ƒ}t||dƒtj|ƒ}|||8}t||dƒ}|tj |ƒj ƒ}d||}||ddd…d}||ddd…d}|tjdtj ƒ|j ƒ9}||fS(sý Gauss-HermiteE quadrature. Computes the sample points and weights for Gauss-HermiteE quadrature. These sample points and weights will correctly integrate polynomials of degree :math:`2*deg - 1` or less over the interval :math:`[-\inf, \inf]` with the weight function :math:`f(x) = \exp(-x^2/2)`. Parameters ---------- deg : int Number of sample points and weights. It must be >= 1. Returns ------- x : ndarray 1-D ndarray containing the sample points. y : ndarray 1-D ndarray containing the weights. Notes ----- .. versionadded:: 1.7.0 The results have only been tested up to degree 100, higher degrees may be problematic. The weights are determined by using the fact that .. math:: w_k = c / (He'_n(x_k) * He_{n-1}(x_k)) where :math:`c` is a constant independent of :math:`k` and :math:`x_k` is the k'th root of :math:`He_n`, and then scaling the results to get the right value when integrating 1. is"deg must be a non-negative integeriNiÿÿÿÿi( RRRSR6R7R"R“teigvalshR°RŽtabstmaxR®R’( R*RuR1RBRptdytdftfmR›((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyR#±s $   $cC`stjd|dƒ}|S(söWeight function of the Hermite_e polynomials. The weight function is :math:`\exp(-x^2/2)` and the interval of integration is :math:`[-\inf, \inf]`. the HermiteE polynomials are orthogonal, but not normalized, with respect to this weight function. Parameters ---------- x : array_like Values at which the weight function will be computed. Returns ------- w : ndarray The weight function at `x`. Notes ----- .. versionadded:: 1.7.0 gà¿i(R6texp(RpR›((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyR$ôscB`sÂeZdZeeƒZeeƒZeeƒZ ee ƒZ ee ƒZ eeƒZeeƒZeeƒZeeƒZeeƒZeeƒZeeƒZdZejeƒZ ejeƒZ!RS(sAn HermiteE series class. The HermiteE class provides the standard Python numerical methods '+', '-', '*', '//', '%', 'divmod', '**', and '()' as well as the attributes and methods listed in the `ABCPolyBase` documentation. Parameters ---------- coef : array_like HermiteE coefficients in order of increasing degree, i.e, ``(1, 2, 3)`` gives ``1*He_0(x) + 2*He_1(X) + 3*He_2(x)``. domain : (2,) array_like, optional Domain to use. The interval ``[domain[0], domain[1]]`` is mapped to the interval ``[window[0], window[1]]`` by shifting and scaling. The default value is [-1, 1]. window : (2,) array_like, optional Window, see `domain` for its use. The default value is [-1, 1]. .. versionadded:: 1.6.0 therme("t__name__t __module__t__doc__t staticmethodR t_addR t_subRt_mulRt_divRt_powRt_valRt_intRt_derRt_fitR t_lineRt_rootsRt _fromrootstnicknameR6R7R tdomaintwindow(((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyRs             (8R»t __future__RRRR–tnumpyR6t numpy.linalgtlinalgR“tnumpy.core.multiarrayRtRR%t _polybaseRt__all__ttrimcoefRRRR7R RRRR RR R R RRRRRtTrueRRRRRRR R!RTR<RR"RR°R#R$R(((s9/tmp/pip-build-fiC0ax/numpy/numpy/polynomial/hermite_e.pyt;s\      . > % C 0 1 1 B A 6W~ _ 8 7 ; ; > ? AÉ . ; + C