Hacked By AnonymousFox
�
�܋fؿ � � � d Z g d�ZddlZddlmZ ddlmZ ddl m
Z ddlm
Z
ej Z ej ddg� � Z ej dg� � Z ej dg� � Z ej ddg� � Zd � Zd
� Zd� Zd� Zd
� Zd� Zd� Zd#d�Zd$d�Zdg dddfd�Zd%d�Zd%d�Z d� Z!d� Z"d� Z#d� Z$d� Z%d� Z&d� Z'd&d�Z(d� Z)d � Z* G d!� d"e
� � Z+dS )'a�
=================================================
Power Series (:mod:`numpy.polynomial.polynomial`)
=================================================
This module provides a number of objects (mostly functions) useful for
dealing with polynomials, including a `Polynomial` class that
encapsulates the usual arithmetic operations. (General information
on how this module represents and works with polynomial objects is in
the docstring for its "parent" sub-package, `numpy.polynomial`).
Classes
-------
.. autosummary::
:toctree: generated/
Polynomial
Constants
---------
.. autosummary::
:toctree: generated/
polydomain
polyzero
polyone
polyx
Arithmetic
----------
.. autosummary::
:toctree: generated/
polyadd
polysub
polymulx
polymul
polydiv
polypow
polyval
polyval2d
polyval3d
polygrid2d
polygrid3d
Calculus
--------
.. autosummary::
:toctree: generated/
polyder
polyint
Misc Functions
--------------
.. autosummary::
:toctree: generated/
polyfromroots
polyroots
polyvalfromroots
polyvander
polyvander2d
polyvander3d
polycompanion
polyfit
polytrim
polyline
See Also
--------
`numpy.polynomial`
)�polyzero�polyone�polyx�
polydomain�polyline�polyadd�polysub�polymulx�polymul�polydiv�polypow�polyval�polyvalfromroots�polyder�polyint�
polyfromroots�
polyvander�polyfit�polytrim� polyroots�
Polynomial� polyval2d� polyval3d�
polygrid2d�
polygrid3d�polyvander2d�polyvander3d� N)�normalize_axis_index� )� polyutils)�ABCPolyBase���c �d � |dk rt j | |g� � S t j | g� � S )a�
Returns an array representing a linear polynomial.
Parameters
----------
off, scl : scalars
The "y-intercept" and "slope" of the line, respectively.
Returns
-------
y : ndarray
This module's representation of the linear polynomial ``off +
scl*x``.
See Also
--------
numpy.polynomial.chebyshev.chebline
numpy.polynomial.legendre.legline
numpy.polynomial.laguerre.lagline
numpy.polynomial.hermite.hermline
numpy.polynomial.hermite_e.hermeline
Examples
--------
>>> from numpy.polynomial import polynomial as P
>>> P.polyline(1,-1)
array([ 1, -1])
>>> P.polyval(1, P.polyline(1,-1)) # should be 0
0.0
r )�np�array)�off�scls �R/opt/cloudlinux/venv/lib64/python3.11/site-packages/numpy/polynomial/polynomial.pyr r q s2 � �@ �a�x�x��x��c�
�#�#�#��x������ c �B � t j t t | � � S )a
Generate a monic polynomial with given roots.
Return the coefficients of the polynomial
.. math:: p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n),
where the ``r_n`` are the roots specified in `roots`. If a zero has
multiplicity n, then it must appear in `roots` n times. For instance,
if 2 is a root of multiplicity three and 3 is a root of multiplicity 2,
then `roots` looks something like [2, 2, 2, 3, 3]. The roots can appear
in any order.
If the returned coefficients are `c`, then
.. math:: p(x) = c_0 + c_1 * x + ... + x^n
The coefficient of the last term is 1 for monic polynomials in this
form.
Parameters
----------
roots : array_like
Sequence containing the roots.
Returns
-------
out : ndarray
1-D array of the polynomial's coefficients If all the roots are
real, then `out` is also real, otherwise it is complex. (see
Examples below).
See Also
--------
numpy.polynomial.chebyshev.chebfromroots
numpy.polynomial.legendre.legfromroots
numpy.polynomial.laguerre.lagfromroots
numpy.polynomial.hermite.hermfromroots
numpy.polynomial.hermite_e.hermefromroots
Notes
-----
The coefficients are determined by multiplying together linear factors
of the form ``(x - r_i)``, i.e.
.. math:: p(x) = (x - r_0) (x - r_1) ... (x - r_n)
where ``n == len(roots) - 1``; note that this implies that ``1`` is always
returned for :math:`a_n`.
Examples
--------
>>> from numpy.polynomial import polynomial as P
>>> P.polyfromroots((-1,0,1)) # x(x - 1)(x + 1) = x^3 - x
array([ 0., -1., 0., 1.])
>>> j = complex(0,1)
>>> P.polyfromroots((-j,j)) # complex returned, though values are real
array([1.+0.j, 0.+0.j, 1.+0.j])
)�pu�
_fromrootsr r
)�rootss r( r r � s � �z �=��7�E�2�2�2r) c �, � t j | |� � S )a
Add one polynomial to another.
Returns the sum of two polynomials `c1` + `c2`. The arguments are
sequences of coefficients from lowest order term to highest, i.e.,
[1,2,3] represents the polynomial ``1 + 2*x + 3*x**2``.
Parameters
----------
c1, c2 : array_like
1-D arrays of polynomial coefficients ordered from low to high.
Returns
-------
out : ndarray
The coefficient array representing their sum.
See Also
--------
polysub, polymulx, polymul, polydiv, polypow
Examples
--------
>>> from numpy.polynomial import polynomial as P
>>> c1 = (1,2,3)
>>> c2 = (3,2,1)
>>> sum = P.polyadd(c1,c2); sum
array([4., 4., 4.])
>>> P.polyval(2, sum) # 4 + 4(2) + 4(2**2)
28.0
)r+ �_add��c1�c2s r( r r � s � �B �7�2�r�?�?�r) c �, � t j | |� � S )a-
Subtract one polynomial from another.
Returns the difference of two polynomials `c1` - `c2`. The arguments
are sequences of coefficients from lowest order term to highest, i.e.,
[1,2,3] represents the polynomial ``1 + 2*x + 3*x**2``.
Parameters
----------
c1, c2 : array_like
1-D arrays of polynomial coefficients ordered from low to
high.
Returns
-------
out : ndarray
Of coefficients representing their difference.
See Also
--------
polyadd, polymulx, polymul, polydiv, polypow
Examples
--------
>>> from numpy.polynomial import polynomial as P
>>> c1 = (1,2,3)
>>> c2 = (3,2,1)
>>> P.polysub(c1,c2)
array([-2., 0., 2.])
>>> P.polysub(c2,c1) # -P.polysub(c1,c2)
array([ 2., 0., -2.])
)r+ �_subr0 s r( r r � s � �D �7�2�r�?�?�r) c � � t j | g� � \ } t | � � dk r| d dk r| S t j t | � � dz | j �� � }| d dz |d<