ó °¿v]c@`sUdZddlmZmZmZddlZddlZddlj Z ddl m Z ddl mZddlmZdd d d d d ddddddddddddddddddd d!d"d#d$d%d&gZejZd'„Zd(„ZejddgƒZejdgƒZejdgƒZejdd)gƒ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„Z5defdB„ƒYZ6dS(Cs, Objects for dealing with Laguerre series. This module provides a number of objects (mostly functions) useful for dealing with Laguerre series, including a `Laguerre` 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 --------- - `lagdomain` -- Laguerre series default domain, [-1,1]. - `lagzero` -- Laguerre series that evaluates identically to 0. - `lagone` -- Laguerre series that evaluates identically to 1. - `lagx` -- Laguerre series for the identity map, ``f(x) = x``. Arithmetic ---------- - `lagadd` -- add two Laguerre series. - `lagsub` -- subtract one Laguerre series from another. - `lagmulx` -- multiply a Laguerre series in ``P_i(x)`` by ``x``. - `lagmul` -- multiply two Laguerre series. - `lagdiv` -- divide one Laguerre series by another. - `lagpow` -- raise a Laguerre series to a positive integer power. - `lagval` -- evaluate a Laguerre series at given points. - `lagval2d` -- evaluate a 2D Laguerre series at given points. - `lagval3d` -- evaluate a 3D Laguerre series at given points. - `laggrid2d` -- evaluate a 2D Laguerre series on a Cartesian product. - `laggrid3d` -- evaluate a 3D Laguerre series on a Cartesian product. Calculus -------- - `lagder` -- differentiate a Laguerre series. - `lagint` -- integrate a Laguerre series. Misc Functions -------------- - `lagfromroots` -- create a Laguerre series with specified roots. - `lagroots` -- find the roots of a Laguerre series. - `lagvander` -- Vandermonde-like matrix for Laguerre polynomials. - `lagvander2d` -- Vandermonde-like matrix for 2D power series. - `lagvander3d` -- Vandermonde-like matrix for 3D power series. - `laggauss` -- Gauss-Laguerre quadrature, points and weights. - `lagweight` -- Laguerre weight function. - `lagcompanion` -- symmetrized companion matrix in Laguerre form. - `lagfit` -- least-squares fit returning a Laguerre series. - `lagtrim` -- trim leading coefficients from a Laguerre series. - `lagline` -- Laguerre series of given straight line. - `lag2poly` -- convert a Laguerre series to a polynomial. - `poly2lag` -- convert a polynomial to a Laguerre series. Classes ------- - `Laguerre` -- A Laguerre series class. See also -------- `numpy.polynomial` i(tdivisiontabsolute_importtprint_functionN(tnormalize_axis_indexi(t polyutils(t ABCPolyBasetlagzerotlagonetlagxt lagdomaintlaglinetlagaddtlagsubtlagmulxtlagmultlagdivtlagpowtlagvaltlagdertlaginttlag2polytpoly2lagt lagfromrootst lagvandertlagfittlagtrimtlagrootstLaguerretlagval2dtlagval3dt laggrid2dt laggrid3dt lagvander2dt lagvander3dt lagcompaniontlaggausst lagweightcC`setj|gƒ\}t|ƒd}d}x3t|ddƒD]}tt|ƒ||ƒ}q>W|S(s„ poly2lag(pol) Convert a polynomial to a Laguerre 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 Laguerre 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 Laguerre series. See Also -------- lag2poly 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.laguerre import poly2lag >>> poly2lag(np.arange(4)) array([ 23., -63., 58., -18.]) iiiÿÿÿÿ(tput as_seriestlentrangeR R (tpoltdegtresti((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.pyRRs &c C`sùddlm}m}m}tj|gƒ\}t|ƒ}|dkrM|S|d}|d}xut|dddƒD]]}|}|||d||d|ƒ}|||d|d|||ƒƒ|ƒ}qxW||||||ƒƒƒSdS(s Convert a Laguerre series to a polynomial. Convert an array representing the coefficients of a Laguerre 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 Laguerre 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 -------- poly2lag 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.laguerre import lag2poly >>> lag2poly([ 23., -63., 58., -18.]) array([ 0., 1., 2., 3.]) i(tpolyaddtpolysubtpolymulxiþÿÿÿiÿÿÿÿiN(t polynomialR-R.R/R%R&R'R(( tcR-R.R/tntc0tc1R,ttmp((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.pyR€s&    #2iÿÿÿÿcC`s8|dkr$tj||| gƒStj|gƒSdS(s Laguerre 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 Laguerre series for ``off + scl*x``. See Also -------- polyline, chebline Examples -------- >>> from numpy.polynomial.laguerre import lagline, lagval >>> lagval(0,lagline(3, 2)) 3.0 >>> lagval(1,lagline(3, 2)) 5.0 iN(tnptarray(tofftscl((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.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.laguerre import lagfromroots, lagval >>> coef = lagfromroots((-1, 0, 1)) >>> lagval((-1, 0, 1), coef) array([ 0., 0., 0.]) >>> coef = lagfromroots((-1j, 1j)) >>> lagval((-1j, 1j), coef) array([ 0.+0.j, 0.+0.j]) iittrimiiÿÿÿÿN( R'R6tonesR%R&tFalsetsortR tdivmodR(R(trootstrtpR2tmR,R5((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.pyRìs2  # 4 cC`sutj||gƒ\}}t|ƒt|ƒkrO||jc |7*|}n||jc |7*|}tj|ƒS(sé Add one Laguerre series to another. Returns the sum of two Laguerre 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 Laguerre series coefficients ordered from low to high. Returns ------- out : ndarray Array representing the Laguerre series of their sum. See Also -------- lagsub, lagmulx, lagmul, lagdiv, lagpow Notes ----- Unlike multiplication, division, etc., the sum of two Laguerre series is a Laguerre 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.laguerre import lagadd >>> lagadd([1, 2, 3], [1, 2, 3, 4]) array([ 2., 4., 6., 4.]) (R%R&R'tsizettrimseq(R4tc2tret((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.pyR /s' cC`s|tj||gƒ\}}t|ƒt|ƒkrO||jc |8*|}n | }||jc |7*|}tj|ƒS(sø Subtract one Laguerre series from another. Returns the difference of two Laguerre 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 Laguerre series coefficients ordered from low to high. Returns ------- out : ndarray Of Laguerre series coefficients representing their difference. See Also -------- lagadd, lagmulx, lagmul, lagdiv, lagpow Notes ----- Unlike multiplication, division, etc., the difference of two Laguerre series is a Laguerre 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.laguerre import lagsub >>> lagsub([1, 2, 3, 4], [1, 2, 3]) array([ 0., 0., 0., 4.]) (R%R&R'RCRD(R4RERF((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.pyR `s& cC`sõtj|gƒ\}t|ƒdkr;|ddkr;|Stjt|ƒdd|jƒ}|d|d<|d |d>> from numpy.polynomial.laguerre import lagmulx >>> lagmulx([1, 2, 3]) array([ -1., -1., 11., -9.]) iitdtypei(R%R&R'R6temptyRGR((R1tprdR,((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.pyR ‘s'""  cC`srtj||gƒ\}}t|ƒt|ƒkrB|}|}n |}|}t|ƒdkrw|d|}d}nßt|ƒdkr¨|d|}|d|}n®t|ƒ}|d|}|d|}xƒtdt|ƒdƒD]h}|}|d}t|| |||d|ƒ}t|td|d|t|ƒƒ|ƒ}qêWt|t|t|ƒƒƒS(sR Multiply one Laguerre series by another. Returns the product of two Laguerre 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 Laguerre series coefficients ordered from low to high. Returns ------- out : ndarray Of Laguerre series coefficients representing their product. See Also -------- lagadd, lagsub, lagmulx, lagdiv, lagpow Notes ----- In general, the (polynomial) product of two C-series results in terms that are not in the Laguerre polynomial basis set. Thus, to express the product as a Laguerre 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.laguerre import lagmul >>> lagmul([1, 2, 3], [0, 1, 2]) array([ 8., -13., 38., -51., 36.]) iiiiþÿÿÿiÿÿÿÿi(R%R&R'R(R R R (R4RER1txsR3tndR,R5((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.pyRÇs*'     $2c 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.laguerre import lagdiv >>> lagdiv([ 8., -13., 38., -51., 36.], [0, 1, 2]) (array([ 1., 2., 3.]), array([ 0.])) >>> lagdiv([ 9., -12., 38., -51., 36.], [0, 1, 2]) (array([ 1., 2., 3.]), array([ 1., 1.])) iÿÿÿÿiiRGN( R%R&tZeroDivisionErrorR'R6RHRGR(RRD( R4REtlc1tlc2tquotremR,RAtq((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.pyR s",      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 Laguerre series to a power. Returns the Laguerre 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 Laguerre 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 Laguerre series of power. See Also -------- lagadd, lagsub, lagmulx, lagmul, lagdiv Examples -------- >>> from numpy.polynomial.laguerre import lagpow >>> lagpow([1, 2, 3], 2) array([ 14., -16., 56., -72., 54.]) is%Power must be a non-negative integer.sPower is too largeiRGiN( R%R&tintt ValueErrortNoneR6R7RGR(R(R1tpowtmaxpowertpowerRIR,((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.pyRJs#   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 d}n®x«t |ƒD]}|d}||9}tj |f|jdd |jƒ} xEt |dd ƒD]1} ||  | | d<|| dc|| 7>> from numpy.polynomial.laguerre import lagder >>> lagder([ 1., 1., 1., -3.]) array([ 1., 2., 3.]) >>> lagder([ 1., 0., 0., -4., 3.], 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((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.pyR€s87+        & 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 |ƒ}xt|ƒD]} t |ƒ} ||9}| dkrÿtj|ddkƒrÿ|dc|| 7td| ƒD]-} | | c|| 7<||  | | d m``, ``np.ndim(lbnd) != 0``, or ``np.ndim(scl) != 0``. See Also -------- lagder 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.laguerre import lagint >>> lagint([1,2,3]) array([ 1., 1., 1., -3.]) >>> lagint([1,2,3], m=2) array([ 1., 0., 0., -4., 3.]) >>> lagint([1,2,3], k=1) array([ 2., 1., 1., -3.]) >>> lagint([1,2,3], lbnd=-1) array([ 11.5, 1. , 1. , -3. ]) >>> lagint([1,2], m=2, k=[1,2], lbnd=-1) array([ 11.16666667, -5. , -3. , 2. ]) 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((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.pyRÙsLT +    !  %*! cC`sŒtj|ddddƒ}|jjdkrB|jtjƒ}nt|ttfƒritj |ƒ}nt|tj ƒr¡|r¡|j |j d |j ƒ}nt|ƒdkrÆ|d}d}n¶t|ƒdkrï|d}|d}nt|ƒ}|d}|d}xjtd t|ƒdƒD]O}|}|d}|| ||d|}||d|d||}q)W||d|S( s+ Evaluate a Laguerre series at points x. If `c` is of length `n + 1`, this function returns the value: .. math:: p(x) = c_0 * L_0(x) + c_1 * L_1(x) + ... + c_n * L_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 -------- lagval2d, laggrid2d, lagval3d, laggrid3d Notes ----- The evaluation uses Clenshaw recursion, aka synthetic division. Examples -------- >>> from numpy.polynomial.laguerre import lagval >>> coef = [1,2,3] >>> lagval(1, coef) -0.5 >>> lagval([[1,2],[3,4]], coef) array([[-0.5, -4. ], [-4.5, -2. ]]) RXiRYis ?bBhHiIlLqQpPiiþÿÿÿiÿÿÿÿi(i(R6R7RGRZR[R\t isinstancettupleRgtasarraytndarraytreshapeR_R]R'R((txR1ttensorR3R4RKR,R5((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.pyRYs,E          "cC`smy%tj||fddƒ\}}Wntk rDtdƒ‚nXt||ƒ}t||dtƒ}|S(s? Evaluate a 2-D Laguerre series at points (x, y). This function returns the values: .. math:: p(x,y) = \sum_{i,j} c_{i,j} * L_i(x) * L_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 -------- lagval, laggrid2d, lagval3d, laggrid3d Notes ----- .. versionadded:: 1.7.0 RYisx, y are incompatibleRq(R6R7t ExceptionRSRR<(RptyR1((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.pyR¸s.% cC`s"t||ƒ}t||ƒ}|S(sã Evaluate a 2-D Laguerre series on the Cartesian product of x and y. This function returns the values: .. math:: p(a,b) = \sum_{i,j} c_{i,j} * L_i(a) * L_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 + y.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 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 Chebyshev series at points in the Cartesian product of `x` and `y`. See Also -------- lagval, lagval2d, lagval3d, laggrid3d Notes ----- .. versionadded:: 1.7.0 (R(RpRsR1((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.pyRðs2cC`sˆy+tj|||fddƒ\}}}Wntk rJtdƒ‚nXt||ƒ}t||dtƒ}t||dtƒ}|S(sœ Evaluate a 3-D Laguerre series at points (x, y, z). This function returns the values: .. math:: p(x,y,z) = \sum_{i,j,k} c_{i,j,k} * L_i(x) * L_j(y) * L_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 multidimension polynomial on points formed with triples of corresponding values from `x`, `y`, and `z`. See Also -------- lagval, lagval2d, laggrid2d, laggrid3d Notes ----- .. versionadded:: 1.7.0 RYisx, y, z are incompatibleRq(R6R7RrRSRR<(RpRstzR1((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.pyR's0+ cC`s1t||ƒ}t||ƒ}t||ƒ}|S(sK Evaluate a 3-D Laguerre 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} * L_i(a) * L_j(b) * L_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 -------- lagval, lagval2d, laggrid2d, lagval3d Notes ----- .. versionadded:: 1.7.0 (R(RpRsRtR1((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.pyRbs5cC`s-t|ƒ}||kr'tdƒ‚n|dkrBtdƒ‚ntj|ddddƒd}|df|j}|j}tj|d|ƒ}|dd|d<|dkrd||d>> from numpy.polynomial.laguerre import lagvander >>> x = np.array([0, 1, 2]) >>> lagvander(x, 3) array([[ 1. , 1. , 1. , 1. ], [ 1. , 0. , -0.5 , -0.66666667], [ 1. , -1. , -1. , -0.33333333]]) sdeg must be integerisdeg must be non-negativeRYRXigRGiiÿÿÿÿ( RRRSR6R7R_RGRHR(R^(RpR*tidegtdimstdtyptvR,((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.pyRs,     Ac C`sg|D]}t|ƒ^q}gt||ƒD]$\}}||koP|dk^q/}|ddgkrztdƒ‚n|\}}tj||fddƒd\}}t||ƒ} t||ƒ} | d | dddd…f} | j| jd d ƒS( sPseudo-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] = L_i(x) * L_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 Laguerre polynomials. If ``V = lagvander2d(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 ``lagval2d(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 Laguerre 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 -------- lagvander, lagvander3d. lagval2d, lagval3d Notes ----- .. versionadded:: 1.7.0 iis%degrees must be non-negative integersRYg.Niþÿÿÿiÿÿÿÿ(.N(iÿÿÿÿ( RRtzipRSR6R7RRTRoR_( RpRsR*tdRutidtis_validtdegxtdegytvxtvyRx((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.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( sPseudo-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 The pseudo-Vandermonde matrix is defined by .. math:: V[..., (m+1)(n+1)i + (n+1)j + k] = L_i(x)*L_j(y)*L_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 Laguerre polynomials. If ``V = lagvander3d(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 ``lagval3d(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 Laguerre 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 -------- lagvander, lagvander3d. lagval2d, lagval3d Notes ----- .. versionadded:: 1.7.0 iis%degrees must be non-negative integersRYg.Niýÿÿÿiÿÿÿÿ(.NN(iÿÿÿÿ( RRRyRSR6R7RRTRoR_(RpRsRtR*RzRuR{R|R}R~tdegzRR€tvzRx((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.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) Laguerre 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, hermefit lagval : Evaluates a Laguerre series. lagvander : pseudo Vandermonde matrix of Laguerre series. lagweight : Laguerre 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 Laguerre 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 as the (typically) overdetermined matrix equation .. math:: V(x) * c = w * y, where `V` is the weighted pseudo Vandermonde matrix of `x`, `c` are the coefficients to be solved for, `w` are the weights, and `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 Laguerre series are probably most useful when the data can be approximated by ``sqrt(w(x)) * p(x)``, where `w(x)` is the Laguerre 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 `lagweight`. References ---------- .. [1] Wikipedia, "Curve fitting", https://en.wikipedia.org/wiki/Curve_fitting Examples -------- >>> from numpy.polynomial.laguerre import lagfit, lagval >>> x = np.linspace(0, 10) >>> err = np.random.randn(len(x))/10 >>> y = lagval(x, [1, 2, 3]) + err >>> lagfit(x, y, 2) array([ 0.96971004, 2.00193749, 3.00288744]) 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((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.pyR[sj|0         "7!+,  cC`setj|gƒ\}t|ƒdkr6tdƒ‚nt|ƒdkrktjd|d|dggƒSt|ƒd}tj||fd|jƒ}|jdƒdd|d…}|jdƒdd|d…}|jdƒ|d|d…}tj d|ƒ |d>> from numpy.polynomial.laguerre import lagroots, lagfromroots >>> coef = lagfromroots([0, 1, 2]) >>> coef array([ 2., -8., 12., -6.]) >>> lagroots(coef) array([ -4.44089210e-16, 1.00000000e+00, 2.00000000e+00]) iRGii( R%R&R'R6R7RGR"R“teigvalsR=(R1RBR@((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.pyRPs/   c C`s t|ƒ}||ks$|dkr3tdƒ‚ntjdg|dgƒ}t|ƒ}tj|ƒ}t||ƒ}t|t|ƒƒ}|||8}t||dƒ}|tj |ƒj ƒ}|tj |ƒj ƒ}d||}||j ƒ}||fS(sñ Gauss-Laguerre quadrature. Computes the sample points and weights for Gauss-Laguerre quadrature. These sample points and weights will correctly integrate polynomials of degree :math:`2*deg - 1` or less over the interval :math:`[0, \inf]` with the weight function :math:`f(x) = \exp(-x)`. 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 / (L'_n(x_k) * L_{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:`L_n`, and then scaling the results to get the right value when integrating 1. is"deg must be a non-negative integeri( RRRSR6R7R"R“teigvalshRRtabstmaxR’( R*RuR1RBRptdytdftfmR›((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.pyR#‹s$  cC`stj| ƒ}|S(sìWeight function of the Laguerre polynomials. The weight function is :math:`exp(-x)` and the interval of integration is :math:`[0, \inf]`. The Laguerre 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 (R6texp(RpR›((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.pyR$ËscB`sÈeZdZeeƒZeeƒZeeƒZ ee ƒZ ee ƒZ eeƒZeeƒZeeƒZeeƒZeeƒZeeƒZeeƒZdZejeƒZ ejeƒZ!dZ"RS(sA Laguerre series class. The Laguerre 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 Laguerre coefficients in order of increasing degree, i.e, ``(1, 2, 3)`` gives ``1*L_0(x) + 2*L_1(X) + 3*L_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 [0, 1]. window : (2,) array_like, optional Window, see `domain` for its use. The default value is [0, 1]. .. versionadded:: 1.6.0 tlagtL(#t__name__t __module__t__doc__t staticmethodR t_addR t_subRt_mulRt_divRt_powRt_valRt_intRt_derRt_fitR t_lineRt_rootsRt _fromrootstnicknameR6R7R tdomaintwindowt basis_name(((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.pyRés"            (7R·t __future__RRRR–tnumpyR6t numpy.linalgtlinalgR“tnumpy.core.multiarrayRtRR%t _polybaseRt__all__ttrimcoefRRRR7R RRRR RR R R RRRRRtTrueRRRRRRR R!RTR<RR"RR#R$R(((si/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/polynomial/laguerre.pyt<sX     . < $ C 1 1 6 B A 6Y€ _ 8 7 ; ; > ? AÉ , ; @