/usr/local/lib64/python3.6/site-packages/numpy/lib/__pycache__
NameSizeModeActions
arraypad.cpython-36.pyc218270644editdlrm
arraysetops.cpython-36.pyc218080644editdlrm
arrayterator.cpython-36.pyc70210644editdlrm
financial.cpython-36.pyc300600644editdlrm
format.cpython-36.pyc251790644editdlrm
function_base.cpython-36.pyc1372260644editdlrm
histograms.cpython-36.pyc320230644editdlrm
index_tricks.cpython-36.pyc279100644editdlrm
mixins.cpython-36.pyc71120644editdlrm
nanfunctions.cpython-36.pyc544600644editdlrm
npyio.cpython-36.pyc670620644editdlrm
polynomial.cpython-36.pyc381770644editdlrm
recfunctions.cpython-36.pyc473250644editdlrm
scimath.cpython-36.pyc153490644editdlrm
setup.cpython-36.pyc5500644editdlrm
shape_base.cpython-36.pyc358480644editdlrm
stride_tricks.cpython-36.pyc83150644editdlrm
twodim_base.cpython-36.pyc280230644editdlrm
type_check.cpython-36.pyc192370644editdlrm
ufunclike.cpython-36.pyc78410644editdlrm
user_array.cpython-36.pyc113380644editdlrm
utils.cpython-36.pyc246410644editdlrm
_datasource.cpython-36.pyc204000644editdlrm
_iotools.cpython-36.pyc259030644editdlrm
_version.cpython-36.pyc48190644editdlrm
__init__.cpython-36.pyc15700644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/numpy/lib/__pycache__/polynomial.cpython-36.pyc (38177B)
3 Eg @sdZddddddddd d d d g Zd dlZd dlZd dlZd dljjZd dl m Z m Z m Z m Z mZmZmZmZd dl mZd dlmZd dlmZmZd dlmZd dlmZmZmZmZd dlm Z m!Z!m"Z"ej#ej$ddZ$edGdd d e%Z&ddZ'e$e'ddZ(ddZ)e$e)ddZ*d;dd Z+e$e+dd%dZ.d?d&d'Z/e$e/d@d)d Z0d*d+Z1e$e1d,d Z2d-d.Z3e$e3d/dZ4e$e3d0dZ5e$e3d1dZ6d2d3Z7e$e7d4dZ8ej9d5Z:dAd7d8Z;edGd9d d Z>> np.poly((0, 0, 0)) # Multiple root example array([1., 0., 0., 0.]) The line above represents z**3 + 0*z**2 + 0*z + 0. >>> np.poly((-1./2, 0, 1./2)) array([ 1. , 0. , -0.25, 0. ]) The line above represents z**3 - z/4 >>> np.poly((np.random.random(1)[0], 0, np.random.random(1)[0])) array([ 1. , -0.77086955, 0.08618131, 0. ]) # random Given a square array object: >>> P = np.array([[0, 1./3], [-1./2, 0]]) >>> np.poly(P) array([1. , 0. , 0.16666667]) Note how in all cases the leading coefficient is always 1. r z.input must be 1d or non-empty square 2d array.g?)dtypefull)mode)r,)rshapelenrr-objectastyperchar ValueErrorrrangeNXconvolver issubclasstypecomplexfloatingasarraycomplexallsort conjugatercopy)r)shdtakrr'r'r(r,s*X(        cCs|S)Nr')pr'r'r(_roots_dispatchersrGcCst|}|jdkrtdtjtj|d}t|dkrDtjgSt||dd}|t|dt|dd}t |j j tj tj fs|jt}t|}|dkrttj|df|j d}|dd |d|dddf<t|}n tjg}t|tj||j f}|S) a Return the roots of a polynomial with coefficients given in p. The values in the rank-1 array `p` are coefficients of a polynomial. If the length of `p` is n+1 then the polynomial is described by:: p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n] Parameters ---------- p : array_like Rank-1 array of polynomial coefficients. Returns ------- out : ndarray An array containing the roots of the polynomial. Raises ------ ValueError When `p` cannot be converted to a rank-1 array. See also -------- poly : Find the coefficients of a polynomial with a given sequence of roots. polyval : Compute polynomial values. polyfit : Least squares polynomial fit. poly1d : A one-dimensional polynomial class. Notes ----- The algorithm relies on computing the eigenvalues of the companion matrix [1]_. References ---------- .. [1] R. A. Horn & C. R. Johnson, *Matrix Analysis*. Cambridge, UK: Cambridge University Press, 1999, pp. 146-7. Examples -------- >>> coeff = [3.2, 2, 1] >>> np.roots(coeff) array([-0.3125+0.46351241j, -0.3125-0.46351241j]) r,zInput must be a rank-1 array.r r+NrHrH)rndimr5r7ZnonzeroZravelr1rintr9r-r:Zfloatingr;r3floatrrrrzeros)rFZnon_zeroZtrailing_zerosNArr'r'r(rs$3     "  cCs|fS)Nr')rFmrEr'r'r(_polyint_dispatchersrPr,cCst|}|dkrtd|dkr,tj|t}t|}t|dkr\|dkr\|dtj|t}t||krptdt|t }tj |}|dkr|rt |S|Stj |j tj t|dd|dgf}t||d|ddd}|rt |S|SdS)a Return an antiderivative (indefinite integral) of a polynomial. The returned order `m` antiderivative `P` of polynomial `p` satisfies :math:`\frac{d^m}{dx^m}P(x) = p(x)` and is defined up to `m - 1` integration constants `k`. The constants determine the low-order polynomial part .. math:: \frac{k_{m-1}}{0!} x^0 + \ldots + \frac{k_0}{(m-1)!}x^{m-1} of `P` so that :math:`P^{(j)}(0) = k_{m-j-1}`. Parameters ---------- p : array_like or poly1d Polynomial to integrate. A sequence is interpreted as polynomial coefficients, see `poly1d`. m : int, optional Order of the antiderivative. (Default: 1) k : list of `m` scalars or scalar, optional Integration constants. They are given in the order of integration: those corresponding to highest-order terms come first. If ``None`` (default), all constants are assumed to be zero. If `m = 1`, a single scalar can be given instead of a list. See Also -------- polyder : derivative of a polynomial poly1d.integ : equivalent method Examples -------- The defining property of the antiderivative: >>> p = np.poly1d([1,1,1]) >>> P = np.polyint(p) >>> P poly1d([ 0.33333333, 0.5 , 1. , 0. ]) # may vary >>> np.polyder(P) == p True The integration constants default to zero, but can be specified: >>> P = np.polyint(p, 3) >>> P(0) 0.0 >>> np.polyder(P)(0) 0.0 >>> np.polyder(P, 2)(0) 0.0 >>> P = np.polyint(p, 3, k=[6,5,3]) >>> P poly1d([ 0.01666667, 0.04166667, 0.16666667, 3. , 5. , 3. ]) # may vary Note that 3 = 6 / 2!, and that the constants are given in the order of integrations. Constant of the highest-order polynomial term comes first: >>> np.polyder(P, 2)(0) 6.0 >>> np.polyder(P, 1)(0) 5.0 >>> P(0) 3.0 r z0Order of integral must be positive (see polyder)Nr,z7k must be a scalar or a rank-1 array of length 1 or >m.)rErH)rJr5r7rLrKrr1r isinstancer r< concatenate __truediv__aranger)rFrOrEtruepolyyvalr'r'r(rs,D    (cCs|fS)Nr')rFrOr'r'r(_polyder_dispatcher_srXcCs~t|}|dkrtdt|t}tj|}t|d}|ddtj|dd}|dkr`|}nt||d}|rzt|}|S)aa Return the derivative of the specified order of a polynomial. Parameters ---------- p : poly1d or sequence Polynomial to differentiate. A sequence is interpreted as polynomial coefficients, see `poly1d`. m : int, optional Order of differentiation (default: 1) Returns ------- der : poly1d A new polynomial representing the derivative. See Also -------- polyint : Anti-derivative of a polynomial. poly1d : Class for one-dimensional polynomials. Examples -------- The derivative of the polynomial :math:`x^3 + x^2 + x^1 + 1` is: >>> p = np.poly1d([1,1,1,1]) >>> p2 = np.polyder(p) >>> p2 poly1d([3, 2, 1]) which evaluates to: >>> p2(2.) 17.0 We can verify this, approximating the derivative with ``(f(x + h) - f(x))/h``: >>> (p(2. + 0.001) - p(2.)) / 0.001 17.007000999997857 The fourth-order derivative of a 3rd-order polynomial is zero: >>> np.polyder(p, 2) poly1d([6, 2]) >>> np.polyder(p, 3) poly1d([6]) >>> np.polyder(p, 4) poly1d([0.]) r z2Order of derivative must be positive (see polyint)r,NrHrH) rJr5rQr r7r<r1rTr)rFrOrUnrVrWr'r'r(rcs5   cCs |||fS)Nr')xrVdegrcondr.wcovr'r'r(_polyfit_dispatchersr_FcCs^t|d}tj|d}tj|d}|dkr8td|jdkrJtd|jdkr\td|jdksp|jdkrxtd|jd|jdkrtd |d krt|t |j j }t ||}|} |d k rHtj|d}|jdkrtd |jd|jdkrtd ||d d tj f9}| jdkr@| |d d tj f9} n| |9} tj||jdd } || }t|| |\} } } }| j| j} | |kr| rd}tj|tdd|r| | | ||fS|rVtt|j|}|tj| | }|dkrd}n&t||kr td| t||}|jdkr4| ||fS| |d d d d tj f|fSn| Sd S)a  Least squares polynomial fit. Fit a polynomial ``p(x) = p[0] * x**deg + ... + p[deg]`` of degree `deg` to points `(x, y)`. Returns a vector of coefficients `p` that minimises the squared error in the order `deg`, `deg-1`, ... `0`. The `Polynomial.fit ` class method is recommended for new code as it is more stable numerically. See the documentation of the method for more information. Parameters ---------- x : array_like, shape (M,) x-coordinates of the M sample points ``(x[i], y[i])``. y : array_like, shape (M,) or (M, K) y-coordinates of the sample points. Several data sets of sample points sharing the same x-coordinates can be fitted at once by passing in a 2D-array that contains one dataset per column. deg : int Degree of the fitting polynomial 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 to apply to the y-coordinates of the sample points. For gaussian uncertainties, use 1/sigma (not 1/sigma**2). cov : bool or str, optional If given and not `False`, return not just the estimate but also its covariance matrix. By default, the covariance are scaled by chi2/sqrt(N-dof), i.e., the weights are presumed to be unreliable except in a relative sense and everything is scaled such that the reduced chi2 is unity. This scaling is omitted if ``cov='unscaled'``, as is relevant for the case that the weights are 1/sigma**2, with sigma known to be a reliable estimate of the uncertainty. Returns ------- p : ndarray, shape (deg + 1,) or (deg + 1, K) Polynomial coefficients, highest power first. If `y` was 2-D, the coefficients for `k`-th data set are in ``p[:,k]``. residuals, rank, singular_values, rcond Present only if `full` = True. Residuals is sum of squared residuals of the least-squares fit, the effective rank of the scaled Vandermonde coefficient matrix, its singular values, and the specified value of `rcond`. For more details, see `linalg.lstsq`. V : ndarray, shape (M,M) or (M,M,K) Present only if `full` = False and `cov`=True. The covariance matrix of the polynomial coefficient estimates. The diagonal of this matrix are the variance estimates for each coefficient. If y is a 2-D array, then the covariance matrix for the `k`-th data set are in ``V[:,:,k]`` 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', np.RankWarning) See Also -------- polyval : Compute polynomial values. linalg.lstsq : Computes a least-squares fit. scipy.interpolate.UnivariateSpline : Computes spline fits. Notes ----- The solution minimizes the squared error .. math :: E = \sum_{j=0}^k |p(x_j) - y_j|^2 in the equations:: x[0]**n * p[0] + ... + x[0] * p[n-1] + p[n] = y[0] x[1]**n * p[0] + ... + x[1] * p[n-1] + p[n] = y[1] ... x[k]**n * p[0] + ... + x[k] * p[n-1] + p[n] = y[k] The coefficient matrix of the coefficients `p` is a Vandermonde matrix. `polyfit` issues a `RankWarning` when the least-squares fit is badly conditioned. This implies that the best fit is not well-defined due to numerical error. The results may be improved by lowering the polynomial degree or by replacing `x` by `x` - `x`.mean(). The `rcond` parameter can also be set to a value smaller than its default, but the resulting fit may be spurious: including contributions from the small singular values can add numerical noise to the result. Note that fitting polynomial coefficients is inherently badly conditioned when the degree of the polynomial is large or the interval of sample points is badly centered. The quality of the fit should always be checked in these cases. When polynomial fits are not satisfactory, splines may be a good alternative. References ---------- .. [1] Wikipedia, "Curve fitting", https://en.wikipedia.org/wiki/Curve_fitting .. [2] Wikipedia, "Polynomial interpolation", https://en.wikipedia.org/wiki/Polynomial_interpolation Examples -------- >>> import warnings >>> x = np.array([0.0, 1.0, 2.0, 3.0, 4.0, 5.0]) >>> y = np.array([0.0, 0.8, 0.9, 0.1, -0.8, -1.0]) >>> z = np.polyfit(x, y, 3) >>> z array([ 0.08703704, -0.81349206, 1.69312169, -0.03968254]) # may vary It is convenient to use `poly1d` objects for dealing with polynomials: >>> p = np.poly1d(z) >>> p(0.5) 0.6143849206349179 # may vary >>> p(3.5) -0.34732142857143039 # may vary >>> p(10) 22.579365079365115 # may vary High-order polynomials may oscillate wildly: >>> with warnings.catch_warnings(): ... warnings.simplefilter('ignore', np.RankWarning) ... p30 = np.poly1d(np.polyfit(x, y, 30)) ... >>> p30(4) -0.80000000000000204 # may vary >>> p30(5) -0.99999999999999445 # may vary >>> p30(4.5) -0.10547061179440398 # may vary Illustration: >>> import matplotlib.pyplot as plt >>> xp = np.linspace(-2, 6, 100) >>> _ = plt.plot(x, y, '.', xp, p(xp), '-', xp, p30(xp), '--') >>> plt.ylim(-2,2) (-2, 2) >>> plt.show() r,gr zexpected deg >= 0zexpected 1D vector for xzexpected non-empty vector for xr+zexpected 1D or 2D array for yz$expected x and y to have same lengthNz expected a 1-d array for weightsz(expected w and y to have the same length)Zaxisz!Polyfit may be poorly conditioned) stacklevelZunscaledzJthe number of data points must exceed order to scale the covariance matrix)rJr7r<r5rI TypeErrorsizer0r1rr-ZepsrZnewaxissqrtsumr Twarningswarnr r!router)rZrVr[r\r.r]r^orderlhsrhsscalecZresidsZranksmsgZVbaseZfacr'r'r(r sb!           "cCs||fS)Nr')rFrZr'r'r(_polyval_dispatchersrqcCsXtj|}t|trd}ntj|}tj|}x$tt|D]}||||}q `values` array_like, `x` a poly1d object => `values` is also. See Also -------- poly1d: A polynomial class. Notes ----- Horner's scheme [1]_ is used to evaluate the polynomial. Even so, for polynomials of high degree the values may be inaccurate due to rounding errors. Use carefully. If `x` is a subtype of `ndarray` the return value will be of the same type. References ---------- .. [1] I. N. Bronshtein, K. A. Semendyayev, and K. A. Hirsch (Eng. trans. Ed.), *Handbook of Mathematics*, New York, Van Nostrand Reinhold Co., 1985, pg. 720. Examples -------- >>> np.polyval([3,0,1], 5) # 3 * 5**2 + 0 * 5**1 + 1 76 >>> np.polyval([3,0,1], np.poly1d(5)) poly1d([76.]) >>> np.polyval(np.poly1d([3,0,1]), 5) 76 >>> np.polyval(np.poly1d([3,0,1]), np.poly1d(5)) poly1d([76.]) r )r7r<rQr Z asanyarrayZ zeros_liker6r1)rFrZrVir'r'r(r s>    cCs||fS)Nr')a1a2r'r'r(_binary_op_dispatchersrucCst|tpt|t}t|}t|}t|t|}|dkrF||}nN|dkrptj||j}tj||f|}n$tjt||j}|tj||f}|rt|}|S)a6 Find the sum of two polynomials. Returns the polynomial resulting from the sum of two input polynomials. Each input must be either a poly1d object or a 1D sequence of polynomial coefficients, from highest to lowest degree. Parameters ---------- a1, a2 : array_like or poly1d object Input polynomials. Returns ------- out : ndarray or poly1d object The sum of the inputs. If either input is a poly1d object, then the output is also a poly1d object. Otherwise, it is a 1D array of polynomial coefficients from highest to lowest degree. See Also -------- poly1d : A one-dimensional polynomial class. poly, polyadd, polyder, polydiv, polyfit, polyint, polysub, polyval Examples -------- >>> np.polyadd([1, 2], [9, 5, 4]) array([9, 6, 6]) Using poly1d objects: >>> p1 = np.poly1d([1, 2]) >>> p2 = np.poly1d([9, 5, 4]) >>> print(p1) 1 x + 2 >>> print(p2) 2 9 x + 5 x + 4 >>> print(np.polyadd(p1, p2)) 2 9 x + 6 x + 6 r ) rQr rr1r7rLr-rRr)rsrtrUdiffrWzrr'r'r(rs- cCst|tpt|t}t|}t|}t|t|}|dkrF||}nN|dkrptj||j}tj||f|}n$tjt||j}|tj||f}|rt|}|S)a Difference (subtraction) of two polynomials. Given two polynomials `a1` and `a2`, returns ``a1 - a2``. `a1` and `a2` can be either array_like sequences of the polynomials' coefficients (including coefficients equal to zero), or `poly1d` objects. Parameters ---------- a1, a2 : array_like or poly1d Minuend and subtrahend polynomials, respectively. Returns ------- out : ndarray or poly1d Array or `poly1d` object of the difference polynomial's coefficients. See Also -------- polyval, polydiv, polymul, polyadd Examples -------- .. math:: (2 x^2 + 10 x - 2) - (3 x^2 + 10 x -4) = (-x^2 + 2) >>> np.polysub([2, 10, -2], [3, 10, -4]) array([-1, 0, 2]) r ) rQr rr1r7rLr-rRr)rsrtrUrvrWrwr'r'r(r$s cCsBt|tpt|t}t|t|}}tj||}|r>t|}|S)a# Find the product of two polynomials. Finds the polynomial resulting from the multiplication of the two input polynomials. Each input must be either a poly1d object or a 1D sequence of polynomial coefficients, from highest to lowest degree. Parameters ---------- a1, a2 : array_like or poly1d object Input polynomials. Returns ------- out : ndarray or poly1d object The polynomial resulting from the multiplication of the inputs. If either inputs is a poly1d object, then the output is also a poly1d object. Otherwise, it is a 1D array of polynomial coefficients from highest to lowest degree. See Also -------- poly1d : A one-dimensional polynomial class. poly, polyadd, polyder, polydiv, polyfit, polyint, polysub, polyval convolve : Array convolution. Same output as polymul, but has parameter for overlap mode. Examples -------- >>> np.polymul([1, 2, 3], [9, 5, 1]) array([ 9, 23, 38, 17, 3]) Using poly1d objects: >>> p1 = np.poly1d([1, 2, 3]) >>> p2 = np.poly1d([9, 5, 1]) >>> print(p1) 2 1 x + 2 x + 3 >>> print(p2) 2 9 x + 5 x + 1 >>> print(np.polymul(p1, p2)) 4 3 2 9 x + 23 x + 38 x + 17 x + 3 )rQr r7r8)rsrtrUrWr'r'r(rTs 1 cCs||fS)Nr')uvr'r'r(_polydiv_dispatchersrzc Cs.t|tpt|t}t|d}t|d}|d|d}t|d}t|d}d|d}tjt||ddf|j}|j|j}xNt d||dD]8} ||| } | || <|| | |d| |8<qWx4tj |ddddo|j ddkr|dd}qW|r&t|t|fS||fS) a Returns the quotient and remainder of polynomial division. The input arrays are the coefficients (including any coefficients equal to zero) of the "numerator" (dividend) and "denominator" (divisor) polynomials, respectively. Parameters ---------- u : array_like or poly1d Dividend polynomial's coefficients. v : array_like or poly1d Divisor polynomial's coefficients. Returns ------- q : ndarray Coefficients, including those equal to zero, of the quotient. r : ndarray Coefficients, including those equal to zero, of the remainder. See Also -------- poly, polyadd, polyder, polydiv, polyfit, polyint, polymul, polysub polyval Notes ----- Both `u` and `v` must be 0-d or 1-d (ndim = 0 or 1), but `u.ndim` need not equal `v.ndim`. In other words, all four possible combinations - ``u.ndim = v.ndim = 0``, ``u.ndim = v.ndim = 1``, ``u.ndim = 1, v.ndim = 0``, and ``u.ndim = 0, v.ndim = 1`` - work. Examples -------- .. math:: \frac{3x^2 + 5x + 2}{2x + 1} = 1.5x + 1.75, remainder 0.25 >>> x = np.array([3.0, 5.0, 2.0]) >>> y = np.array([2.0, 1.0]) >>> np.polydiv(x, y) (array([1.5 , 1.75]), array([0.25])) gr r,g?g+=)ZrtolNrH) rQr rr1r7rLmaxr-r3r6Zallcloser0) rxryrUr]rOrYrmqrrEdr'r'r(rs$.       $&z[*][*]([0-9]*)Fc Csd}d}d}d}xtj||}|dkr(P|j}|jd}|||d} |d}| dt|d} dt| d|} t|t| |kst|t| |kr||d|d7}| }| }q|| dt|d7}|dt| d|7}qW||d|7}|||dS)Nr  r, z ) _poly_matsearchspangroupsr1) ZastrwraprYZline1Zline2outputmatrpowerZpartstrZtoadd2Ztoadd1r'r'r( _raise_powers.  rc@sPeZdZdZdZeddZejddZeddZedd Z ed d Z ed d Z e jdd Z e Z eZ ZZe ZdBddZdCddZddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Z e Z!d0d1Z"e"Z#d2d3Z$d4d5Z%d6d7Z&d8d9Z'd:d;Z(dDd>d?Z)dEd@dAZ*dS)Fr a@ A one-dimensional polynomial class. A convenience class, used to encapsulate "natural" operations on polynomials so that said operations may take on their customary form in code (see Examples). Parameters ---------- c_or_r : array_like The polynomial's coefficients, in decreasing powers, or if the value of the second parameter is True, the polynomial's roots (values where the polynomial evaluates to 0). For example, ``poly1d([1, 2, 3])`` returns an object that represents :math:`x^2 + 2x + 3`, whereas ``poly1d([1, 2, 3], True)`` returns one that represents :math:`(x-1)(x-2)(x-3) = x^3 - 6x^2 + 11x -6`. r : bool, optional If True, `c_or_r` specifies the polynomial's roots; the default is False. variable : str, optional Changes the variable used when printing `p` from `x` to `variable` (see Examples). Examples -------- Construct the polynomial :math:`x^2 + 2x + 3`: >>> p = np.poly1d([1, 2, 3]) >>> print(np.poly1d(p)) 2 1 x + 2 x + 3 Evaluate the polynomial at :math:`x = 0.5`: >>> p(0.5) 4.25 Find the roots: >>> p.r array([-1.+1.41421356j, -1.-1.41421356j]) >>> p(p.r) array([ -4.44089210e-16+0.j, -4.44089210e-16+0.j]) # may vary These numbers in the previous line represent (0, 0) to machine precision Show the coefficients: >>> p.c array([1, 2, 3]) Display the order (the leading zero-coefficients are removed): >>> p.order 2 Show the coefficient of the k-th power in the polynomial (which is equivalent to ``p.c[-(i+1)]``): >>> p[1] 2 Polynomials can be added, subtracted, multiplied, and divided (returns quotient and remainder): >>> p * p poly1d([ 1, 4, 10, 12, 9]) >>> (p**3 + 4) / p (poly1d([ 1., 4., 10., 12., 9.]), poly1d([4.])) ``asarray(p)`` gives the coefficient array, so polynomials can be used in all functions that accept arrays: >>> p**2 # square of polynomial poly1d([ 1, 4, 10, 12, 9]) >>> np.square(p) # square of individual coefficients array([1, 4, 9]) The variable used in the string representation of `p` can be modified, using the `variable` parameter: >>> p = np.poly1d([1,2,3], variable='z') >>> print(p) 2 1 z + 2 z + 3 Construct a polynomial from its roots: >>> np.poly1d([1, 2], True) poly1d([ 1., -3., 2.]) This is the same polynomial as obtained by: >>> np.poly1d([1, -1]) * np.poly1d([1, -2]) poly1d([ 1, -3, 2]) NcCs|jS)z The polynomial coefficients )_coeffs)selfr'r'r(coeffsVsz poly1d.coeffscCs||jk rtddS)NzCannot set attribute)rAttributeError)rvaluer'r'r(r[s cCs|jS)z% The name of the polynomial variable ) _variable)rr'r'r(variableaszpoly1d.variablecCst|jdS)z' The order or degree of the polynomial r,)r1r)rr'r'r(rjgsz poly1d.ordercCs t|jS)z1 The roots of the polynomial, where self(x) == 0 )rr)rr'r'r(rlsz poly1d.rootscCs |jdS)Nr)__dict__)rr'r'r(rsszpoly1d._coeffscCs||jd<dS)Nr)r)rrr'r'r(rvsFcCst|trb|j|_|j|_t|jt|jrPd}tj|tdd|jj |j|dk r^||_dS|rnt |}t |}|j dkrt dt|dd}t|dkrtjd g}||_|dkrd }||_dS) NzbIn the future extra properties will not be copied across when constructing one poly1d from anotherr+)rar,zPolynomial must be 1d only.f)Ztrimr grZ)rQr rrsetrrgrh FutureWarningupdaterrrIr5rr1r7r)rZc_or_rr}rrpr'r'r(__init__s,     zpoly1d.__init__cCs"|rtj|j|Stj|jSdS)N)r7r<r)rtr'r'r( __array__szpoly1d.__array__cCst|j}|dd}d|S)Nr,z poly1d(%s)rH)reprr)rvalsr'r'r(__repr__s  zpoly1d.__repr__cCs|jS)N)rj)rr'r'r(__len__szpoly1d.__len__c Csd}|j}|jtjj|jdk}t|d}dd}xltt|D]Z}t||sj|t||}nJt||dkrd|t ||}n$d|t|||t ||f}||}|dkr|dkrd|f} n|dkrd} nd } nn|dkr$|dkrd } n|d kr|} n d ||f} n6|dkr4d } n&|d krLd ||f} nd |||f} |dkr| d kr| j drd|| ddf}n d|| f}qF| }qFWt |S)N0r r,cSs"d|}|jdr|dd}|S)Nz%.4gz.0000)endswith)r|ror'r'r( fmt_floats  z!poly1d.__str__..fmt_floatz%sjz (%s + %sj)z%srbz%s %sz%s**%dz %s %s**%d-z%s - %sz%s + %s) rrr7 logical_or accumulater1r6rrr startswithr) rZthestrvarrrMrrEZcoefstrrZnewstrr'r'r(__str__sJ           zpoly1d.__str__cCs t|j|S)N)r r)rrWr'r'r(__call__szpoly1d.__call__cCs t|j S)N)r r)rr'r'r(__neg__szpoly1d.__neg__cCs|S)Nr')rr'r'r(__pos__szpoly1d.__pos__cCs4t|rt|j|St|}tt|j|jSdS)N)rr rr)rotherr'r'r(__mul__szpoly1d.__mul__cCs4t|rt||jSt|}tt|j|jSdS)N)rr rr)rrr'r'r(__rmul__szpoly1d.__rmul__cCst|}tt|j|jS)N)r rr)rrr'r'r(__add__szpoly1d.__add__cCst|}tt|j|jS)N)r rr)rrr'r'r(__radd__szpoly1d.__radd__cCsRt| st||ks|dkr&tddg}xt|D]}t|j|}q6Wt|S)Nr z$Power to non-negative integers only.r,)rrJr5r6rrr )rrWres_r'r'r(__pow__s zpoly1d.__pow__cCst|}tt|j|jS)N)r rr)rrr'r'r(__sub__szpoly1d.__sub__cCst|}tt|j|jS)N)r rr)rrr'r'r(__rsub__ szpoly1d.__rsub__cCs,t|rt|j|St|}t||SdS)N)rr rr)rrr'r'r(__div__szpoly1d.__div__cCs,t|rt||jSt|}t||SdS)N)rr rr)rrr'r'r(__rdiv__szpoly1d.__rdiv__cCs2t|tstS|jj|jjkr"dS|j|jkjS)NF)rQr NotImplementedrr0r>)rrr'r'r(__eq__"s  z poly1d.__eq__cCst|tstS|j| S)N)rQr rr)rrr'r'r(__ne__)s z poly1d.__ne__cCs.|j|}||jkrdS|dkr$dS|j|S)Nr )rjr)rrWindr'r'r( __getitem__/s   zpoly1d.__getitem__cCs^|j|}|dkrtd||jkrPtj||j|jj}tj||jf|_d}||j|<dS)Nr z!Does not support negative powers.)rjr5r7rLrr-rRr)rkeyrWrrwr'r'r( __setitem__7s   zpoly1d.__setitem__cCs t|jS)N)iterr)rr'r'r(__iter__Bszpoly1d.__iter__r,r cCstt|j||dS)z Return an antiderivative (indefinite integral) of this polynomial. Refer to `polyint` for full documentation. See Also -------- polyint : equivalent function )rOrE)r rr)rrOrEr'r'r(integEs z poly1d.integcCstt|j|dS)z Return a derivative of this polynomial. Refer to `polyder` for full documentation. See Also -------- polyder : equivalent function )rO)r rr)rrOr'r'r(derivRs z poly1d.deriv)FN)N)r,r )r,)+r#r$r%r&__hash__propertyrsetterrrjrrr}rnZcoefZ coefficientsorrrrrrrrrrrrrrrrrSr __rtruediv__rrrrrrrr'r'r'r(r sLd        9  always)NN)r,N)N)r,)NNNN)NFNF)r)>r&__all__ functoolsrergZnumpy.core.numericcorenumericr7Z numpy.corerrrrrrrrrZnumpy.core.overridesrZnumpy.lib.twodim_baserrZnumpy.lib.function_baserZnumpy.lib.type_checkrrrrZ numpy.linalgrr r!partialZarray_function_dispatch UserWarningr r*rrGrrPrrXrr_r rqr rurrrrzrcompilerrr simplefilterr'r'r'r(s\   (     vV  ^  E  hI>09B  t