Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
laguerre.cpython-313.pyc1403 linesDownload Raw Back to __pycache__
1�

2z�jh����SrSSKrSSKJr SSKJr /SQr\Rr3SrSr\R"S	S4/5r\R"S/5r\R"S/5r\R"SS/5rSrS
rSrSrSrSrSrS%SjrS&SjrS/SSS4SjrS'SjrSrSrSrSr Sr!Sr"Sr#S(Sjr$Sr%S r&S!r'S"r("S#S$\5r)g))a�5==================================================6Laguerre Series (:mod:`numpy.polynomial.laguerre`)7==================================================8 9This module provides a number of objects (mostly functions) useful for10dealing with Laguerre series, including a `Laguerre` class that11encapsulates the usual arithmetic operations.  (General information12on how this module represents and works with such polynomials is in the13docstring for its "parent" sub-package, `numpy.polynomial`).14 15Classes16-------17.. autosummary::18   :toctree: generated/19 20   Laguerre21 22Constants23---------24.. autosummary::25   :toctree: generated/26 27   lagdomain28   lagzero29   lagone30   lagx31 32Arithmetic33----------34.. autosummary::35   :toctree: generated/36 37   lagadd38   lagsub39   lagmulx40   lagmul41   lagdiv42   lagpow43   lagval44   lagval2d45   lagval3d46   laggrid2d47   laggrid3d48 49Calculus50--------51.. autosummary::52   :toctree: generated/53 54   lagder55   lagint56 57Misc Functions58--------------59.. autosummary::60   :toctree: generated/61 62   lagfromroots63   lagroots64   lagvander65   lagvander2d66   lagvander3d67   laggauss68   lagweight69   lagcompanion70   lagfit71   lagtrim72   lagline73   lag2poly74   poly2lag75 76See also77--------78`numpy.polynomial`79 80�N�)�	polyutils)�ABCPolyBase)�lagzero�lagone�lagx�	lagdomain�lagline�lagadd�lagsub�lagmulx�lagmul�lagdiv�lagpow�lagval�lagder�lagint�lag2poly�poly2lag�lagfromroots�	lagvander�lagfit�lagtrim�lagroots�Laguerre�lagval2d�lagval3d�	laggrid2d�	laggrid3d�lagvander2d�lagvander3d�lagcompanion�laggauss�	lagweightc��[R"U/5unSnUSSS2Hn[[U5U5nM U$)a+81poly2lag(pol)82 83Convert a polynomial to a Laguerre series.84 85Convert an array representing the coefficients of a polynomial (relative86to the "standard" basis) ordered from lowest degree to highest, to an87array of the coefficients of the equivalent Laguerre series, ordered88from lowest to highest degree.89 90Parameters91----------92pol : array_like93    1-D array containing the polynomial coefficients94 95Returns96-------97c : ndarray98    1-D array containing the coefficients of the equivalent Laguerre99    series.100 101See Also102--------103lag2poly104 105Notes106-----107The easy way to do conversions between polynomial basis sets108is to use the convert method of a class instance.109 110Examples111--------112>>> import numpy as np113>>> from numpy.polynomial.laguerre import poly2lag114>>> poly2lag(np.arange(4))115array([ 23., -63.,  58., -18.])116 117rN�����)�pu�	as_seriesrr
)�pol�res�ps   �_D:\code\apps\devtools\python\user_packages\Python313\site-packages\numpy/polynomial/laguerre.pyrr^sC��N
�L�L�#���E�S�118�C�
��2��Y���W�S�\�1�%����J�c119�J�SSKJnJnJn [R120"U/5un[
U5nUS:XaU$USnUSn[US-121SS5H<nUnU"XS-122XgS-123-U-5nU"X�"SU-S-124U-U"U55U-5nM> U"XS"Xb"U555$)a�125Convert a Laguerre series to a polynomial.126 127Convert an array representing the coefficients of a Laguerre series,128ordered from lowest degree to highest, to an array of the coefficients129of the equivalent polynomial (relative to the "standard" basis) ordered130from lowest to highest degree.131 132Parameters133----------134c : array_like135    1-D array containing the Laguerre series coefficients, ordered136    from lowest order term to highest.137 138Returns139-------140pol : ndarray141    1-D array containing the coefficients of the equivalent polynomial142    (relative to the "standard" basis) ordered from lowest order term143    to highest.144 145See Also146--------147poly2lag148 149Notes150-----151The easy way to do conversions between polynomial basis sets152is to use the convert method of a class instance.153 154Examples155--------156>>> from numpy.polynomial.laguerre import lag2poly157>>> lag2poly([ 23., -63.,  58., -18.])158array([0., 1., 2., 3.])159 160r)�polyadd�polymulx�polysub�����r&�)�161polynomialr/r0r1r'r(�len�range)	�cr/r0r1�n�c0�c1�i�tmps	         r,rr�s���L7�6�162�,�,��s�163�C�Q��A��A��A�v���
�r�U��
�r�U���q�1�u�a��$�A��C���q�5��B�a�%�L�A�#5�6�B���g�q�1�u�q�y�B�&6����E��I�J�B�%��r�7�2�x��|�4�5�5r-���?r&c�r�US:wa"X-U*/5$[R"U/5$)aP164Laguerre series whose graph is a straight line.165 166Parameters167----------168off, scl : scalars169    The specified line is given by ``off + scl*x``.170 171Returns172-------173y : ndarray174    This module's representation of the Laguerre series for175    ``off + scl*x``.176 177See Also178--------179numpy.polynomial.polynomial.polyline180numpy.polynomial.chebyshev.chebline181numpy.polynomial.legendre.legline182numpy.polynomial.hermite.hermline183numpy.polynomial.hermite_e.hermeline184 185Examples186--------187>>> from numpy.polynomial.laguerre import lagline, lagval188>>> lagval(0,lagline(3, 2))1893.0190>>> lagval(1,lagline(3, 2))1915.0192 193r)�np�array)�off�scls  r,r194r195�s4��@�a�x��x�x���S�D�)�*�*��x�x����r-c�B�[R"[[U5$)a�196Generate a Laguerre series with given roots.197 198The function returns the coefficients of the polynomial199 200.. math:: p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n),201 202in Laguerre form, where the :math:`r_n` are the roots specified in `roots`.203If a zero has multiplicity n, then it must appear in `roots` n times.204For instance, if 2 is a root of multiplicity three and 3 is a root of205multiplicity 2, then `roots` looks something like [2, 2, 2, 3, 3]. The206roots can appear in any order.207 208If the returned coefficients are `c`, then209 210.. math:: p(x) = c_0 + c_1 * L_1(x) + ... +  c_n * L_n(x)211 212The coefficient of the last term is not generally 1 for monic213polynomials in Laguerre form.214 215Parameters216----------217roots : array_like218    Sequence containing the roots.219 220Returns221-------222out : ndarray223    1-D array of coefficients.  If all roots are real then `out` is a224    real array, if some of the roots are complex, then `out` is complex225    even if all the coefficients in the result are real (see Examples226    below).227 228See Also229--------230numpy.polynomial.polynomial.polyfromroots231numpy.polynomial.legendre.legfromroots232numpy.polynomial.chebyshev.chebfromroots233numpy.polynomial.hermite.hermfromroots234numpy.polynomial.hermite_e.hermefromroots235 236Examples237--------238>>> from numpy.polynomial.laguerre import lagfromroots, lagval239>>> coef = lagfromroots((-1, 0, 1))240>>> lagval((-1, 0, 1), coef)241array([0.,  0.,  0.])242>>> coef = lagfromroots((-1j, 1j))243>>> lagval((-1j, 1j), coef)244array([0.+0.j, 0.+0.j])245 246)r'�247_fromrootsr248r)�rootss r,rr�s��j�=�=��&�%�0�0r-c�.�[R"X5$)aw249Add one Laguerre series to another.250 251Returns the sum of two Laguerre series `c1` + `c2`.  The arguments252are sequences of coefficients ordered from lowest order term to253highest, i.e., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``.254 255Parameters256----------257c1, c2 : array_like258    1-D arrays of Laguerre series coefficients ordered from low to259    high.260 261Returns262-------263out : ndarray264    Array representing the Laguerre series of their sum.265 266See Also267--------268lagsub, lagmulx, lagmul, lagdiv, lagpow269 270Notes271-----272Unlike multiplication, division, etc., the sum of two Laguerre series273is a Laguerre series (without having to "reproject" the result onto274the basis set) so addition, just like that of "standard" polynomials,275is simply "component-wise."276 277Examples278--------279>>> from numpy.polynomial.laguerre import lagadd280>>> lagadd([1, 2, 3], [1, 2, 3, 4])281array([2.,  4.,  6.,  4.])282 283)r'�_add�r:�c2s  r,rr3���J�7�7�2�?�r-c�.�[R"X5$)a�284Subtract one Laguerre series from another.285 286Returns the difference of two Laguerre series `c1` - `c2`.  The287sequences of coefficients are from lowest order term to highest, i.e.,288[1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``.289 290Parameters291----------292c1, c2 : array_like293    1-D arrays of Laguerre series coefficients ordered from low to294    high.295 296Returns297-------298out : ndarray299    Of Laguerre series coefficients representing their difference.300 301See Also302--------303lagadd, lagmulx, lagmul, lagdiv, lagpow304 305Notes306-----307Unlike multiplication, division, etc., the difference of two Laguerre308series is a Laguerre series (without having to "reproject" the result309onto the basis set) so subtraction, just like that of "standard"310polynomials, is simply "component-wise."311 312Examples313--------314>>> from numpy.polynomial.laguerre import lagsub315>>> lagsub([1, 2, 3, 4], [1, 2, 3])316array([0.,  0.,  0.,  4.])317 318)r'�_subrIs  r,rr[rKr-c��[R"U/5un[U5S:XaUSS:XaU$[R"[U5S-UR319S9nUSUS'US*US'[
S[U55H>nX*US--XS-'X==XSU-S---
ss'XS-320==XU--ss'M@ U$)a�Multiply a Laguerre series by x.321 322Multiply the Laguerre series `c` by x, where x is the independent323variable.324 325 326Parameters327----------328c : array_like329    1-D array of Laguerre series coefficients ordered from low to330    high.331 332Returns333-------334out : ndarray335    Array representing the result of the multiplication.336 337See Also338--------339lagadd, lagsub, lagmul, lagdiv, lagpow340 341Notes342-----343The multiplication uses the recursion relationship for Laguerre344polynomials in the form345 346.. math::347 348    xP_i(x) = (-(i + 1)*P_{i + 1}(x) + (2i + 1)P_{i}(x) - iP_{i - 1}(x))349 350Examples351--------352>>> from numpy.polynomial.laguerre import lagmulx353>>> lagmulx([1, 2, 3])354array([-1.,  -1.,  11.,  -9.])355 356rr��dtyper3)r'r(r5r@�emptyrPr6)r7�prdr;s   r,r
r
�s���N
�,�,��s�357�C�Q�358�1�v��{�q��t�q�y���359�(�(�3�q�6�A�:�Q�W�W�360-�C�
�q�T�C��F���d�U�C��F�
�1�c�!�f�
���d�U�a�!�e�_���E�361���!�$�!�a�%�!�)�$�$����E�362�a�d�Q�h��363���Jr-c364�4�[R"X/5up[U5[U5:�aUnUnOUnUn[U5S:XaUSU-nSnO�[U5S:XaUSU-nUSU-nO�[U5nUSU-nUSU-n[S[U5S-5HOnUnUS-365n[	X&*U-XS-366-U-5n[U[	SU-S-367U-[
U55U-5nMQ [U[	U[
U555$)a�368Multiply one Laguerre series by another.369 370Returns the product of two Laguerre series `c1` * `c2`.  The arguments371are sequences of coefficients, from lowest order "term" to highest,372e.g., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``.373 374Parameters375----------376c1, c2 : array_like377    1-D arrays of Laguerre series coefficients ordered from low to378    high.379 380Returns381-------382out : ndarray383    Of Laguerre series coefficients representing their product.384 385See Also386--------387lagadd, lagsub, lagmulx, lagdiv, lagpow388 389Notes390-----391In general, the (polynomial) product of two C-series results in terms392that are not in the Laguerre polynomial basis set.  Thus, to express393the product as a Laguerre series, it is necessary to "reproject" the394product onto said basis set, which may produce "unintuitive" (but395correct) results; see Examples section below.396 397Examples398--------399>>> from numpy.polynomial.laguerre import lagmul400>>> lagmul([1, 2, 3], [0, 1, 2])401array([  8., -13.,  38., -51.,  36.])402 403rrr3r2r&�)r'r(r5r6rrr
)r:rJr7�xsr9�ndr;r<s        r,rr�s)��N�|�|�R�H�%�H�R�404�2�w��R�����
����
��405�1�v��{�
�q�T�B�Y��
��	�Q��1��
�q�T�B�Y��
�q�T�B�Y��
��V��
�r�U�R�Z��
�r�U�R�Z���q�#�a�&�1�*�%�A��C��a��B���"���406�R��6�]�b�$8�9�B���V�Q��V�a�Z�2�$5�w�r�{�C�b�H�I�B�	&�407�"�f�R����-�.�.r-c�8�[R"[X5$)a�408Divide one Laguerre series by another.409 410Returns the quotient-with-remainder of two Laguerre series411`c1` / `c2`.  The arguments are sequences of coefficients from lowest412order "term" to highest, e.g., [1,2,3] represents the series413``P_0 + 2*P_1 + 3*P_2``.414 415Parameters416----------417c1, c2 : array_like418    1-D arrays of Laguerre series coefficients ordered from low to419    high.420 421Returns422-------423[quo, rem] : ndarrays424    Of Laguerre series coefficients representing the quotient and425    remainder.426 427See Also428--------429lagadd, lagsub, lagmulx, lagmul, lagpow430 431Notes432-----433In general, the (polynomial) division of one Laguerre series by another434results in quotient and remainder terms that are not in the Laguerre435polynomial basis set.  Thus, to express these results as a Laguerre436series, it is necessary to "reproject" the results onto the Laguerre437basis set, which may produce "unintuitive" (but correct) results; see438Examples section below.439 440Examples441--------442>>> from numpy.polynomial.laguerre import lagdiv443>>> lagdiv([  8., -13.,  38., -51.,  36.], [0, 1, 2])444(array([1., 2., 3.]), array([0.]))445>>> lagdiv([  9., -12.,  38., -51.,  36.], [0, 1, 2])446(array([1., 2., 3.]), array([1., 1.]))447 448)r'�_divrrIs  r,rr�s��V�7�7�6�2�"�"r-c�:�[R"[XU5$)aRaise a Laguerre series to a power.449 450Returns the Laguerre series `c` raised to the power `pow`. The451argument `c` is a sequence of coefficients ordered from low to high.452i.e., [1,2,3] is the series  ``P_0 + 2*P_1 + 3*P_2.``453 454Parameters455----------456c : array_like457    1-D array of Laguerre series coefficients ordered from low to458    high.459pow : integer460    Power to which the series will be raised461maxpower : integer, optional462    Maximum power allowed. This is mainly to limit growth of the series463    to unmanageable size. Default is 16464 465Returns466-------467coef : ndarray468    Laguerre series of power.469 470See Also471--------472lagadd, lagsub, lagmulx, lagmul, lagdiv473 474Examples475--------476>>> from numpy.polynomial.laguerre import lagpow477>>> lagpow([1, 2, 3], 2)478array([ 14., -16.,  56., -72.,  54.])479 480)r'�_powr)r7�pow�maxpowers   r,rr)s��D�7�7�6�1�8�,�,r-c�2�[R"USSS9nURRS;aUR	[R4815n[R"US5n[R"US5nUS:a[S5e[RRRXPR5nUS:XaU$[R"XS5n[U5nXF:�a	US	SS-nO�[U5HvnUS-482nX-n[R "U4UR"SS	-URS4839n[USS5Hn	X	*X�S-484'X	S-485==X	-
ss'M  US*US'UnMx [R"USU5nU$)a_486Differentiate a Laguerre series.487 488Returns the Laguerre series coefficients `c` differentiated `m` times489along `axis`.  At each iteration the result is multiplied by `scl` (the490scaling factor is for use in a linear change of variable). The argument491`c` is an array of coefficients from low to high degree along each492axis, e.g., [1,2,3] represents the series ``1*L_0 + 2*L_1 + 3*L_2``493while [[1,2],[1,2]] represents ``1*L_0(x)*L_0(y) + 1*L_1(x)*L_0(y) +4942*L_0(x)*L_1(y) + 2*L_1(x)*L_1(y)`` if axis=0 is ``x`` and axis=1 is495``y``.496 497Parameters498----------499c : array_like500    Array of Laguerre series coefficients. If `c` is multidimensional501    the different axis correspond to different variables with the502    degree in each axis given by the corresponding index.503m : int, optional504    Number of derivatives taken, must be non-negative. (Default: 1)505scl : scalar, optional506    Each differentiation is multiplied by `scl`.  The end result is507    multiplication by ``scl**m``.  This is for use in a linear change of508    variable. (Default: 1)509axis : int, optional510    Axis over which the derivative is taken. (Default: 0).511 512Returns513-------514der : ndarray515    Laguerre series of the derivative.516 517See Also518--------519lagint520 521Notes522-----523In general, the result of differentiating a Laguerre series does not524resemble the same operation on a power series. Thus the result of this525function may be "unintuitive," albeit correct; see Examples section526below.527 528Examples529--------530>>> from numpy.polynomial.laguerre import lagder531>>> lagder([ 1.,  1.,  1., -3.])532array([1.,  2.,  3.])533>>> lagder([ 1.,  0.,  0., -4.,  3.], m=2)534array([1.,  2.,  3.])535 536rT��ndmin�copy�
?bBhHiIlLqQpPzthe order of derivation�the axisrz,The order of derivation must be non-negativeNrOr&)r@rArP�char�astype�doubler'�_as_int�537ValueError�lib�array_utils�normalize_axis_index�ndim�moveaxisr5r6rQ�shape)538r7�mrC�axis�cnt�iaxisr8r;�der�js539          r,rrNsi��j	����!�$�'�A��w�w�|�|��&�
�H�H�R�Y�Y���540�*�*�Q�1�5412�C��J�J�t�Z�(�E�542�Q�w��G�H�H��F�F���3�3�E�6�6�B�E�543�a�x���544���A�a� �A��A��A�545�x�
�b�q�E�A�I���s��A��A��A�
�H�A��(�(�A�4�!�'�'�!�"�+�-�Q�W�W�=�C��1�a��_���d�U���E�546��a�%��A�D� ��%���d�U�C��F��A��	���A�q�%� �A��Hr-c	��[R"USSS9nURRS;aUR	[R5475n[R"U5(dU/n[R"US5n[R"US5nUS:a[S5e[U5U:�a[S	5e[R"U5S:wa[S5485e[R"U5S:wa[S5e[RRRXpR5nUS:XaU$[R"XS5n[!U5S/U[U5-549--n[#U5H�n[U5n	X-nU	S:Xa2[R$"USS:H5(aUS==X(-
ss'MJ[R&"U	S-4UR(SS-URS
9n550USU551S'US*U552S'[#SU	5HnX�==X-
ss'X*X�S-'M U553S==X([+X:5-554-
ss'U555nM� [R"USU5nU$)ab556Integrate a Laguerre series.557 558Returns the Laguerre series coefficients `c` integrated `m` times from559`lbnd` along `axis`. At each iteration the resulting series is560**multiplied** by `scl` and an integration constant, `k`, is added.561The scaling factor is for use in a linear change of variable.  ("Buyer562beware": note that, depending on what one is doing, one may want `scl`563to be the reciprocal of what one might expect; for more information,564see the Notes section below.)  The argument `c` is an array of565coefficients from low to high degree along each axis, e.g., [1,2,3]566represents the series ``L_0 + 2*L_1 + 3*L_2`` while [[1,2],[1,2]]567represents ``1*L_0(x)*L_0(y) + 1*L_1(x)*L_0(y) + 2*L_0(x)*L_1(y) +5682*L_1(x)*L_1(y)`` if axis=0 is ``x`` and axis=1 is ``y``.569 570 571Parameters572----------573c : array_like574    Array of Laguerre series coefficients. If `c` is multidimensional575    the different axis correspond to different variables with the576    degree in each axis given by the corresponding index.577m : int, optional578    Order of integration, must be positive. (Default: 1)579k : {[], list, scalar}, optional580    Integration constant(s).  The value of the first integral at581    ``lbnd`` is the first value in the list, the value of the second582    integral at ``lbnd`` is the second value, etc.  If ``k == []`` (the583    default), all constants are set to zero.  If ``m == 1``, a single584    scalar can be given instead of a list.585lbnd : scalar, optional586    The lower bound of the integral. (Default: 0)587scl : scalar, optional588    Following each integration the result is *multiplied* by `scl`589    before the integration constant is added. (Default: 1)590axis : int, optional591    Axis over which the integral is taken. (Default: 0).592 593Returns594-------595S : ndarray596    Laguerre series coefficients of the integral.597 598Raises599------600ValueError601    If ``m < 0``, ``len(k) > m``, ``np.ndim(lbnd) != 0``, or602    ``np.ndim(scl) != 0``.603 604See Also605--------606lagder607 608Notes609-----610Note that the result of each integration is *multiplied* by `scl`.611Why is this important to note?  Say one is making a linear change of612variable :math:`u = ax + b` in an integral relative to `x`.  Then613:math:`dx = du/a`, so one will need to set `scl` equal to614:math:`1/a` - perhaps not what one would have first thought.615 616Also note that, in general, the result of integrating a C-series needs617to be "reprojected" onto the C-series basis set.  Thus, typically,618the result of this function is "unintuitive," albeit correct; see619Examples section below.620 621Examples622--------623>>> from numpy.polynomial.laguerre import lagint624>>> lagint([1,2,3])625array([ 1.,  1.,  1., -3.])626>>> lagint([1,2,3], m=2)627array([ 1.,  0.,  0., -4.,  3.])628>>> lagint([1,2,3], k=1)629array([ 2.,  1.,  1., -3.])630>>> lagint([1,2,3], lbnd=-1)631array([11.5,  1. ,  1. , -3. ])632>>> lagint([1,2], m=2, k=[1,2], lbnd=-1)633array([ 11.16666667,  -5.        ,  -3.        ,   2.        ]) # may vary634 635rTr^razthe order of integrationrbrz-The order of integration must be non-negativezToo many integration constantszlbnd must be a scalar.zscl must be a scalar.NrO)r@rArPrcrdre�iterabler'rfrgr5rkrhrirjrl�listr6�allrQrmr)r7rn�k�lbndrCrorprqr;r8r<rss            r,rr�s��d	����!�$�'�A��w�w�|�|��&�
�H�H�R�Y�Y���
�;�;�q�>�>�
�C��636�*�*�Q�2�6373�C��J�J�t�Z�(�E�638�Q�w��H�I�I�639�1�v��|��9�:�:�	�w�w�t�}����1�2�2�	�w�w�s�|�q���0�1�1��F�F���3�3�E�6�6�B�E�640�a�x���641���A�a� �A��Q��1�#��s�1�v��&�&�A�
�3�Z����F��	�����6�b�f�f�Q�q�T�Q�Y�'�'�
�a�D�A�D�L�D��(�(�A��E�8�a�g�g�a�b�k�1����A�C��q�T�C��F���d�U�C��F��1�a�[����!�$����d�U���E�642�!�
��F�a�d�V�D�.�.�.�F��A��	���A�q�%� �A��Hr-c���[R"USSS9nURRS;aUR	[R6435n[
U[[45(a[R"U5n[
U[R5(a2U(a+URURSUR--5n[U5S:XaUSnSnOx[U5S:XaUSnUSnO^[U5nUSnUS	n[S644[U5S-5H-nUnUS-645nX*XES-646-U--647nXtSU-S-648U-649-U--nM/ X4SU-650--$)a5	651Evaluate a Laguerre series at points x.652 653If `c` is of length ``n + 1``, this function returns the value:654 655.. math:: p(x) = c_0 * L_0(x) + c_1 * L_1(x) + ... + c_n * L_n(x)656 657The parameter `x` is converted to an array only if it is a tuple or a658list, otherwise it is treated as a scalar. In either case, either `x`659or its elements must support multiplication and addition both with660themselves and with the elements of `c`.661 662If `c` is a 1-D array, then ``p(x)`` will have the same shape as `x`.  If663`c` is multidimensional, then the shape of the result depends on the664value of `tensor`. If `tensor` is true the shape will be c.shape[1:] +665x.shape. If `tensor` is false the shape will be c.shape[1:]. Note that666scalars have shape (,).667 668Trailing zeros in the coefficients will be used in the evaluation, so669they should be avoided if efficiency is a concern.670 671Parameters672----------673x : array_like, compatible object674    If `x` is a list or tuple, it is converted to an ndarray, otherwise675    it is left unchanged and treated as a scalar. In either case, `x`676    or its elements must support addition and multiplication with677    themselves and with the elements of `c`.678c : array_like679    Array of coefficients ordered so that the coefficients for terms of680    degree n are contained in c[n]. If `c` is multidimensional the681    remaining indices enumerate multiple polynomials. In the two682    dimensional case the coefficients may be thought of as stored in683    the columns of `c`.684tensor : boolean, optional685    If True, the shape of the coefficient array is extended with ones686    on the right, one for each dimension of `x`. Scalars have dimension 0687    for this action. The result is that every column of coefficients in688    `c` is evaluated for every element of `x`. If False, `x` is broadcast689    over the columns of `c` for the evaluation.  This keyword is useful690    when `c` is multidimensional. The default value is True.691 692Returns693-------694values : ndarray, algebra_like695    The shape of the return value is described above.696 697See Also698--------699lagval2d, laggrid2d, lagval3d, laggrid3d700 701Notes702-----703The evaluation uses Clenshaw recursion, aka synthetic division.704 705Examples706--------707>>> from numpy.polynomial.laguerre import lagval708>>> coef = [1, 2, 3]709>>> lagval(1, coef)710-0.5711>>> lagval([[1, 2],[3, 4]], coef)712array([[-0.5, -4. ],713       [-4.5, -2. ]])714 715rNr^ra)rrr3r2r&rT)r@rArPrcrdre�716isinstance�tuplerv�asarray�ndarray�reshapermrkr5r6)�xr7�tensorr9r:rVr;r<s        r,rrsL��F	����!�$�'�A��w�w�|�|��&�
�H�H�R�Y�Y����!�e�T�]�#�#��J�J�q�M���!�R�Z�Z� � �V�
�I�I�a�g�g��q�v�v�
�-�.��717�1�v��{�
�q�T��
��	�Q��1��
�q�T��
�q�T��
��V��
�r�U��
�r�U���q�#�a�&�1�*�%�A��C��a��B��2��"�Q��-�2�-�-�B��q�2�v��z�Q�.�/�2�5�5�B�	&�718�a�!�e���r-c�:�[R"[X U5$)a719720Evaluate a 2-D Laguerre series at points (x, y).721 722This function returns the values:723 724.. math:: p(x,y) = \sum_{i,j} c_{i,j} * L_i(x) * L_j(y)725 726The parameters `x` and `y` are converted to arrays only if they are727tuples or a lists, otherwise they are treated as a scalars and they728must have the same shape after conversion. In either case, either `x`729and `y` or their elements must support multiplication and addition both730with themselves and with the elements of `c`.731 732If `c` is a 1-D array a one is implicitly appended to its shape to make733it 2-D. The shape of the result will be c.shape[2:] + x.shape.734 735Parameters736----------737x, y : array_like, compatible objects738    The two dimensional series is evaluated at the points ``(x, y)``,739    where `x` and `y` must have the same shape. If `x` or `y` is a list740    or tuple, it is first converted to an ndarray, otherwise it is left741    unchanged and if it isn't an ndarray it is treated as a scalar.742c : array_like743    Array of coefficients ordered so that the coefficient of the term744    of multi-degree i,j is contained in ``c[i,j]``. If `c` has745    dimension greater than two the remaining indices enumerate multiple746    sets of coefficients.747 748Returns749-------750values : ndarray, compatible object751    The values of the two dimensional polynomial at points formed with752    pairs of corresponding values from `x` and `y`.753 754See Also755--------756lagval, laggrid2d, lagval3d, laggrid3d757 758Examples759--------760>>> from numpy.polynomial.laguerre import lagval2d761>>> c = [[1, 2],[3, 4]]762>>> lagval2d(1, 1, c)7631.0764�r'�_valndr�r��yr7s   r,rrys��^�9�9�V�Q�1�%�%r-c�:�[R"[X U5$)a�765Evaluate a 2-D Laguerre series on the Cartesian product of x and y.766 767This function returns the values:768 769.. math:: p(a,b) = \sum_{i,j} c_{i,j} * L_i(a) * L_j(b)770 771where the points ``(a, b)`` consist of all pairs formed by taking772`a` from `x` and `b` from `y`. The resulting points form a grid with773`x` in the first dimension and `y` in the second.774 775The parameters `x` and `y` are converted to arrays only if they are776tuples or a lists, otherwise they are treated as a scalars. In either777case, either `x` and `y` or their elements must support multiplication778and addition both with themselves and with the elements of `c`.779 780If `c` has fewer than two dimensions, ones are implicitly appended to781its shape to make it 2-D. The shape of the result will be c.shape[2:] +782x.shape + y.shape.783 784Parameters785----------786x, y : array_like, compatible objects787    The two dimensional series is evaluated at the points in the788    Cartesian product of `x` and `y`.  If `x` or `y` is a list or789    tuple, it is first converted to an ndarray, otherwise it is left790    unchanged and, if it isn't an ndarray, it is treated as a scalar.791c : array_like792    Array of coefficients ordered so that the coefficient of the term of793    multi-degree i,j is contained in ``c[i,j]``. If `c` has dimension794    greater than two the remaining indices enumerate multiple sets of795    coefficients.796 797Returns798-------799values : ndarray, compatible object800    The values of the two dimensional Chebyshev series at points in the801    Cartesian product of `x` and `y`.802 803See Also804--------805lagval, lagval2d, lagval3d, laggrid3d806 807Examples808--------809>>> from numpy.polynomial.laguerre import laggrid2d810>>> c = [[1, 2], [3, 4]]811>>> laggrid2d([0, 1], [0, 1], c)812array([[10.,  4.],813       [ 3.,  1.]])814 815�r'�_gridndrr�s   r,rr�s��j�:�:�f�a�A�&�&r-c�:�[R"[X0X5$)a{816Evaluate a 3-D Laguerre series at points (x, y, z).817 818This function returns the values:819 820.. math:: p(x,y,z) = \sum_{i,j,k} c_{i,j,k} * L_i(x) * L_j(y) * L_k(z)821 822The parameters `x`, `y`, and `z` are converted to arrays only if823they are tuples or a lists, otherwise they are treated as a scalars and824they must have the same shape after conversion. In either case, either825`x`, `y`, and `z` or their elements must support multiplication and826addition both with themselves and with the elements of `c`.827 828If `c` has fewer than 3 dimensions, ones are implicitly appended to its829shape to make it 3-D. The shape of the result will be c.shape[3:] +830x.shape.831 832Parameters833----------834x, y, z : array_like, compatible object835    The three dimensional series is evaluated at the points836    ``(x, y, z)``, where `x`, `y`, and `z` must have the same shape.  If837    any of `x`, `y`, or `z` is a list or tuple, it is first converted838    to an ndarray, otherwise it is left unchanged and if it isn't an839    ndarray it is  treated as a scalar.840c : array_like841    Array of coefficients ordered so that the coefficient of the term of842    multi-degree i,j,k is contained in ``c[i,j,k]``. If `c` has dimension843    greater than 3 the remaining indices enumerate multiple sets of844    coefficients.845 846Returns847-------848values : ndarray, compatible object849    The values of the multidimensional polynomial on points formed with850    triples of corresponding values from `x`, `y`, and `z`.851 852See Also853--------854lagval, lagval2d, laggrid2d, laggrid3d855 856Examples857--------858>>> from numpy.polynomial.laguerre import lagval3d859>>> c = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]860>>> lagval3d(1, 1, 2, c)861-1.0862 863r��r�r��zr7s    r,rr�s��d�9�9�V�Q�1�(�(r-c�:�[R"[X0X5$)a�864Evaluate a 3-D Laguerre series on the Cartesian product of x, y, and z.865 866This function returns the values:867 868.. math:: p(a,b,c) = \sum_{i,j,k} c_{i,j,k} * L_i(a) * L_j(b) * L_k(c)869 870where the points ``(a, b, c)`` consist of all triples formed by taking871`a` from `x`, `b` from `y`, and `c` from `z`. The resulting points form872a grid with `x` in the first dimension, `y` in the second, and `z` in873the third.874 875The parameters `x`, `y`, and `z` are converted to arrays only if they876are tuples or a lists, otherwise they are treated as a scalars. In877either case, either `x`, `y`, and `z` or their elements must support878multiplication and addition both with themselves and with the elements879of `c`.880 881If `c` has fewer than three dimensions, ones are implicitly appended to882its shape to make it 3-D. The shape of the result will be c.shape[3:] +883x.shape + y.shape + z.shape.884 885Parameters886----------887x, y, z : array_like, compatible objects888    The three dimensional series is evaluated at the points in the889    Cartesian product of `x`, `y`, and `z`.  If `x`, `y`, or `z` is a890    list or tuple, it is first converted to an ndarray, otherwise it is891    left unchanged and, if it isn't an ndarray, it is treated as a892    scalar.893c : array_like894    Array of coefficients ordered so that the coefficients for terms of895    degree i,j are contained in ``c[i,j]``. If `c` has dimension896    greater than two the remaining indices enumerate multiple sets of897    coefficients.898 899Returns900-------901values : ndarray, compatible object902    The values of the two dimensional polynomial at points in the Cartesian903    product of `x` and `y`.904 905See Also906--------907lagval, lagval2d, laggrid2d, lagval3d908 909Examples910--------911>>> from numpy.polynomial.laguerre import laggrid3d912>>> c = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]913>>> laggrid3d([0, 1], [0, 1], [2, 4], c)914array([[[ -4., -44.],915        [ -2., -18.]],916       [[ -2., -14.],917        [ -1.,  -5.]]])918 919r�r�s    r,rrs��t�:�:�f�a�A�)�)r-c���[R"US5nUS:a[S5e[R"USSS9S-nUS-4UR920-nURn[R"X4S9nUS-S-US'US:�aDSU-921US'[S	US-5H)nXVS-922S	U-S-923U-924-XVS	-925US-926--927U-XV'M+ [R"USS9285$)a�Pseudo-Vandermonde matrix of given degree.929 930Returns the pseudo-Vandermonde matrix of degree `deg` and sample points931`x`. The pseudo-Vandermonde matrix is defined by932 933.. math:: V[..., i] = L_i(x)934 935where ``0 <= i <= deg``. The leading indices of `V` index the elements of936`x` and the last index is the degree of the Laguerre polynomial.937 938If `c` is a 1-D array of coefficients of length ``n + 1`` and `V` is the939array ``V = lagvander(x, n)``, then ``np.dot(V, c)`` and940``lagval(x, c)`` are the same up to roundoff. This equivalence is941useful both for least squares fitting and for the evaluation of a large942number of Laguerre series of the same degree and sample points.943 944Parameters945----------946x : array_like947    Array of points. The dtype is converted to float64 or complex128948    depending on whether any of the elements are complex. If `x` is949    scalar it is converted to a 1-D array.950deg : int951    Degree of the resulting matrix.952 953Returns954-------955vander : ndarray956    The pseudo-Vandermonde matrix. The shape of the returned matrix is957    ``x.shape + (deg + 1,)``, where The last index is the degree of the958    corresponding Laguerre polynomial.  The dtype will be the same as959    the converted `x`.960 961Examples962--------963>>> import numpy as np964>>> from numpy.polynomial.laguerre import lagvander965>>> x = np.array([0, 1, 2])966>>> lagvander(x, 3)967array([[ 1.        ,  1.        ,  1.        ,  1.        ],968       [ 1.        ,  0.        , -0.5       , -0.66666667],969       [ 1.        , -1.        , -1.        , -0.33333333]])970 971�degrzdeg must be non-negativeNr)r`r_r=rOr3r&)972r'rfrgr@rArmrPrQr6rl)r�r��ideg�dims�dtyp�vr;s       r,rrUs���Z�:�:�c�5�!�D��a�x��3�4�4�973�����Q�'�#�-�A��1�H�;���� �D��7�7�D�974����"�A��q�5�1�9�A�a�D��a�x��1�u��!���q�$��(�#�A��!�e�H��A���	�A�
�.��q�5��Q��U�1C�C�q�H�A�D�$�
�;�;�q�!�R� � r-c�H�[R"[[4X4U5$)a�Pseudo-Vandermonde matrix of given degrees.975 976Returns the pseudo-Vandermonde matrix of degrees `deg` and sample977points ``(x, y)``. The pseudo-Vandermonde matrix is defined by978 979.. math:: V[..., (deg[1] + 1)*i + j] = L_i(x) * L_j(y),980 981where ``0 <= i <= deg[0]`` and ``0 <= j <= deg[1]``. The leading indices of982`V` index the points ``(x, y)`` and the last index encodes the degrees of983the Laguerre polynomials.984 985If ``V = lagvander2d(x, y, [xdeg, ydeg])``, then the columns of `V`986correspond to the elements of a 2-D coefficient array `c` of shape987(xdeg + 1, ydeg + 1) in the order988 989.. math:: c_{00}, c_{01}, c_{02}, ... , c_{10}, c_{11}, c_{12}, ...990 991and ``np.dot(V, c.flat)`` and ``lagval2d(x, y, c)`` will be the same992up to roundoff. This equivalence is useful both for least squares993fitting and for the evaluation of a large number of 2-D Laguerre994series of the same degrees and sample points.995 996Parameters997----------998x, y : array_like999    Arrays of point coordinates, all of the same shape. The dtypes1000    will be converted to either float64 or complex128 depending on1001    whether any of the elements are complex. Scalars are converted to1002    1-D arrays.1003deg : list of ints1004    List of maximum degrees of the form [x_deg, y_deg].1005 1006Returns1007-------1008vander2d : ndarray1009    The shape of the returned matrix is ``x.shape + (order,)``, where1010    :math:`order = (deg[0]+1)*(deg[1]+1)`.  The dtype will be the same1011    as the converted `x` and `y`.1012 1013See Also1014--------1015lagvander, lagvander3d, lagval2d, lagval3d1016 1017Examples1018--------1019>>> import numpy as np1020>>> from numpy.polynomial.laguerre import lagvander2d1021>>> x = np.array([0])1022>>> y = np.array([2])1023>>> lagvander2d(x, y, [2, 1])1024array([[ 1., -1.,  1., -1.,  1., -1.]])1025 1026�r'�_vander_nd_flatr)r�r�r�s   r,r r �s!��l���y�)�4�q�f�c�B�Br-c�T�[R"[[[4XU4U5$)a�Pseudo-Vandermonde matrix of given degrees.1027 1028Returns the pseudo-Vandermonde matrix of degrees `deg` and sample1029points ``(x, y, z)``. If `l`, `m`, `n` are the given degrees in `x`, `y`, `z`,1030then The pseudo-Vandermonde matrix is defined by1031 1032.. math:: V[..., (m+1)(n+1)i + (n+1)j + k] = L_i(x)*L_j(y)*L_k(z),1033 1034where ``0 <= i <= l``, ``0 <= j <= m``, and ``0 <= j <= n``.  The leading1035indices of `V` index the points ``(x, y, z)`` and the last index encodes1036the degrees of the Laguerre polynomials.1037 1038If ``V = lagvander3d(x, y, z, [xdeg, ydeg, zdeg])``, then the columns1039of `V` correspond to the elements of a 3-D coefficient array `c` of1040shape (xdeg + 1, ydeg + 1, zdeg + 1) in the order1041 1042.. math:: c_{000}, c_{001}, c_{002},... , c_{010}, c_{011}, c_{012},...1043 1044and  ``np.dot(V, c.flat)`` and ``lagval3d(x, y, z, c)`` will be the1045same up to roundoff. This equivalence is useful both for least squares1046fitting and for the evaluation of a large number of 3-D Laguerre1047series of the same degrees and sample points.1048 1049Parameters1050----------1051x, y, z : array_like1052    Arrays of point coordinates, all of the same shape. The dtypes will1053    be converted to either float64 or complex128 depending on whether1054    any of the elements are complex. Scalars are converted to 1-D1055    arrays.1056deg : list of ints1057    List of maximum degrees of the form [x_deg, y_deg, z_deg].1058 1059Returns1060-------1061vander3d : ndarray1062    The shape of the returned matrix is ``x.shape + (order,)``, where1063    :math:`order = (deg[0]+1)*(deg[1]+1)*(deg[2]+1)`.  The dtype will1064    be the same as the converted `x`, `y`, and `z`.1065 1066See Also1067--------1068lagvander, lagvander3d, lagval2d, lagval3d1069 1070Examples1071--------1072>>> import numpy as np1073>>> from numpy.polynomial.laguerre import lagvander3d1074>>> x = np.array([0])1075>>> y = np.array([2])1076>>> z = np.array([0])1077>>> lagvander3d(x, y, z, [2, 1, 3])1078array([[ 1.,  1.,  1.,  1., -1., -1., -1., -1.,  1.,  1.,  1.,  1., -1.,1079        -1., -1., -1.,  1.,  1.,  1.,  1., -1., -1., -1., -1.]])1080 1081r�)r�r�r�r�s    r,r!r!�s%��r���y�)�Y�?�!���C�P�Pr-c	�<�[R"[XX#XE5$)a�1082Least squares fit of Laguerre series to data.1083 1084Return the coefficients of a Laguerre series of degree `deg` that is the1085least squares fit to the data values `y` given at points `x`. If `y` is10861-D the returned coefficients will also be 1-D. If `y` is 2-D multiple1087fits are done, one for each column of `y`, and the resulting1088coefficients are stored in the corresponding columns of a 2-D return.1089The fitted polynomial(s) are in the form1090 1091.. math::  p(x) = c_0 + c_1 * L_1(x) + ... + c_n * L_n(x),1092 1093where ``n`` is `deg`.1094 1095Parameters1096----------1097x : array_like, shape (M,)1098    x-coordinates of the M sample points ``(x[i], y[i])``.1099y : array_like, shape (M,) or (M, K)1100    y-coordinates of the sample points. Several data sets of sample1101    points sharing the same x-coordinates can be fitted at once by1102    passing in a 2D-array that contains one dataset per column.1103deg : int or 1-D array_like1104    Degree(s) of the fitting polynomials. If `deg` is a single integer1105    all terms up to and including the `deg`'th term are included in the1106    fit. For NumPy versions >= 1.11.0 a list of integers specifying the1107    degrees of the terms to include may be used instead.1108rcond : float, optional1109    Relative condition number of the fit. Singular values smaller than1110    this relative to the largest singular value will be ignored. The1111    default value is len(x)*eps, where eps is the relative precision of1112    the float type, about 2e-16 in most cases.1113full : bool, optional1114    Switch determining nature of return value. When it is False (the1115    default) just the coefficients are returned, when True diagnostic1116    information from the singular value decomposition is also returned.1117w : array_like, shape (`M`,), optional1118    Weights. If not None, the weight ``w[i]`` applies to the unsquared1119    residual ``y[i] - y_hat[i]`` at ``x[i]``. Ideally the weights are1120    chosen so that the errors of the products ``w[i]*y[i]`` all have the1121    same variance.  When using inverse-variance weighting, use1122    ``w[i] = 1/sigma(y[i])``.  The default value is None.1123 1124Returns1125-------1126coef : ndarray, shape (M,) or (M, K)1127    Laguerre coefficients ordered from low to high. If `y` was 2-D,1128    the coefficients for the data in column *k*  of `y` are in column1129    *k*.1130 1131[residuals, rank, singular_values, rcond] : list1132    These values are only returned if ``full == True``1133 1134    - residuals -- sum of squared residuals of the least squares fit1135    - rank -- the numerical rank of the scaled Vandermonde matrix1136    - singular_values -- singular values of the scaled Vandermonde matrix1137    - rcond -- value of `rcond`.1138 1139    For more details, see `numpy.linalg.lstsq`.1140 1141Warns1142-----1143RankWarning1144    The rank of the coefficient matrix in the least-squares fit is1145    deficient. The warning is only raised if ``full == False``.  The1146    warnings can be turned off by1147 1148    >>> import warnings1149    >>> warnings.simplefilter('ignore', np.exceptions.RankWarning)1150 1151See Also1152--------1153numpy.polynomial.polynomial.polyfit1154numpy.polynomial.legendre.legfit1155numpy.polynomial.chebyshev.chebfit1156numpy.polynomial.hermite.hermfit1157numpy.polynomial.hermite_e.hermefit1158lagval : Evaluates a Laguerre series.1159lagvander : pseudo Vandermonde matrix of Laguerre series.1160lagweight : Laguerre weight function.1161numpy.linalg.lstsq : Computes a least-squares fit from the matrix.1162scipy.interpolate.UnivariateSpline : Computes spline fits.1163 1164Notes1165-----1166The solution is the coefficients of the Laguerre series ``p`` that1167minimizes the sum of the weighted squared errors1168 1169.. math:: E = \sum_j w_j^2 * |y_j - p(x_j)|^2,1170 1171where the :math:`w_j` are the weights. This problem is solved by1172setting up as the (typically) overdetermined matrix equation1173 1174.. math:: V(x) * c = w * y,1175 1176where ``V`` is the weighted pseudo Vandermonde matrix of `x`, ``c`` are the1177coefficients to be solved for, `w` are the weights, and `y` are the1178observed values.  This equation is then solved using the singular value1179decomposition of ``V``.1180 1181If some of the singular values of `V` are so small that they are1182neglected, then a `~exceptions.RankWarning` will be issued. This means that1183the coefficient values may be poorly determined. Using a lower order fit1184will usually get rid of the warning.  The `rcond` parameter can also be1185set to a value smaller than its default, but the resulting fit may be1186spurious and have large contributions from roundoff error.1187 1188Fits using Laguerre series are probably most useful when the data can1189be approximated by ``sqrt(w(x)) * p(x)``, where ``w(x)`` is the Laguerre1190weight. In that case the weight ``sqrt(w(x[i]))`` should be used1191together with data values ``y[i]/sqrt(w(x[i]))``. The weight function is1192available as `lagweight`.1193 1194References1195----------1196.. [1] Wikipedia, "Curve fitting",1197       https://en.wikipedia.org/wiki/Curve_fitting1198 1199Examples1200--------

Showing the first 1,200 of 1403 lines. Download the file for the rest.

codekingpro/portable-devtools · Team Ai