Path: blob/master/ invest-robot-contest_TinkoffBotTwitch-main/venv/lib/python3.8/site-packages/numpy/polynomial/laguerre.py
7813 views
"""1==================================================2Laguerre Series (:mod:`numpy.polynomial.laguerre`)3==================================================45This module provides a number of objects (mostly functions) useful for6dealing with Laguerre series, including a `Laguerre` class that7encapsulates the usual arithmetic operations. (General information8on how this module represents and works with such polynomials is in the9docstring for its "parent" sub-package, `numpy.polynomial`).1011Classes12-------13.. autosummary::14:toctree: generated/1516Laguerre1718Constants19---------20.. autosummary::21:toctree: generated/2223lagdomain24lagzero25lagone26lagx2728Arithmetic29----------30.. autosummary::31:toctree: generated/3233lagadd34lagsub35lagmulx36lagmul37lagdiv38lagpow39lagval40lagval2d41lagval3d42laggrid2d43laggrid3d4445Calculus46--------47.. autosummary::48:toctree: generated/4950lagder51lagint5253Misc Functions54--------------55.. autosummary::56:toctree: generated/5758lagfromroots59lagroots60lagvander61lagvander2d62lagvander3d63laggauss64lagweight65lagcompanion66lagfit67lagtrim68lagline69lag2poly70poly2lag7172See also73--------74`numpy.polynomial`7576"""77import numpy as np78import numpy.linalg as la79from numpy.core.multiarray import normalize_axis_index8081from . import polyutils as pu82from ._polybase import ABCPolyBase8384__all__ = [85'lagzero', 'lagone', 'lagx', 'lagdomain', 'lagline', 'lagadd',86'lagsub', 'lagmulx', 'lagmul', 'lagdiv', 'lagpow', 'lagval', 'lagder',87'lagint', 'lag2poly', 'poly2lag', 'lagfromroots', 'lagvander',88'lagfit', 'lagtrim', 'lagroots', 'Laguerre', 'lagval2d', 'lagval3d',89'laggrid2d', 'laggrid3d', 'lagvander2d', 'lagvander3d', 'lagcompanion',90'laggauss', 'lagweight']9192lagtrim = pu.trimcoef939495def poly2lag(pol):96"""97poly2lag(pol)9899Convert a polynomial to a Laguerre series.100101Convert an array representing the coefficients of a polynomial (relative102to the "standard" basis) ordered from lowest degree to highest, to an103array of the coefficients of the equivalent Laguerre series, ordered104from lowest to highest degree.105106Parameters107----------108pol : array_like1091-D array containing the polynomial coefficients110111Returns112-------113c : ndarray1141-D array containing the coefficients of the equivalent Laguerre115series.116117See Also118--------119lag2poly120121Notes122-----123The easy way to do conversions between polynomial basis sets124is to use the convert method of a class instance.125126Examples127--------128>>> from numpy.polynomial.laguerre import poly2lag129>>> poly2lag(np.arange(4))130array([ 23., -63., 58., -18.])131132"""133[pol] = pu.as_series([pol])134res = 0135for p in pol[::-1]:136res = lagadd(lagmulx(res), p)137return res138139140def lag2poly(c):141"""142Convert a Laguerre series to a polynomial.143144Convert an array representing the coefficients of a Laguerre series,145ordered from lowest degree to highest, to an array of the coefficients146of the equivalent polynomial (relative to the "standard" basis) ordered147from lowest to highest degree.148149Parameters150----------151c : array_like1521-D array containing the Laguerre series coefficients, ordered153from lowest order term to highest.154155Returns156-------157pol : ndarray1581-D array containing the coefficients of the equivalent polynomial159(relative to the "standard" basis) ordered from lowest order term160to highest.161162See Also163--------164poly2lag165166Notes167-----168The easy way to do conversions between polynomial basis sets169is to use the convert method of a class instance.170171Examples172--------173>>> from numpy.polynomial.laguerre import lag2poly174>>> lag2poly([ 23., -63., 58., -18.])175array([0., 1., 2., 3.])176177"""178from .polynomial import polyadd, polysub, polymulx179180[c] = pu.as_series([c])181n = len(c)182if n == 1:183return c184else:185c0 = c[-2]186c1 = c[-1]187# i is the current degree of c1188for i in range(n - 1, 1, -1):189tmp = c0190c0 = polysub(c[i - 2], (c1*(i - 1))/i)191c1 = polyadd(tmp, polysub((2*i - 1)*c1, polymulx(c1))/i)192return polyadd(c0, polysub(c1, polymulx(c1)))193194#195# These are constant arrays are of integer type so as to be compatible196# with the widest range of other types, such as Decimal.197#198199# Laguerre200lagdomain = np.array([0, 1])201202# Laguerre coefficients representing zero.203lagzero = np.array([0])204205# Laguerre coefficients representing one.206lagone = np.array([1])207208# Laguerre coefficients representing the identity x.209lagx = np.array([1, -1])210211212def lagline(off, scl):213"""214Laguerre series whose graph is a straight line.215216Parameters217----------218off, scl : scalars219The specified line is given by ``off + scl*x``.220221Returns222-------223y : ndarray224This module's representation of the Laguerre series for225``off + scl*x``.226227See Also228--------229numpy.polynomial.polynomial.polyline230numpy.polynomial.chebyshev.chebline231numpy.polynomial.legendre.legline232numpy.polynomial.hermite.hermline233numpy.polynomial.hermite_e.hermeline234235Examples236--------237>>> from numpy.polynomial.laguerre import lagline, lagval238>>> lagval(0,lagline(3, 2))2393.0240>>> lagval(1,lagline(3, 2))2415.0242243"""244if scl != 0:245return np.array([off + scl, -scl])246else:247return np.array([off])248249250def lagfromroots(roots):251"""252Generate a Laguerre series with given roots.253254The function returns the coefficients of the polynomial255256.. math:: p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n),257258in Laguerre form, where the `r_n` are the roots specified in `roots`.259If a zero has multiplicity n, then it must appear in `roots` n times.260For instance, if 2 is a root of multiplicity three and 3 is a root of261multiplicity 2, then `roots` looks something like [2, 2, 2, 3, 3]. The262roots can appear in any order.263264If the returned coefficients are `c`, then265266.. math:: p(x) = c_0 + c_1 * L_1(x) + ... + c_n * L_n(x)267268The coefficient of the last term is not generally 1 for monic269polynomials in Laguerre form.270271Parameters272----------273roots : array_like274Sequence containing the roots.275276Returns277-------278out : ndarray2791-D array of coefficients. If all roots are real then `out` is a280real array, if some of the roots are complex, then `out` is complex281even if all the coefficients in the result are real (see Examples282below).283284See Also285--------286numpy.polynomial.polynomial.polyfromroots287numpy.polynomial.legendre.legfromroots288numpy.polynomial.chebyshev.chebfromroots289numpy.polynomial.hermite.hermfromroots290numpy.polynomial.hermite_e.hermefromroots291292Examples293--------294>>> from numpy.polynomial.laguerre import lagfromroots, lagval295>>> coef = lagfromroots((-1, 0, 1))296>>> lagval((-1, 0, 1), coef)297array([0., 0., 0.])298>>> coef = lagfromroots((-1j, 1j))299>>> lagval((-1j, 1j), coef)300array([0.+0.j, 0.+0.j])301302"""303return pu._fromroots(lagline, lagmul, roots)304305306def lagadd(c1, c2):307"""308Add one Laguerre series to another.309310Returns the sum of two Laguerre series `c1` + `c2`. The arguments311are sequences of coefficients ordered from lowest order term to312highest, i.e., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``.313314Parameters315----------316c1, c2 : array_like3171-D arrays of Laguerre series coefficients ordered from low to318high.319320Returns321-------322out : ndarray323Array representing the Laguerre series of their sum.324325See Also326--------327lagsub, lagmulx, lagmul, lagdiv, lagpow328329Notes330-----331Unlike multiplication, division, etc., the sum of two Laguerre series332is a Laguerre series (without having to "reproject" the result onto333the basis set) so addition, just like that of "standard" polynomials,334is simply "component-wise."335336Examples337--------338>>> from numpy.polynomial.laguerre import lagadd339>>> lagadd([1, 2, 3], [1, 2, 3, 4])340array([2., 4., 6., 4.])341342343"""344return pu._add(c1, c2)345346347def lagsub(c1, c2):348"""349Subtract one Laguerre series from another.350351Returns the difference of two Laguerre series `c1` - `c2`. The352sequences of coefficients are from lowest order term to highest, i.e.,353[1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``.354355Parameters356----------357c1, c2 : array_like3581-D arrays of Laguerre series coefficients ordered from low to359high.360361Returns362-------363out : ndarray364Of Laguerre series coefficients representing their difference.365366See Also367--------368lagadd, lagmulx, lagmul, lagdiv, lagpow369370Notes371-----372Unlike multiplication, division, etc., the difference of two Laguerre373series is a Laguerre series (without having to "reproject" the result374onto the basis set) so subtraction, just like that of "standard"375polynomials, is simply "component-wise."376377Examples378--------379>>> from numpy.polynomial.laguerre import lagsub380>>> lagsub([1, 2, 3, 4], [1, 2, 3])381array([0., 0., 0., 4.])382383"""384return pu._sub(c1, c2)385386387def lagmulx(c):388"""Multiply a Laguerre series by x.389390Multiply the Laguerre series `c` by x, where x is the independent391variable.392393394Parameters395----------396c : array_like3971-D array of Laguerre series coefficients ordered from low to398high.399400Returns401-------402out : ndarray403Array representing the result of the multiplication.404405See Also406--------407lagadd, lagsub, lagmul, lagdiv, lagpow408409Notes410-----411The multiplication uses the recursion relationship for Laguerre412polynomials in the form413414.. math::415416xP_i(x) = (-(i + 1)*P_{i + 1}(x) + (2i + 1)P_{i}(x) - iP_{i - 1}(x))417418Examples419--------420>>> from numpy.polynomial.laguerre import lagmulx421>>> lagmulx([1, 2, 3])422array([-1., -1., 11., -9.])423424"""425# c is a trimmed copy426[c] = pu.as_series([c])427# The zero series needs special treatment428if len(c) == 1 and c[0] == 0:429return c430431prd = np.empty(len(c) + 1, dtype=c.dtype)432prd[0] = c[0]433prd[1] = -c[0]434for i in range(1, len(c)):435prd[i + 1] = -c[i]*(i + 1)436prd[i] += c[i]*(2*i + 1)437prd[i - 1] -= c[i]*i438return prd439440441def lagmul(c1, c2):442"""443Multiply one Laguerre series by another.444445Returns the product of two Laguerre series `c1` * `c2`. The arguments446are sequences of coefficients, from lowest order "term" to highest,447e.g., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``.448449Parameters450----------451c1, c2 : array_like4521-D arrays of Laguerre series coefficients ordered from low to453high.454455Returns456-------457out : ndarray458Of Laguerre series coefficients representing their product.459460See Also461--------462lagadd, lagsub, lagmulx, lagdiv, lagpow463464Notes465-----466In general, the (polynomial) product of two C-series results in terms467that are not in the Laguerre polynomial basis set. Thus, to express468the product as a Laguerre series, it is necessary to "reproject" the469product onto said basis set, which may produce "unintuitive" (but470correct) results; see Examples section below.471472Examples473--------474>>> from numpy.polynomial.laguerre import lagmul475>>> lagmul([1, 2, 3], [0, 1, 2])476array([ 8., -13., 38., -51., 36.])477478"""479# s1, s2 are trimmed copies480[c1, c2] = pu.as_series([c1, c2])481482if len(c1) > len(c2):483c = c2484xs = c1485else:486c = c1487xs = c2488489if len(c) == 1:490c0 = c[0]*xs491c1 = 0492elif len(c) == 2:493c0 = c[0]*xs494c1 = c[1]*xs495else:496nd = len(c)497c0 = c[-2]*xs498c1 = c[-1]*xs499for i in range(3, len(c) + 1):500tmp = c0501nd = nd - 1502c0 = lagsub(c[-i]*xs, (c1*(nd - 1))/nd)503c1 = lagadd(tmp, lagsub((2*nd - 1)*c1, lagmulx(c1))/nd)504return lagadd(c0, lagsub(c1, lagmulx(c1)))505506507def lagdiv(c1, c2):508"""509Divide one Laguerre series by another.510511Returns the quotient-with-remainder of two Laguerre series512`c1` / `c2`. The arguments are sequences of coefficients from lowest513order "term" to highest, e.g., [1,2,3] represents the series514``P_0 + 2*P_1 + 3*P_2``.515516Parameters517----------518c1, c2 : array_like5191-D arrays of Laguerre series coefficients ordered from low to520high.521522Returns523-------524[quo, rem] : ndarrays525Of Laguerre series coefficients representing the quotient and526remainder.527528See Also529--------530lagadd, lagsub, lagmulx, lagmul, lagpow531532Notes533-----534In general, the (polynomial) division of one Laguerre series by another535results in quotient and remainder terms that are not in the Laguerre536polynomial basis set. Thus, to express these results as a Laguerre537series, it is necessary to "reproject" the results onto the Laguerre538basis set, which may produce "unintuitive" (but correct) results; see539Examples section below.540541Examples542--------543>>> from numpy.polynomial.laguerre import lagdiv544>>> lagdiv([ 8., -13., 38., -51., 36.], [0, 1, 2])545(array([1., 2., 3.]), array([0.]))546>>> lagdiv([ 9., -12., 38., -51., 36.], [0, 1, 2])547(array([1., 2., 3.]), array([1., 1.]))548549"""550return pu._div(lagmul, c1, c2)551552553def lagpow(c, pow, maxpower=16):554"""Raise a Laguerre series to a power.555556Returns the Laguerre series `c` raised to the power `pow`. The557argument `c` is a sequence of coefficients ordered from low to high.558i.e., [1,2,3] is the series ``P_0 + 2*P_1 + 3*P_2.``559560Parameters561----------562c : array_like5631-D array of Laguerre series coefficients ordered from low to564high.565pow : integer566Power to which the series will be raised567maxpower : integer, optional568Maximum power allowed. This is mainly to limit growth of the series569to unmanageable size. Default is 16570571Returns572-------573coef : ndarray574Laguerre series of power.575576See Also577--------578lagadd, lagsub, lagmulx, lagmul, lagdiv579580Examples581--------582>>> from numpy.polynomial.laguerre import lagpow583>>> lagpow([1, 2, 3], 2)584array([ 14., -16., 56., -72., 54.])585586"""587return pu._pow(lagmul, c, pow, maxpower)588589590def lagder(c, m=1, scl=1, axis=0):591"""592Differentiate a Laguerre series.593594Returns the Laguerre series coefficients `c` differentiated `m` times595along `axis`. At each iteration the result is multiplied by `scl` (the596scaling factor is for use in a linear change of variable). The argument597`c` is an array of coefficients from low to high degree along each598axis, e.g., [1,2,3] represents the series ``1*L_0 + 2*L_1 + 3*L_2``599while [[1,2],[1,2]] represents ``1*L_0(x)*L_0(y) + 1*L_1(x)*L_0(y) +6002*L_0(x)*L_1(y) + 2*L_1(x)*L_1(y)`` if axis=0 is ``x`` and axis=1 is601``y``.602603Parameters604----------605c : array_like606Array of Laguerre series coefficients. If `c` is multidimensional607the different axis correspond to different variables with the608degree in each axis given by the corresponding index.609m : int, optional610Number of derivatives taken, must be non-negative. (Default: 1)611scl : scalar, optional612Each differentiation is multiplied by `scl`. The end result is613multiplication by ``scl**m``. This is for use in a linear change of614variable. (Default: 1)615axis : int, optional616Axis over which the derivative is taken. (Default: 0).617618.. versionadded:: 1.7.0619620Returns621-------622der : ndarray623Laguerre series of the derivative.624625See Also626--------627lagint628629Notes630-----631In general, the result of differentiating a Laguerre series does not632resemble the same operation on a power series. Thus the result of this633function may be "unintuitive," albeit correct; see Examples section634below.635636Examples637--------638>>> from numpy.polynomial.laguerre import lagder639>>> lagder([ 1., 1., 1., -3.])640array([1., 2., 3.])641>>> lagder([ 1., 0., 0., -4., 3.], m=2)642array([1., 2., 3.])643644"""645c = np.array(c, ndmin=1, copy=True)646if c.dtype.char in '?bBhHiIlLqQpP':647c = c.astype(np.double)648649cnt = pu._deprecate_as_int(m, "the order of derivation")650iaxis = pu._deprecate_as_int(axis, "the axis")651if cnt < 0:652raise ValueError("The order of derivation must be non-negative")653iaxis = normalize_axis_index(iaxis, c.ndim)654655if cnt == 0:656return c657658c = np.moveaxis(c, iaxis, 0)659n = len(c)660if cnt >= n:661c = c[:1]*0662else:663for i in range(cnt):664n = n - 1665c *= scl666der = np.empty((n,) + c.shape[1:], dtype=c.dtype)667for j in range(n, 1, -1):668der[j - 1] = -c[j]669c[j - 1] += c[j]670der[0] = -c[1]671c = der672c = np.moveaxis(c, 0, iaxis)673return c674675676def lagint(c, m=1, k=[], lbnd=0, scl=1, axis=0):677"""678Integrate a Laguerre series.679680Returns the Laguerre series coefficients `c` integrated `m` times from681`lbnd` along `axis`. At each iteration the resulting series is682**multiplied** by `scl` and an integration constant, `k`, is added.683The scaling factor is for use in a linear change of variable. ("Buyer684beware": note that, depending on what one is doing, one may want `scl`685to be the reciprocal of what one might expect; for more information,686see the Notes section below.) The argument `c` is an array of687coefficients from low to high degree along each axis, e.g., [1,2,3]688represents the series ``L_0 + 2*L_1 + 3*L_2`` while [[1,2],[1,2]]689represents ``1*L_0(x)*L_0(y) + 1*L_1(x)*L_0(y) + 2*L_0(x)*L_1(y) +6902*L_1(x)*L_1(y)`` if axis=0 is ``x`` and axis=1 is ``y``.691692693Parameters694----------695c : array_like696Array of Laguerre series coefficients. If `c` is multidimensional697the different axis correspond to different variables with the698degree in each axis given by the corresponding index.699m : int, optional700Order of integration, must be positive. (Default: 1)701k : {[], list, scalar}, optional702Integration constant(s). The value of the first integral at703``lbnd`` is the first value in the list, the value of the second704integral at ``lbnd`` is the second value, etc. If ``k == []`` (the705default), all constants are set to zero. If ``m == 1``, a single706scalar can be given instead of a list.707lbnd : scalar, optional708The lower bound of the integral. (Default: 0)709scl : scalar, optional710Following each integration the result is *multiplied* by `scl`711before the integration constant is added. (Default: 1)712axis : int, optional713Axis over which the integral is taken. (Default: 0).714715.. versionadded:: 1.7.0716717Returns718-------719S : ndarray720Laguerre series coefficients of the integral.721722Raises723------724ValueError725If ``m < 0``, ``len(k) > m``, ``np.ndim(lbnd) != 0``, or726``np.ndim(scl) != 0``.727728See Also729--------730lagder731732Notes733-----734Note that the result of each integration is *multiplied* by `scl`.735Why is this important to note? Say one is making a linear change of736variable :math:`u = ax + b` in an integral relative to `x`. Then737:math:`dx = du/a`, so one will need to set `scl` equal to738:math:`1/a` - perhaps not what one would have first thought.739740Also note that, in general, the result of integrating a C-series needs741to be "reprojected" onto the C-series basis set. Thus, typically,742the result of this function is "unintuitive," albeit correct; see743Examples section below.744745Examples746--------747>>> from numpy.polynomial.laguerre import lagint748>>> lagint([1,2,3])749array([ 1., 1., 1., -3.])750>>> lagint([1,2,3], m=2)751array([ 1., 0., 0., -4., 3.])752>>> lagint([1,2,3], k=1)753array([ 2., 1., 1., -3.])754>>> lagint([1,2,3], lbnd=-1)755array([11.5, 1. , 1. , -3. ])756>>> lagint([1,2], m=2, k=[1,2], lbnd=-1)757array([ 11.16666667, -5. , -3. , 2. ]) # may vary758759"""760c = np.array(c, ndmin=1, copy=True)761if c.dtype.char in '?bBhHiIlLqQpP':762c = c.astype(np.double)763if not np.iterable(k):764k = [k]765cnt = pu._deprecate_as_int(m, "the order of integration")766iaxis = pu._deprecate_as_int(axis, "the axis")767if cnt < 0:768raise ValueError("The order of integration must be non-negative")769if len(k) > cnt:770raise ValueError("Too many integration constants")771if np.ndim(lbnd) != 0:772raise ValueError("lbnd must be a scalar.")773if np.ndim(scl) != 0:774raise ValueError("scl must be a scalar.")775iaxis = normalize_axis_index(iaxis, c.ndim)776777if cnt == 0:778return c779780c = np.moveaxis(c, iaxis, 0)781k = list(k) + [0]*(cnt - len(k))782for i in range(cnt):783n = len(c)784c *= scl785if n == 1 and np.all(c[0] == 0):786c[0] += k[i]787else:788tmp = np.empty((n + 1,) + c.shape[1:], dtype=c.dtype)789tmp[0] = c[0]790tmp[1] = -c[0]791for j in range(1, n):792tmp[j] += c[j]793tmp[j + 1] = -c[j]794tmp[0] += k[i] - lagval(lbnd, tmp)795c = tmp796c = np.moveaxis(c, 0, iaxis)797return c798799800def lagval(x, c, tensor=True):801"""802Evaluate a Laguerre series at points x.803804If `c` is of length `n + 1`, this function returns the value:805806.. math:: p(x) = c_0 * L_0(x) + c_1 * L_1(x) + ... + c_n * L_n(x)807808The parameter `x` is converted to an array only if it is a tuple or a809list, otherwise it is treated as a scalar. In either case, either `x`810or its elements must support multiplication and addition both with811themselves and with the elements of `c`.812813If `c` is a 1-D array, then `p(x)` will have the same shape as `x`. If814`c` is multidimensional, then the shape of the result depends on the815value of `tensor`. If `tensor` is true the shape will be c.shape[1:] +816x.shape. If `tensor` is false the shape will be c.shape[1:]. Note that817scalars have shape (,).818819Trailing zeros in the coefficients will be used in the evaluation, so820they should be avoided if efficiency is a concern.821822Parameters823----------824x : array_like, compatible object825If `x` is a list or tuple, it is converted to an ndarray, otherwise826it is left unchanged and treated as a scalar. In either case, `x`827or its elements must support addition and multiplication with828with themselves and with the elements of `c`.829c : array_like830Array of coefficients ordered so that the coefficients for terms of831degree n are contained in c[n]. If `c` is multidimensional the832remaining indices enumerate multiple polynomials. In the two833dimensional case the coefficients may be thought of as stored in834the columns of `c`.835tensor : boolean, optional836If True, the shape of the coefficient array is extended with ones837on the right, one for each dimension of `x`. Scalars have dimension 0838for this action. The result is that every column of coefficients in839`c` is evaluated for every element of `x`. If False, `x` is broadcast840over the columns of `c` for the evaluation. This keyword is useful841when `c` is multidimensional. The default value is True.842843.. versionadded:: 1.7.0844845Returns846-------847values : ndarray, algebra_like848The shape of the return value is described above.849850See Also851--------852lagval2d, laggrid2d, lagval3d, laggrid3d853854Notes855-----856The evaluation uses Clenshaw recursion, aka synthetic division.857858Examples859--------860>>> from numpy.polynomial.laguerre import lagval861>>> coef = [1,2,3]862>>> lagval(1, coef)863-0.5864>>> lagval([[1,2],[3,4]], coef)865array([[-0.5, -4. ],866[-4.5, -2. ]])867868"""869c = np.array(c, ndmin=1, copy=False)870if c.dtype.char in '?bBhHiIlLqQpP':871c = c.astype(np.double)872if isinstance(x, (tuple, list)):873x = np.asarray(x)874if isinstance(x, np.ndarray) and tensor:875c = c.reshape(c.shape + (1,)*x.ndim)876877if len(c) == 1:878c0 = c[0]879c1 = 0880elif len(c) == 2:881c0 = c[0]882c1 = c[1]883else:884nd = len(c)885c0 = c[-2]886c1 = c[-1]887for i in range(3, len(c) + 1):888tmp = c0889nd = nd - 1890c0 = c[-i] - (c1*(nd - 1))/nd891c1 = tmp + (c1*((2*nd - 1) - x))/nd892return c0 + c1*(1 - x)893894895def lagval2d(x, y, c):896"""897Evaluate a 2-D Laguerre series at points (x, y).898899This function returns the values:900901.. math:: p(x,y) = \\sum_{i,j} c_{i,j} * L_i(x) * L_j(y)902903The parameters `x` and `y` are converted to arrays only if they are904tuples or a lists, otherwise they are treated as a scalars and they905must have the same shape after conversion. In either case, either `x`906and `y` or their elements must support multiplication and addition both907with themselves and with the elements of `c`.908909If `c` is a 1-D array a one is implicitly appended to its shape to make910it 2-D. The shape of the result will be c.shape[2:] + x.shape.911912Parameters913----------914x, y : array_like, compatible objects915The two dimensional series is evaluated at the points `(x, y)`,916where `x` and `y` must have the same shape. If `x` or `y` is a list917or tuple, it is first converted to an ndarray, otherwise it is left918unchanged and if it isn't an ndarray it is treated as a scalar.919c : array_like920Array of coefficients ordered so that the coefficient of the term921of multi-degree i,j is contained in ``c[i,j]``. If `c` has922dimension greater than two the remaining indices enumerate multiple923sets of coefficients.924925Returns926-------927values : ndarray, compatible object928The values of the two dimensional polynomial at points formed with929pairs of corresponding values from `x` and `y`.930931See Also932--------933lagval, laggrid2d, lagval3d, laggrid3d934935Notes936-----937938.. versionadded:: 1.7.0939940"""941return pu._valnd(lagval, c, x, y)942943944def laggrid2d(x, y, c):945"""946Evaluate a 2-D Laguerre series on the Cartesian product of x and y.947948This function returns the values:949950.. math:: p(a,b) = \\sum_{i,j} c_{i,j} * L_i(a) * L_j(b)951952where the points `(a, b)` consist of all pairs formed by taking953`a` from `x` and `b` from `y`. The resulting points form a grid with954`x` in the first dimension and `y` in the second.955956The parameters `x` and `y` are converted to arrays only if they are957tuples or a lists, otherwise they are treated as a scalars. In either958case, either `x` and `y` or their elements must support multiplication959and addition both with themselves and with the elements of `c`.960961If `c` has fewer than two dimensions, ones are implicitly appended to962its shape to make it 2-D. The shape of the result will be c.shape[2:] +963x.shape + y.shape.964965Parameters966----------967x, y : array_like, compatible objects968The two dimensional series is evaluated at the points in the969Cartesian product of `x` and `y`. If `x` or `y` is a list or970tuple, it is first converted to an ndarray, otherwise it is left971unchanged and, if it isn't an ndarray, it is treated as a scalar.972c : array_like973Array of coefficients ordered so that the coefficient of the term of974multi-degree i,j is contained in `c[i,j]`. If `c` has dimension975greater than two the remaining indices enumerate multiple sets of976coefficients.977978Returns979-------980values : ndarray, compatible object981The values of the two dimensional Chebyshev series at points in the982Cartesian product of `x` and `y`.983984See Also985--------986lagval, lagval2d, lagval3d, laggrid3d987988Notes989-----990991.. versionadded:: 1.7.0992993"""994return pu._gridnd(lagval, c, x, y)995996997def lagval3d(x, y, z, c):998"""999Evaluate a 3-D Laguerre series at points (x, y, z).10001001This function returns the values:10021003.. math:: p(x,y,z) = \\sum_{i,j,k} c_{i,j,k} * L_i(x) * L_j(y) * L_k(z)10041005The parameters `x`, `y`, and `z` are converted to arrays only if1006they are tuples or a lists, otherwise they are treated as a scalars and1007they must have the same shape after conversion. In either case, either1008`x`, `y`, and `z` or their elements must support multiplication and1009addition both with themselves and with the elements of `c`.10101011If `c` has fewer than 3 dimensions, ones are implicitly appended to its1012shape to make it 3-D. The shape of the result will be c.shape[3:] +1013x.shape.10141015Parameters1016----------1017x, y, z : array_like, compatible object1018The three dimensional series is evaluated at the points1019`(x, y, z)`, where `x`, `y`, and `z` must have the same shape. If1020any of `x`, `y`, or `z` is a list or tuple, it is first converted1021to an ndarray, otherwise it is left unchanged and if it isn't an1022ndarray it is treated as a scalar.1023c : array_like1024Array of coefficients ordered so that the coefficient of the term of1025multi-degree i,j,k is contained in ``c[i,j,k]``. If `c` has dimension1026greater than 3 the remaining indices enumerate multiple sets of1027coefficients.10281029Returns1030-------1031values : ndarray, compatible object1032The values of the multidimensional polynomial on points formed with1033triples of corresponding values from `x`, `y`, and `z`.10341035See Also1036--------1037lagval, lagval2d, laggrid2d, laggrid3d10381039Notes1040-----10411042.. versionadded:: 1.7.010431044"""1045return pu._valnd(lagval, c, x, y, z)104610471048def laggrid3d(x, y, z, c):1049"""1050Evaluate a 3-D Laguerre series on the Cartesian product of x, y, and z.10511052This function returns the values:10531054.. math:: p(a,b,c) = \\sum_{i,j,k} c_{i,j,k} * L_i(a) * L_j(b) * L_k(c)10551056where the points `(a, b, c)` consist of all triples formed by taking1057`a` from `x`, `b` from `y`, and `c` from `z`. The resulting points form1058a grid with `x` in the first dimension, `y` in the second, and `z` in1059the third.10601061The parameters `x`, `y`, and `z` are converted to arrays only if they1062are tuples or a lists, otherwise they are treated as a scalars. In1063either case, either `x`, `y`, and `z` or their elements must support1064multiplication and addition both with themselves and with the elements1065of `c`.10661067If `c` has fewer than three dimensions, ones are implicitly appended to1068its shape to make it 3-D. The shape of the result will be c.shape[3:] +1069x.shape + y.shape + z.shape.10701071Parameters1072----------1073x, y, z : array_like, compatible objects1074The three dimensional series is evaluated at the points in the1075Cartesian product of `x`, `y`, and `z`. If `x`,`y`, or `z` is a1076list or tuple, it is first converted to an ndarray, otherwise it is1077left unchanged and, if it isn't an ndarray, it is treated as a1078scalar.1079c : array_like1080Array of coefficients ordered so that the coefficients for terms of1081degree i,j are contained in ``c[i,j]``. If `c` has dimension1082greater than two the remaining indices enumerate multiple sets of1083coefficients.10841085Returns1086-------1087values : ndarray, compatible object1088The values of the two dimensional polynomial at points in the Cartesian1089product of `x` and `y`.10901091See Also1092--------1093lagval, lagval2d, laggrid2d, lagval3d10941095Notes1096-----10971098.. versionadded:: 1.7.010991100"""1101return pu._gridnd(lagval, c, x, y, z)110211031104def lagvander(x, deg):1105"""Pseudo-Vandermonde matrix of given degree.11061107Returns the pseudo-Vandermonde matrix of degree `deg` and sample points1108`x`. The pseudo-Vandermonde matrix is defined by11091110.. math:: V[..., i] = L_i(x)11111112where `0 <= i <= deg`. The leading indices of `V` index the elements of1113`x` and the last index is the degree of the Laguerre polynomial.11141115If `c` is a 1-D array of coefficients of length `n + 1` and `V` is the1116array ``V = lagvander(x, n)``, then ``np.dot(V, c)`` and1117``lagval(x, c)`` are the same up to roundoff. This equivalence is1118useful both for least squares fitting and for the evaluation of a large1119number of Laguerre series of the same degree and sample points.11201121Parameters1122----------1123x : array_like1124Array of points. The dtype is converted to float64 or complex1281125depending on whether any of the elements are complex. If `x` is1126scalar it is converted to a 1-D array.1127deg : int1128Degree of the resulting matrix.11291130Returns1131-------1132vander : ndarray1133The pseudo-Vandermonde matrix. The shape of the returned matrix is1134``x.shape + (deg + 1,)``, where The last index is the degree of the1135corresponding Laguerre polynomial. The dtype will be the same as1136the converted `x`.11371138Examples1139--------1140>>> from numpy.polynomial.laguerre import lagvander1141>>> x = np.array([0, 1, 2])1142>>> lagvander(x, 3)1143array([[ 1. , 1. , 1. , 1. ],1144[ 1. , 0. , -0.5 , -0.66666667],1145[ 1. , -1. , -1. , -0.33333333]])11461147"""1148ideg = pu._deprecate_as_int(deg, "deg")1149if ideg < 0:1150raise ValueError("deg must be non-negative")11511152x = np.array(x, copy=False, ndmin=1) + 0.01153dims = (ideg + 1,) + x.shape1154dtyp = x.dtype1155v = np.empty(dims, dtype=dtyp)1156v[0] = x*0 + 11157if ideg > 0:1158v[1] = 1 - x1159for i in range(2, ideg + 1):1160v[i] = (v[i-1]*(2*i - 1 - x) - v[i-2]*(i - 1))/i1161return np.moveaxis(v, 0, -1)116211631164def lagvander2d(x, y, deg):1165"""Pseudo-Vandermonde matrix of given degrees.11661167Returns the pseudo-Vandermonde matrix of degrees `deg` and sample1168points `(x, y)`. The pseudo-Vandermonde matrix is defined by11691170.. math:: V[..., (deg[1] + 1)*i + j] = L_i(x) * L_j(y),11711172where `0 <= i <= deg[0]` and `0 <= j <= deg[1]`. The leading indices of1173`V` index the points `(x, y)` and the last index encodes the degrees of1174the Laguerre polynomials.11751176If ``V = lagvander2d(x, y, [xdeg, ydeg])``, then the columns of `V`1177correspond to the elements of a 2-D coefficient array `c` of shape1178(xdeg + 1, ydeg + 1) in the order11791180.. math:: c_{00}, c_{01}, c_{02} ... , c_{10}, c_{11}, c_{12} ...11811182and ``np.dot(V, c.flat)`` and ``lagval2d(x, y, c)`` will be the same1183up to roundoff. This equivalence is useful both for least squares1184fitting and for the evaluation of a large number of 2-D Laguerre1185series of the same degrees and sample points.11861187Parameters1188----------1189x, y : array_like1190Arrays of point coordinates, all of the same shape. The dtypes1191will be converted to either float64 or complex128 depending on1192whether any of the elements are complex. Scalars are converted to11931-D arrays.1194deg : list of ints1195List of maximum degrees of the form [x_deg, y_deg].11961197Returns1198-------1199vander2d : ndarray1200The shape of the returned matrix is ``x.shape + (order,)``, where1201:math:`order = (deg[0]+1)*(deg[1]+1)`. The dtype will be the same1202as the converted `x` and `y`.12031204See Also1205--------1206lagvander, lagvander3d, lagval2d, lagval3d12071208Notes1209-----12101211.. versionadded:: 1.7.012121213"""1214return pu._vander_nd_flat((lagvander, lagvander), (x, y), deg)121512161217def lagvander3d(x, y, z, deg):1218"""Pseudo-Vandermonde matrix of given degrees.12191220Returns the pseudo-Vandermonde matrix of degrees `deg` and sample1221points `(x, y, z)`. If `l, m, n` are the given degrees in `x, y, z`,1222then The pseudo-Vandermonde matrix is defined by12231224.. math:: V[..., (m+1)(n+1)i + (n+1)j + k] = L_i(x)*L_j(y)*L_k(z),12251226where `0 <= i <= l`, `0 <= j <= m`, and `0 <= j <= n`. The leading1227indices of `V` index the points `(x, y, z)` and the last index encodes1228the degrees of the Laguerre polynomials.12291230If ``V = lagvander3d(x, y, z, [xdeg, ydeg, zdeg])``, then the columns1231of `V` correspond to the elements of a 3-D coefficient array `c` of1232shape (xdeg + 1, ydeg + 1, zdeg + 1) in the order12331234.. math:: c_{000}, c_{001}, c_{002},... , c_{010}, c_{011}, c_{012},...12351236and ``np.dot(V, c.flat)`` and ``lagval3d(x, y, z, c)`` will be the1237same up to roundoff. This equivalence is useful both for least squares1238fitting and for the evaluation of a large number of 3-D Laguerre1239series of the same degrees and sample points.12401241Parameters1242----------1243x, y, z : array_like1244Arrays of point coordinates, all of the same shape. The dtypes will1245be converted to either float64 or complex128 depending on whether1246any of the elements are complex. Scalars are converted to 1-D1247arrays.1248deg : list of ints1249List of maximum degrees of the form [x_deg, y_deg, z_deg].12501251Returns1252-------1253vander3d : ndarray1254The shape of the returned matrix is ``x.shape + (order,)``, where1255:math:`order = (deg[0]+1)*(deg[1]+1)*(deg[2]+1)`. The dtype will1256be the same as the converted `x`, `y`, and `z`.12571258See Also1259--------1260lagvander, lagvander3d, lagval2d, lagval3d12611262Notes1263-----12641265.. versionadded:: 1.7.012661267"""1268return pu._vander_nd_flat((lagvander, lagvander, lagvander), (x, y, z), deg)126912701271def lagfit(x, y, deg, rcond=None, full=False, w=None):1272"""1273Least squares fit of Laguerre series to data.12741275Return the coefficients of a Laguerre series of degree `deg` that is the1276least squares fit to the data values `y` given at points `x`. If `y` is12771-D the returned coefficients will also be 1-D. If `y` is 2-D multiple1278fits are done, one for each column of `y`, and the resulting1279coefficients are stored in the corresponding columns of a 2-D return.1280The fitted polynomial(s) are in the form12811282.. math:: p(x) = c_0 + c_1 * L_1(x) + ... + c_n * L_n(x),12831284where `n` is `deg`.12851286Parameters1287----------1288x : array_like, shape (M,)1289x-coordinates of the M sample points ``(x[i], y[i])``.1290y : array_like, shape (M,) or (M, K)1291y-coordinates of the sample points. Several data sets of sample1292points sharing the same x-coordinates can be fitted at once by1293passing in a 2D-array that contains one dataset per column.1294deg : int or 1-D array_like1295Degree(s) of the fitting polynomials. If `deg` is a single integer1296all terms up to and including the `deg`'th term are included in the1297fit. For NumPy versions >= 1.11.0 a list of integers specifying the1298degrees of the terms to include may be used instead.1299rcond : float, optional1300Relative condition number of the fit. Singular values smaller than1301this relative to the largest singular value will be ignored. The1302default value is len(x)*eps, where eps is the relative precision of1303the float type, about 2e-16 in most cases.1304full : bool, optional1305Switch determining nature of return value. When it is False (the1306default) just the coefficients are returned, when True diagnostic1307information from the singular value decomposition is also returned.1308w : array_like, shape (`M`,), optional1309Weights. If not None, the weight ``w[i]`` applies to the unsquared1310residual ``y[i] - y_hat[i]`` at ``x[i]``. Ideally the weights are1311chosen so that the errors of the products ``w[i]*y[i]`` all have the1312same variance. When using inverse-variance weighting, use1313``w[i] = 1/sigma(y[i])``. The default value is None.13141315Returns1316-------1317coef : ndarray, shape (M,) or (M, K)1318Laguerre coefficients ordered from low to high. If `y` was 2-D,1319the coefficients for the data in column k of `y` are in column1320`k`.13211322[residuals, rank, singular_values, rcond] : list1323These values are only returned if ``full == True``13241325- residuals -- sum of squared residuals of the least squares fit1326- rank -- the numerical rank of the scaled Vandermonde matrix1327- singular_values -- singular values of the scaled Vandermonde matrix1328- rcond -- value of `rcond`.13291330For more details, see `numpy.linalg.lstsq`.13311332Warns1333-----1334RankWarning1335The rank of the coefficient matrix in the least-squares fit is1336deficient. The warning is only raised if ``full == False``. The1337warnings can be turned off by13381339>>> import warnings1340>>> warnings.simplefilter('ignore', np.RankWarning)13411342See Also1343--------1344numpy.polynomial.polynomial.polyfit1345numpy.polynomial.legendre.legfit1346numpy.polynomial.chebyshev.chebfit1347numpy.polynomial.hermite.hermfit1348numpy.polynomial.hermite_e.hermefit1349lagval : Evaluates a Laguerre series.1350lagvander : pseudo Vandermonde matrix of Laguerre series.1351lagweight : Laguerre weight function.1352numpy.linalg.lstsq : Computes a least-squares fit from the matrix.1353scipy.interpolate.UnivariateSpline : Computes spline fits.13541355Notes1356-----1357The solution is the coefficients of the Laguerre series `p` that1358minimizes the sum of the weighted squared errors13591360.. math:: E = \\sum_j w_j^2 * |y_j - p(x_j)|^2,13611362where the :math:`w_j` are the weights. This problem is solved by1363setting up as the (typically) overdetermined matrix equation13641365.. math:: V(x) * c = w * y,13661367where `V` is the weighted pseudo Vandermonde matrix of `x`, `c` are the1368coefficients to be solved for, `w` are the weights, and `y` are the1369observed values. This equation is then solved using the singular value1370decomposition of `V`.13711372If some of the singular values of `V` are so small that they are1373neglected, then a `RankWarning` will be issued. This means that the1374coefficient values may be poorly determined. Using a lower order fit1375will usually get rid of the warning. The `rcond` parameter can also be1376set to a value smaller than its default, but the resulting fit may be1377spurious and have large contributions from roundoff error.13781379Fits using Laguerre series are probably most useful when the data can1380be approximated by ``sqrt(w(x)) * p(x)``, where `w(x)` is the Laguerre1381weight. In that case the weight ``sqrt(w(x[i]))`` should be used1382together with data values ``y[i]/sqrt(w(x[i]))``. The weight function is1383available as `lagweight`.13841385References1386----------1387.. [1] Wikipedia, "Curve fitting",1388https://en.wikipedia.org/wiki/Curve_fitting13891390Examples1391--------1392>>> from numpy.polynomial.laguerre import lagfit, lagval1393>>> x = np.linspace(0, 10)1394>>> err = np.random.randn(len(x))/101395>>> y = lagval(x, [1, 2, 3]) + err1396>>> lagfit(x, y, 2)1397array([ 0.96971004, 2.00193749, 3.00288744]) # may vary13981399"""1400return pu._fit(lagvander, x, y, deg, rcond, full, w)140114021403def lagcompanion(c):1404"""1405Return the companion matrix of c.14061407The usual companion matrix of the Laguerre polynomials is already1408symmetric when `c` is a basis Laguerre polynomial, so no scaling is1409applied.14101411Parameters1412----------1413c : array_like14141-D array of Laguerre series coefficients ordered from low to high1415degree.14161417Returns1418-------1419mat : ndarray1420Companion matrix of dimensions (deg, deg).14211422Notes1423-----14241425.. versionadded:: 1.7.014261427"""1428# c is a trimmed copy1429[c] = pu.as_series([c])1430if len(c) < 2:1431raise ValueError('Series must have maximum degree of at least 1.')1432if len(c) == 2:1433return np.array([[1 + c[0]/c[1]]])14341435n = len(c) - 11436mat = np.zeros((n, n), dtype=c.dtype)1437top = mat.reshape(-1)[1::n+1]1438mid = mat.reshape(-1)[0::n+1]1439bot = mat.reshape(-1)[n::n+1]1440top[...] = -np.arange(1, n)1441mid[...] = 2.*np.arange(n) + 1.1442bot[...] = top1443mat[:, -1] += (c[:-1]/c[-1])*n1444return mat144514461447def lagroots(c):1448"""1449Compute the roots of a Laguerre series.14501451Return the roots (a.k.a. "zeros") of the polynomial14521453.. math:: p(x) = \\sum_i c[i] * L_i(x).14541455Parameters1456----------1457c : 1-D array_like14581-D array of coefficients.14591460Returns1461-------1462out : ndarray1463Array of the roots of the series. If all the roots are real,1464then `out` is also real, otherwise it is complex.14651466See Also1467--------1468numpy.polynomial.polynomial.polyroots1469numpy.polynomial.legendre.legroots1470numpy.polynomial.chebyshev.chebroots1471numpy.polynomial.hermite.hermroots1472numpy.polynomial.hermite_e.hermeroots14731474Notes1475-----1476The root estimates are obtained as the eigenvalues of the companion1477matrix, Roots far from the origin of the complex plane may have large1478errors due to the numerical instability of the series for such1479values. Roots with multiplicity greater than 1 will also show larger1480errors as the value of the series near such points is relatively1481insensitive to errors in the roots. Isolated roots near the origin can1482be improved by a few iterations of Newton's method.14831484The Laguerre series basis polynomials aren't powers of `x` so the1485results of this function may seem unintuitive.14861487Examples1488--------1489>>> from numpy.polynomial.laguerre import lagroots, lagfromroots1490>>> coef = lagfromroots([0, 1, 2])1491>>> coef1492array([ 2., -8., 12., -6.])1493>>> lagroots(coef)1494array([-4.4408921e-16, 1.0000000e+00, 2.0000000e+00])14951496"""1497# c is a trimmed copy1498[c] = pu.as_series([c])1499if len(c) <= 1:1500return np.array([], dtype=c.dtype)1501if len(c) == 2:1502return np.array([1 + c[0]/c[1]])15031504# rotated companion matrix reduces error1505m = lagcompanion(c)[::-1,::-1]1506r = la.eigvals(m)1507r.sort()1508return r150915101511def laggauss(deg):1512"""1513Gauss-Laguerre quadrature.15141515Computes the sample points and weights for Gauss-Laguerre quadrature.1516These sample points and weights will correctly integrate polynomials of1517degree :math:`2*deg - 1` or less over the interval :math:`[0, \\inf]`1518with the weight function :math:`f(x) = \\exp(-x)`.15191520Parameters1521----------1522deg : int1523Number of sample points and weights. It must be >= 1.15241525Returns1526-------1527x : ndarray15281-D ndarray containing the sample points.1529y : ndarray15301-D ndarray containing the weights.15311532Notes1533-----15341535.. versionadded:: 1.7.015361537The results have only been tested up to degree 100 higher degrees may1538be problematic. The weights are determined by using the fact that15391540.. math:: w_k = c / (L'_n(x_k) * L_{n-1}(x_k))15411542where :math:`c` is a constant independent of :math:`k` and :math:`x_k`1543is the k'th root of :math:`L_n`, and then scaling the results to get1544the right value when integrating 1.15451546"""1547ideg = pu._deprecate_as_int(deg, "deg")1548if ideg <= 0:1549raise ValueError("deg must be a positive integer")15501551# first approximation of roots. We use the fact that the companion1552# matrix is symmetric in this case in order to obtain better zeros.1553c = np.array([0]*deg + [1])1554m = lagcompanion(c)1555x = la.eigvalsh(m)15561557# improve roots by one application of Newton1558dy = lagval(x, c)1559df = lagval(x, lagder(c))1560x -= dy/df15611562# compute the weights. We scale the factor to avoid possible numerical1563# overflow.1564fm = lagval(x, c[1:])1565fm /= np.abs(fm).max()1566df /= np.abs(df).max()1567w = 1/(fm * df)15681569# scale w to get the right value, 1 in this case1570w /= w.sum()15711572return x, w157315741575def lagweight(x):1576"""Weight function of the Laguerre polynomials.15771578The weight function is :math:`exp(-x)` and the interval of integration1579is :math:`[0, \\inf]`. The Laguerre polynomials are orthogonal, but not1580normalized, with respect to this weight function.15811582Parameters1583----------1584x : array_like1585Values at which the weight function will be computed.15861587Returns1588-------1589w : ndarray1590The weight function at `x`.15911592Notes1593-----15941595.. versionadded:: 1.7.015961597"""1598w = np.exp(-x)1599return w16001601#1602# Laguerre series class1603#16041605class Laguerre(ABCPolyBase):1606"""A Laguerre series class.16071608The Laguerre class provides the standard Python numerical methods1609'+', '-', '*', '//', '%', 'divmod', '**', and '()' as well as the1610attributes and methods listed in the `ABCPolyBase` documentation.16111612Parameters1613----------1614coef : array_like1615Laguerre coefficients in order of increasing degree, i.e,1616``(1, 2, 3)`` gives ``1*L_0(x) + 2*L_1(X) + 3*L_2(x)``.1617domain : (2,) array_like, optional1618Domain to use. The interval ``[domain[0], domain[1]]`` is mapped1619to the interval ``[window[0], window[1]]`` by shifting and scaling.1620The default value is [0, 1].1621window : (2,) array_like, optional1622Window, see `domain` for its use. The default value is [0, 1].16231624.. versionadded:: 1.6.016251626"""1627# Virtual Functions1628_add = staticmethod(lagadd)1629_sub = staticmethod(lagsub)1630_mul = staticmethod(lagmul)1631_div = staticmethod(lagdiv)1632_pow = staticmethod(lagpow)1633_val = staticmethod(lagval)1634_int = staticmethod(lagint)1635_der = staticmethod(lagder)1636_fit = staticmethod(lagfit)1637_line = staticmethod(lagline)1638_roots = staticmethod(lagroots)1639_fromroots = staticmethod(lagfromroots)16401641# Virtual properties1642domain = np.array(lagdomain)1643window = np.array(lagdomain)1644basis_name = 'L'164516461647