
    Kh                     p    S r SSKrSSKrSSKrSSKJr  SSKrSSKJ	r
  S/r " S S\R                  5      rg)a  
Abstract base class for the various polynomial Classes.

The ABCPolyBase class provides the methods needed to implement the common API
for the various polynomial classes. It operates as a mixin, but uses the
abc module from the stdlib, hence it is only available for Python >= 2.6.

    N)Callable   )	polyutilsABCPolyBasec                   z   \ rS rSrSrSrSrSr\R                  SSSSS	S
SSSSS.
5      r
\R                  SSSSSSSSSSS.
5      r\R                  S:X  + r\S 5       r\\R$                  S 5       5       r\\R$                  S 5       5       r\\R$                  S 5       5       r\\R$                  S 5       5       r\\R$                  S  5       5       r\\R$                  S! 5       5       r\\R$                  S" 5       5       r\\R$                  SjS# j5       5       r\\R$                  S$ 5       5       r\\R$                  S% 5       5       r\\R$                  S& 5       5       r\\R$                  S' 5       5       r\\R$                  S( 5       5       r \\R$                  S) 5       5       r!\\R$                  S* 5       5       r"S+ r#S, r$S- r%S. r&S/ r'SkS1 jr(S2 r)S3 r*S4 r+S5 r,\-S6 5       r.\-S7 5       r/\-S8 5       r0\SlS9 j5       r1S:\2S;\3S<\34S= jr4S> r5S? r6S@ r7SA r8SB r9SC r:SD r;SE r<SF r=SG r>SH r?SI r@SJ rASK rBSL rCSM rDSN rESO rFSP rGSQ rHSR rISS rJST rKSU rLSV rMSW rNSX rOSY rPSZ rQSmS[ jrRS\ rSSnS] jrTS^ rUS_/ S4S` jrVSoSa jrWSb rXSpSc jrY\-  SqSd j5       rZ\-/ SS04Se j5       r[\-SkSf j5       r\\-SkSg j5       r]\-SrSh j5       r^Sir_g)sr      aF  An abstract base class for immutable series classes.

ABCPolyBase provides the standard Python numerical methods
'+', '-', '*', '//', '%', 'divmod', '**', and '()' along with the
methods listed below.

Parameters
----------
coef : array_like
    Series coefficients in order of increasing degree, i.e.,
    ``(1, 2, 3)`` gives ``1*P_0(x) + 2*P_1(x) + 3*P_2(x)``, where
    ``P_i`` is the basis polynomials of degree ``i``.
domain : (2,) array_like, optional
    Domain to use. The interval ``[domain[0], domain[1]]`` is mapped
    to the interval ``[window[0], window[1]]`` by shifting and scaling.
    The default value is the derived class domain.
window : (2,) array_like, optional
    Window, see domain for its use. The default value is the
    derived class window.
symbol : str, optional
    Symbol used to represent the independent variable in string
    representations of the polynomial expression, e.g. for printing.
    The symbol must be a valid Python identifier. Default value is 'x'.

    .. versionadded:: 1.24

Attributes
----------
coef : (N,) ndarray
    Series coefficients in order of increasing degree.
domain : (2,) ndarray
    Domain that is mapped to window.
window : (2,) ndarray
    Window that domain is mapped to.
symbol : str
    Symbol representing the independent variable.

Class Attributes
----------------
maxpower : int
    Maximum power allowed, i.e., the largest number ``n`` such that
    ``p(x)**n`` is allowed. This is to limit runaway polynomial size.
domain : (2,) ndarray
    Default domain of the class.
window : (2,) ndarray
    Default window of the class.

Nd   u   ⁰   ¹   ²   ³u   ⁴u   ⁵u   ⁶u   ⁷u   ⁸u   ⁹)
0123456789u   ₀u   ₁u   ₂u   ₃u   ₄u   ₅u   ₆u   ₇u   ₈u   ₉ntc                     U R                   $ N)_symbolselfs    L/var/www/html/env/lib/python3.13/site-packages/numpy/polynomial/_polybase.pysymbolABCPolyBase.symbolm   s    ||    c                     g r    r   s    r   domainABCPolyBase.domainq        	r    c                     g r   r"   r   s    r   windowABCPolyBase.windowv   r%   r    c                     g r   r"   r   s    r   
basis_nameABCPolyBase.basis_name{   r%   r    c                     g r   r"   c1c2s     r   _addABCPolyBase._add   r%   r    c                     g r   r"   r-   s     r   _subABCPolyBase._sub   r%   r    c                     g r   r"   r-   s     r   _mulABCPolyBase._mul   r%   r    c                     g r   r"   r-   s     r   _divABCPolyBase._div   r%   r    c                     g r   r"   )cpowmaxpowers      r   _powABCPolyBase._pow   r%   r    c                     g r   r"   )xr<   s     r   _valABCPolyBase._val   r%   r    c                     g r   r"   )r<   mklbndscls        r   _intABCPolyBase._int   r%   r    c                     g r   r"   )r<   rF   rI   s      r   _derABCPolyBase._der   r%   r    c                     g r   r"   )rB   ydegrcondfulls        r   _fitABCPolyBase._fit   r%   r    c                     g r   r"   )offrI   s     r   _lineABCPolyBase._line   r%   r    c                     g r   r"   )r<   s    r   _rootsABCPolyBase._roots   r%   r    c                     g r   r"   )rs    r   
_fromrootsABCPolyBase._fromroots   r%   r    c                     [        U R                  5      [        UR                  5      :w  a  g[        R                  " U R                  UR                  :H  5      (       d  gg)zCheck if coefficients match.

Parameters
----------
other : class instance
    The other class must have the ``coef`` attribute.

Returns
-------
bool : boolean
    True if the coefficients are the same, False otherwise.

FT)lencoefnpallr   others     r   has_samecoefABCPolyBase.has_samecoef   sA     tyy>S_,		UZZ/00r    c                 \    [         R                  " U R                  UR                  :H  5      $ )zCheck if domains match.

Parameters
----------
other : class instance
    The other class must have the ``domain`` attribute.

Returns
-------
bool : boolean
    True if the domains are the same, False otherwise.

)rd   re   r#   rf   s     r   has_samedomainABCPolyBase.has_samedomain         vvdkkU\\122r    c                 \    [         R                  " U R                  UR                  :H  5      $ )zCheck if windows match.

Parameters
----------
other : class instance
    The other class must have the ``window`` attribute.

Returns
-------
bool : boolean
    True if the windows are the same, False otherwise.

)rd   re   r'   rf   s     r   has_samewindowABCPolyBase.has_samewindow   rm   r    c                 ,    [        XR                  5      $ )zCheck if types match.

Parameters
----------
other : object
    Class instance.

Returns
-------
bool : boolean
    True if other is same class as self

)
isinstance	__class__rf   s     r   has_sametypeABCPolyBase.has_sametype   s     %00r    c                    [        U[        5      (       a  [        XR                  5      (       d  [        S5      e[        R
                  " U R                  UR                  :H  5      (       d  [        S5      e[        R
                  " U R                  UR                  :H  5      (       d  [        S5      eU R                  UR                  :w  a  [        S5      eUR                  $ U$ )a  Interpret other as polynomial coefficients.

The `other` argument is checked to see if it is of the same
class as self with identical domain and window. If so,
return its coefficients, otherwise return `other`.

Parameters
----------
other : anything
    Object to be checked.

Returns
-------
coef
    The coefficients of`other` if it is a compatible instance,
    of ABCPolyBase, otherwise `other`.

Raises
------
TypeError
    When `other` is an incompatible instance of ABCPolyBase.

zPolynomial types differzDomains differzWindows differzPolynomial symbols differ)rr   r   rs   	TypeErrorrd   re   r#   r'   r   
ValueErrorrc   rf   s     r   _get_coefficientsABCPolyBase._get_coefficients  s    0 e[))e^^44 9::VVDKK5<<788 011VVDKK5<<788 011, !<==::r    rB   c                    [         R                  " U/SS9u  nXl        Ub8  [         R                  " U/SS9u  n[        U5      S:w  a  [	        S5      eX l        Ub8  [         R                  " U/SS9u  n[        U5      S:w  a  [	        S5      eX0l         UR                  5       (       d  [	        S5      e X@l
        g ! [         a    [        S5      ef = f)NFtrim   z$Domain has wrong number of elements.z$Window has wrong number of elements.z/Symbol string must be a valid Python identifierz!Symbol must be a non-empty string)pu	as_seriesrc   rb   rx   r#   r'   isidentifierAttributeErrorrw   r   )r   rc   r#   r'   r   s        r   __init__ABCPolyBase.__init__%  s    tf51	||VH59HV6{a !GHH K||VH59HV6{a !GHH K		A&&(( E  )   	A?@@	As    B> >Cc           
          [        U R                  5      SS n[        U R                  5      SS n[        U R                  5      SS nU R                  R
                  nU SU SU SU SU R                   S3
$ )N   (z	, domain=z	, window=z
, symbol='z'))reprrc   r#   r'   rs   __name__r   )r   rc   r#   r'   names        r   __repr__ABCPolyBase.__repr__C  s    DIIq$dkk"1R(dkk"1R(~~&&&$y	& B;;-r+ 	,r    c                     US:X  a  U R                  5       $ US;  a  [        SU SU R                   S35      eUS:X  a  U R                  U R                  5      $ U R                  U R
                  5      $ )N )asciiunicodezUnsupported format string 'z' passed to z4.__format__. Valid options are 'ascii' and 'unicode'r   )__str__rx   rs   _generate_string_str_term_ascii_str_term_unicode)r   fmt_strs     r   
__format__ABCPolyBase.__format__K  s    b=<<>!..-gYl>>" #() 
 g(()=)=>>$$T%;%;<<r    c                     U R                   (       a  U R                  U R                  5      $ U R                  U R                  5      $ r   )_use_unicoder   r   r   r   s    r   r   ABCPolyBase.__str__X  s9    (()?)?@@$$T%9%9::r    c                    [         R                  " 5       R                  SS5      nUS:  a  Sn[        R                  " U R
                  S   5      nU R                  5       u  pEU R                  [        R                  XE5      u  pgU(       a  SU-   S-   n[        U R
                  SS 5       H  u  pUS-  n[        US-   5      n
 U	S:  a  S	[        R                  " U	S
S9-   nOS[        R                  " U	* S
S9-   n X" X5      -  n[        UR                  S5      S   5      [        U5      -   nU[        U R
                  SS 5      S-
  :  a  US-  nX:  a  UR                  SSS5      nX;-  nM     U$ ! [         a    S	U	 3n Nf = f)zt
Generate the full string representation of the polynomial, using
``term_method`` to generate each polynomial term.
	linewidthK   r   r   r   )N z+ Tparensz- 
r   r~   )rd   get_printoptionsgetr   format_floatrc   mapparms_format_term	enumeratestrrw   rb   splitreplace)r   term_methodr   outrW   scalescaled_symbolneeds_parensirc   power	next_termline_lens                r   r   ABCPolyBase._generate_string]  s    '')--k2>	q=Ioodiil+]]_
&*&7&78;'D#-/#5M 12/GA3JCAJE
(19 $rtD'I II $ruT'J JI U::I399T?2./#i.@H 3tyy}%))A$%--c4;	C3 04 
  ( K	(s   E7$E77F	F	c                     U R                   c  [        S5      eSU R                    UR                  U R                  5       SU S3$ )zk
String representation of single polynomial term using unicode
characters for superscripts and subscripts.
zZSubclasses must define either a basis_name, or override _str_term_unicode(cls, i, arg_str)   ·r   r   )r*   NotImplementedError	translate_subscript_mappingclsr   arg_strs      r   r   ABCPolyBase._str_term_unicode  sU     >>!%5  S^^$Q[[1G1G%H$IG9A 	 r    c                 ^    U R                   c  [        S5      eSU R                    SU SU S3$ )zz
String representation of a single polynomial term using ** and _ to
represent superscripts and subscripts, respectively.
zXSubclasses must define either a basis_name, or override _str_term_ascii(cls, i, arg_str)r   _r   r   r*   r   r   s      r   r   ABCPolyBase._str_term_ascii  sB     >>!%3  3>>"!A3ay22r    c                 ^    U R                   c  [        S5      eSU R                    SU SU S3$ )NzbSubclasses must define either a basis name, or override _repr_latex_term(i, arg_str, needs_parens){z}_{z}(r   r   )r   r   r   r   s       r   _repr_latex_termABCPolyBase._repr_latex_term  s@    >>!%=> > CNN#53wiq99r    c                 H    SR                  [        R                  " XS95      $ )Nz\text{{{}}}r   )formatr   r   )rB   r   s     r   _repr_latex_scalarABCPolyBase._repr_latex_scalar  s     $$R__Q%FGGr    scalar_formatrW   r   c                 
   US:X  a  US:X  a  U R                   nSnXE4$ US:X  a  U" U5       SU R                    3nSnXE4$ US:X  a  U" U5       U R                    3nSnXE4$ U" U5       SU" U5       U R                    3nSnXE4$ )z&Format a single term in the expansion r   r   F + T)r   )r   r   rW   r   termr   s         r   r   ABCPolyBase._format_term  s    !8
;;D L !! aZ#C()T[[M:DL !! AX#E*+DKK=9DL !!	 !%&c '(7   L!!r    c                    U R                  5       u  pU R                  U R                  X5      u  p4SR                  n/ n[	        U R
                  5       H  u  pxUS:X  a  U R                  U5       n	Oc[        U[        R                  5      (       d  SU R                  U5       S3n	O.US:  a  SU R                  USS9 3n	OSU R                  U* SS9 3n	U R                  XsU5      n
U
S	:X  a  U	nOU	 S
U
 3nUS:X  a  U" U5      nUR                  U5        M     U(       a  SR                  U5      nOSnSU R                   SU S3$ )Nz\color{{LightGray}}{{{}}}r   z + (r   r   Tr   z - r   z\,r   r   $z	 \mapsto )r   r   r   r   r   rc   rr   numbersRealr   appendjoinr   )r   rW   r   r   r   mutepartsr   r<   coef_strterm_strpartbodys                r   _repr_latex_ABCPolyBase._repr_latex_  sZ   ]]_
!..t/F/F/2; ,22dii(DAAv"55a897<<00!$"9"9!"<!=Q?a !8!84!8!H IJ !8!8!D!8!I JK ,,QlCH3#*Bxj1AvDzLL+ ). 775>D DDKK=	$q11r    c                    U R                   R                  5       nU R                  R                  5       US'   U R                  R                  5       US'   U R                  R                  5       US'   U R
                  US'   U$ )Nrc   r#   r'   r   )__dict__copyrc   r#   r'   r   )r   rets     r   __getstate__ABCPolyBase.__getstate__  sf    mm  "iinn&F((*H((*HH
r    c                     Xl         g r   )r   )r   dicts     r   __setstate__ABCPolyBase.__setstate__  s    r    c                     [         R                  " XR                  U R                  5      nU R	                  XR
                  5      $ r   )r   	mapdomainr#   r'   rC   rc   )r   args     r   __call__ABCPolyBase.__call__  s-    ll3T[[9yyii((r    c                 ,    [        U R                  5      $ r   )iterrc   r   s    r   __iter__ABCPolyBase.__iter__  s    DIIr    c                 ,    [        U R                  5      $ r   )rb   rc   r   s    r   __len__ABCPolyBase.__len__  s    499~r    c                 |    U R                  U R                  * U R                  U R                  U R                  5      $ r   rs   rc   r#   r'   r   r   s    r   __neg__ABCPolyBase.__neg__  s.    ~~YYJT[[$++
 	
r    c                     U $ r   r"   r   s    r   __pos__ABCPolyBase.__pos__  s    r    c                     U R                  U5      n U R                  U R                  U5      nU R                  X0R                  U R                  U R                  5      $ ! [         a	    [        s $ f = fr   )	ry   r0   rc   	ExceptionNotImplementedrs   r#   r'   r   r   rg   	othercoefrc   s       r   __add__ABCPolyBase.__add__  c    **51		"99TYY	2D ~~dKKdkkJJ  	"!!	"   A   A32A3c                     U R                  U5      n U R                  U R                  U5      nU R                  X0R                  U R                  U R                  5      $ ! [         a	    [        s $ f = fr   )	ry   r3   rc   r   r   rs   r#   r'   r   r   s       r   __sub__ABCPolyBase.__sub__  r  r  c                     U R                  U5      n U R                  U R                  U5      nU R                  X0R                  U R                  U R                  5      $ ! [         a	    [        s $ f = fr   )	ry   r6   rc   r   r   rs   r#   r'   r   r   s       r   __mul__ABCPolyBase.__mul__%  r  r  c                     [        U[        R                  5      (       a  [        U[        5      (       a$  [	        S[        U 5       S[        U5       S35      eU R                  U5      $ )Nz&unsupported types for true division: 'z', '')rr   r   Numberboolrw   type__floordiv__rf   s     r   __truediv__ABCPolyBase.__truediv__-  s`     %00Jud4K4KJ<tDK=3    ''r    c                 D    U R                  U5      nU[        L a  U$ US   $ Nr   
__divmod__r   r   rg   ress      r   r  ABCPolyBase.__floordiv__8  &    ooe$. J1vr    c                 D    U R                  U5      nU[        L a  U$ US   $ Nr   r  r  s      r   __mod__ABCPolyBase.__mod__>  r  r    c                 l   U R                  U5      n U R                  U R                  U5      u  p4U R                  X0R                  U R                  U R                  5      nU R                  X@R                  U R                  U R                  5      nX44$ ! [         a    e [         a	    [
        s $ f = fr   )
ry   r9   rc   ZeroDivisionErrorr   r   rs   r#   r'   r   )r   rg   r   quorems        r   r  ABCPolyBase.__divmod__D  s    **51		"yyI6HC
 nnS++t{{DKKHnnS++t{{DKKHx ! 	 	"!!	"s   B B32B3c                     U R                  U R                  XR                  S9nU R                  X R                  U R
                  U R                  5      nU$ )N)r>   )r?   rc   r>   rs   r#   r'   r   )r   rg   rc   r  s       r   __pow__ABCPolyBase.__pow__P  s?    yyEMMyBnnT;;T[[I
r    c                      U R                  XR                  5      nU R	                  X R
                  U R                  U R                  5      $ ! [         a	    [        s $ f = fr   )r0   rc   r   r   rs   r#   r'   r   r   rg   rc   s      r   __radd__ABCPolyBase.__radd__U  Q    	"99UII.D ~~dKKdkkJJ  	"!!	"   A A! A!c                      U R                  XR                  5      nU R	                  X R
                  U R                  U R                  5      $ ! [         a	    [        s $ f = fr   )r3   rc   r   r   rs   r#   r'   r   r(  s      r   __rsub__ABCPolyBase.__rsub__\  r+  r,  c                      U R                  XR                  5      nU R	                  X R
                  U R                  U R                  5      $ ! [         a	    [        s $ f = fr   )r6   rc   r   r   rs   r#   r'   r   r(  s      r   __rmul__ABCPolyBase.__rmul__c  r+  r,  c                 $    U R                  U5      $ r   )__rfloordiv__rf   s     r   __rdiv__ABCPolyBase.__rdiv__j  s    !!%((r    c                     [         $ r   )r   rf   s     r   __rtruediv__ABCPolyBase.__rtruediv__n  s
     r    c                 D    U R                  U5      nU[        L a  U$ US   $ r  __rdivmod__r   r  s      r   r4  ABCPolyBase.__rfloordiv__s  (    u%. J1vr    c                 D    U R                  U5      nU[        L a  U$ US   $ r  r;  r  s      r   __rmod__ABCPolyBase.__rmod__y  r>  r    c                 H    U R                  XR                  5      u  p#U R                  X R                  U R                  U R                  5      nU R                  X0R                  U R                  U R                  5      nX#4$ ! [         a    e [         a	    [        s $ f = fr   )	r9   rc   r   r   r   rs   r#   r'   r   )r   rg   r!  r"  s       r   r<  ABCPolyBase.__rdivmod__  s    	"yy		2HC
 nnS++t{{DKKHnnS++t{{DKKHx ! 	 	"!!	"s   B B! B!c                    [        XR                  5      =(       a    [        R                  " U R                  UR                  :H  5      =(       a    [        R                  " U R
                  UR
                  :H  5      =(       a    U R                  R                  UR                  R                  :H  =(       aM    [        R                  " U R                  UR                  :H  5      =(       a    U R                  UR                  :H  nU$ r   )	rr   rs   rd   re   r#   r'   rc   shaper   r  s      r   __eq__ABCPolyBase.__eq__  s    %0 -vvdkkU\\12-vvdkkU\\12- 		5::#3#33- vvdii5::-.	-
 u||+ 	 
r    c                 .    U R                  U5      (       + $ r   )rF  rf   s     r   __ne__ABCPolyBase.__ne__  s    ;;u%%%r    c                 z    U R                  U R                  U R                  U R                  U R                  5      $ )zGReturn a copy.

Returns
-------
new_series : series
    Copy of self.

r   r   s    r   r   ABCPolyBase.copy  s)     ~~diidkk4;;OOr    c                     [        U 5      S-
  $ )u6  The degree of the series.

Returns
-------
degree : int
    Degree of the series, one less than the number of coefficients.

Examples
--------

Create a polynomial object for ``1 + 7*x + 4*x**2``:

>>> poly = np.polynomial.Polynomial([1, 7, 4])
>>> print(poly)
1.0 + 7.0·x + 4.0·x²
>>> poly.degree()
2

Note that this method does not check for non-zero coefficients.
You must trim the polynomial to remove any trailing zeroes:

>>> poly = np.polynomial.Polynomial([1, 7, 0])
>>> print(poly)
1.0 + 7.0·x + 0.0·x²
>>> poly.degree()
2
>>> poly.trim().degree()
1

r   )rb   r   s    r   degreeABCPolyBase.degree  s    > 4y1}r    c                 *    U R                  US-   5      $ )a9  Truncate series to the given degree.

Reduce the degree of the series to `deg` by discarding the
high order terms. If `deg` is greater than the current degree a
copy of the current series is returned. This can be useful in least
squares where the coefficients of the high degree terms may be very
small.

Parameters
----------
deg : non-negative int
    The series is reduced to degree `deg` by discarding the high
    order terms. The value of `deg` must be a non-negative integer.

Returns
-------
new_series : series
    New instance of series with reduced degree.

r   )truncate)r   rQ   s     r   cutdegABCPolyBase.cutdeg  s    * }}S1W%%r    c                     [         R                  " U R                  U5      nU R                  X R                  U R
                  U R                  5      $ )a'  Remove trailing coefficients

Remove trailing coefficients until a coefficient is reached whose
absolute value greater than `tol` or the beginning of the series is
reached. If all the coefficients would be removed the series is set
to ``[0]``. A new series instance is returned with the new
coefficients.  The current instance remains unchanged.

Parameters
----------
tol : non-negative number.
    All trailing coefficients less than `tol` will be removed.

Returns
-------
new_series : series
    New instance of series with trimmed coefficients.

)r   trimcoefrc   rs   r#   r'   r   )r   tolrc   s      r   r}   ABCPolyBase.trim  s7    ( {{499c*~~dKKdkkJJr    c                    [        U5      nX!:w  d  US:  a  [        S5      eU[        U R                  5      :  a  U R                  nOU R                  SU nU R	                  X0R
                  U R                  U R                  5      $ )a  Truncate series to length `size`.

Reduce the series to length `size` by discarding the high
degree terms. The value of `size` must be a positive integer. This
can be useful in least squares where the coefficients of the
high degree terms may be very small.

Parameters
----------
size : positive int
    The series is reduced to length `size` by discarding the high
    degree terms. The value of `size` must be a positive integer.

Returns
-------
new_series : series
    New instance of series with truncated coefficients.

r   zsize must be a positive integerN)intrx   rb   rc   rs   r#   r'   r   )r   sizeisizerc   s       r   rQ  ABCPolyBase.truncate  sl    ( D	=EAI>??C		N"99D99Ve$D~~dKKdkkJJr    c                     Uc  U R                   nUc  UR                  nUc  UR                  nU " UR                  XU R                  S95      $ )a1  Convert series to a different kind and/or domain and/or window.

Parameters
----------
domain : array_like, optional
    The domain of the converted series. If the value is None,
    the default domain of `kind` is used.
kind : class, optional
    The polynomial series type class to which the current instance
    should be converted. If kind is None, then the class of the
    current instance is used.
window : array_like, optional
    The window of the converted series. If the value is None,
    the default window of `kind` is used.

Returns
-------
new_series : series
    The returned class can be of different type than the current
    instance and/or have a different domain and/or different
    window.

Notes
-----
Conversion between domains and class types can result in
numerically ill defined series.

)r'   r   )rs   r#   r'   identityr   )r   r#   kindr'   s       r   convertABCPolyBase.convert  sJ    : <>>D>[[F>[[FDMM&MLMMr    c                 X    [         R                  " U R                  U R                  5      $ )a#  Return the mapping parameters.

The returned values define a linear map ``off + scl*x`` that is
applied to the input arguments before the series is evaluated. The
map depends on the ``domain`` and ``window``; if the current
``domain`` is equal to the ``window`` the resulting map is the
identity.  If the coefficients of the series instance are to be
used by themselves outside this class, then the linear function
must be substituted for the ``x`` in the standard representation of
the base polynomials.

Returns
-------
off, scl : float or complex
    The mapping function is defined by ``off + scl*x``.

Notes
-----
If the current domain is the interval ``[l1, r1]`` and the window
is ``[l2, r2]``, then the linear mapping function ``L`` is
defined by the equations::

    L(l1) = l2
    L(r1) = r2

)r   r   r#   r'   r   s    r   r   ABCPolyBase.mapparms6  s    6 {{4;;44r    r   c                     U R                  5       u  pEUc  SnOXEU-  -   nU R                  U R                  XUSU-  5      nU R                  X`R                  U R
                  U R                  5      $ )ay  Integrate.

Return a series instance that is the definite integral of the
current series.

Parameters
----------
m : non-negative int
    The number of integrations to perform.
k : array_like
    Integration constants. The first constant is applied to the
    first integration, the second to the second, and so on. The
    list of values must less than or equal to `m` in length and any
    missing values are set to zero.
lbnd : Scalar
    The lower bound of the definite integral.

Returns
-------
new_series : series
    A new series representing the integral. The domain is the same
    as the domain of the integrated series.

r   g      ?)r   rJ   rc   rs   r#   r'   r   )r   rF   rG   rH   rW   rI   rc   s          r   integABCPolyBase.integS  sa    2 ==?<DT>DyyA$37~~dKKdkkJJr    c                     U R                  5       u  p#U R                  U R                  X5      nU R                  X@R                  U R
                  U R                  5      $ )aG  Differentiate.

Return a series instance of that is the derivative of the current
series.

Parameters
----------
m : non-negative int
    Find the derivative of order `m`.

Returns
-------
new_series : series
    A new series representing the derivative. The domain is the same
    as the domain of the differentiated series.

)r   rM   rc   rs   r#   r'   r   )r   rF   rW   rI   rc   s        r   derivABCPolyBase.derivt  sD    $ ==?yyA+~~dKKdkkJJr    c                     U R                  U R                  5      n[        R                  " XR                  U R
                  5      $ )zReturn the roots of the series polynomial.

Compute the roots for the series. Note that the accuracy of the
roots decreases the further outside the `domain` they lie.

Returns
-------
roots : ndarray
    Array containing the roots of the series.

)r[   rc   r   r   r'   r#   )r   rootss     r   rk  ABCPolyBase.roots  s/     DII&||E;;<<r    c                 r    Uc  U R                   n[        R                  " US   US   U5      nU " U5      nX44$ )a  Return x, y values at equally spaced points in domain.

Returns the x, y values at `n` linearly spaced points across the
domain.  Here y is the value of the polynomial at the points x. By
default the domain is the same as that of the series instance.
This method is intended mostly as a plotting aid.

Parameters
----------
n : int, optional
    Number of point pairs to return. The default value is 100.
domain : {None, array_like}, optional
    If not None, the specified domain is used instead of that of
    the calling instance. It should be of the form ``[beg,end]``.
    The default is None which case the class domain is used.

Returns
-------
x, y : ndarray
    x is equal to linspace(self.domain[0], self.domain[1], n) and
    y is the series evaluated at element of x.

r   r   )r#   rd   linspace)r   nr#   rB   rP   s        r   rn  ABCPolyBase.linspace  s<    0 >[[FKKq	6!9a0Gtr    c
           	         Uc=  [         R                  " U5      nUS   US   :X  a  US==   S-  ss'   US==   S-  ss'   O-[        U5      [        L a  [	        U5      S:X  a  U R
                  nUc  U R                  n[         R                  " XU5      n
U R                  XX7XVS9nU(       a  Uu  pU " XXS9U4$ UnU " XXS9$ )a  Least squares fit to data.

Return a series instance that is the least squares fit to the data
`y` sampled at `x`. The domain of the returned instance can be
specified and this will often result in a superior fit with less
chance of ill conditioning.

Parameters
----------
x : array_like, shape (M,)
    x-coordinates of the M sample points ``(x[i], y[i])``.
y : array_like, shape (M,)
    y-coordinates of the M sample points ``(x[i], y[i])``.
deg : int or 1-D array_like
    Degree(s) of the fitting polynomials. If `deg` is a single integer
    all terms up to and including the `deg`'th term are included in the
    fit. For NumPy versions >= 1.11.0 a list of integers specifying the
    degrees of the terms to include may be used instead.
domain : {None, [beg, end], []}, optional
    Domain to use for the returned series. If ``None``,
    then a minimal domain that covers the points `x` is chosen.  If
    ``[]`` the class domain is used. The default value was the
    class domain in NumPy 1.4 and ``None`` in later versions.
    The ``[]`` option was added in numpy 1.5.0.
rcond : float, optional
    Relative condition number of the fit. Singular values smaller
    than this relative to the largest singular value will be
    ignored. The default value is ``len(x)*eps``, where eps is the
    relative precision of the float type, about 2e-16 in most
    cases.
full : bool, optional
    Switch determining nature of return value. When it is False
    (the default) just the coefficients are returned, when True
    diagnostic information from the singular value decomposition is
    also returned.
w : array_like, shape (M,), optional
    Weights. If not None, the weight ``w[i]`` applies to the unsquared
    residual ``y[i] - y_hat[i]`` at ``x[i]``. Ideally the weights are
    chosen so that the errors of the products ``w[i]*y[i]`` all have
    the same variance.  When using inverse-variance weighting, use
    ``w[i] = 1/sigma(y[i])``.  The default value is None.
window : {[beg, end]}, optional
    Window to use for the returned series. The default
    value is the default class domain
symbol : str, optional
    Symbol representing the independent variable. Default is 'x'.

Returns
-------
new_series : series
    A series that represents the least squares fit to the data and
    has the domain and window specified in the call. If the
    coefficients for the unscaled and unshifted basis polynomials are
    of interest, do ``new_series.convert().coef``.

[resid, rank, sv, rcond] : list
    These values are only returned if ``full == True``

    - resid -- sum of squared residuals of the least squares fit
    - rank -- the numerical rank of the scaled Vandermonde matrix
    - sv -- singular values of the scaled Vandermonde matrix
    - rcond -- value of `rcond`.

    For more details, see `linalg.lstsq`.

r   r   )wrR   rS   r#   r'   r   )	r   	getdomainr  listrb   r#   r'   r   rT   )r   rB   rP   rQ   r#   rR   rS   rr  r'   r   xnewr  rc   statuss                 r   fitABCPolyBase.fit  s    J >\\!_FayF1I%q	Q	q	Q	&\T!c&kQ&6ZZF>ZZF||Av.hhthA NTDF  Dt6IIr    c                 l   [         R                  " U/SS9u  nUc  [         R                  " U5      nO-[        U5      [        L a  [        U5      S:X  a  U R                  nUc  U R                  n[        U5      n[         R                  " X#5      u  pgXgU-  -   nU R                  U5      Xu-  -  n	U " XX4S9$ )a  Return series instance that has the specified roots.

Returns a series representing the product
``(x - r[0])*(x - r[1])*...*(x - r[n-1])``, where ``r`` is a
list of roots.

Parameters
----------
roots : array_like
    List of roots.
domain : {[], None, array_like}, optional
    Domain for the resulting series. If None the domain is the
    interval from the smallest root to the largest. If [] the
    domain is the class domain. The default is [].
window : {None, array_like}, optional
    Window for the returned series. If None the class window is
    used. The default is None.
symbol : str, optional
    Symbol representing the independent variable. Default is 'x'.

Returns
-------
new_series : series
    Series with the specified roots.

Fr|   r   rs  )
r   r   rt  r  ru  rb   r#   r'   r   r_   )
r   rk  r#   r'   r   rQ   rW   rI   rnewrc   s
             r   	fromrootsABCPolyBase.fromroots  s    8 ,,wU3>\\%(F&\T!c&kQ&6ZZF>ZZF%j;;v.Y~~d#ch.4vEEr    c                     Uc  U R                   nUc  U R                  n[        R                  " X!5      u  pEU R	                  XE5      nU " XaX#5      $ )a  Identity function.

If ``p`` is the returned series, then ``p(x) == x`` for all
values of x.

Parameters
----------
domain : {None, array_like}, optional
    If given, the array must be of the form ``[beg, end]``, where
    ``beg`` and ``end`` are the endpoints of the domain. If None is
    given then the class domain is used. The default is None.
window : {None, array_like}, optional
    If given, the resulting array must be if the form
    ``[beg, end]``, where ``beg`` and ``end`` are the endpoints of
    the window. If None is given then the class window is used. The
    default is None.
symbol : str, optional
    Symbol representing the independent variable. Default is 'x'.

Returns
-------
new_series : series
     Series of representing the identity.

)r#   r'   r   r   rX   )r   r#   r'   r   rW   rI   rc   s          r   r^  ABCPolyBase.identity=  sK    6 >ZZF>ZZF;;v.yy"400r    c                     Uc  U R                   nUc  U R                  n[        U5      nXQ:w  d  US:  a  [        S5      eU " S/U-  S/-   X#U5      $ )a  Series basis polynomial of degree `deg`.

Returns the series representing the basis polynomial of degree `deg`.

Parameters
----------
deg : int
    Degree of the basis polynomial for the series. Must be >= 0.
domain : {None, array_like}, optional
    If given, the array must be of the form ``[beg, end]``, where
    ``beg`` and ``end`` are the endpoints of the domain. If None is
    given then the class domain is used. The default is None.
window : {None, array_like}, optional
    If given, the resulting array must be if the form
    ``[beg, end]``, where ``beg`` and ``end`` are the endpoints of
    the window. If None is given then the class window is used. The
    default is None.
symbol : str, optional
    Symbol representing the independent variable. Default is 'x'.

Returns
-------
new_series : series
    A series with the coefficient of the `deg` term set to one and
    all others zero.

r   z deg must be non-negative integerr   )r#   r'   rY  rx   )r   rQ   r#   r'   r   idegs         r   basisABCPolyBase.basis`  s[    : >ZZF>ZZF3x;$(?@@A3t8qc>66::r    c                 b    Uc  U R                   nUc  U R                  nUR                  X U5      $ )a  Convert series to series of this class.

The `series` is expected to be an instance of some polynomial
series of one of the types supported by by the numpy.polynomial
module, but could be some other class that supports the convert
method.

Parameters
----------
series : series
    The series instance to be converted.
domain : {None, array_like}, optional
    If given, the array must be of the form ``[beg, end]``, where
    ``beg`` and ``end`` are the endpoints of the domain. If None is
    given then the class domain is used. The default is None.
window : {None, array_like}, optional
    If given, the resulting array must be if the form
    ``[beg, end]``, where ``beg`` and ``end`` are the endpoints of
    the window. If None is given then the class window is used. The
    default is None.

Returns
-------
new_series : series
    A series of the same kind as the calling class and equal to
    `series` when evaluated.

See Also
--------
convert : similar instance method

)r#   r'   r`  )r   seriesr#   r'   s       r   castABCPolyBase.cast  s2    D >ZZF>ZZF~~f622r    )r   r   rc   r#   r'   r   )NNrB   )F)r   )NNN)r   )r	   N)NNFNNrB   )NN)`r   
__module____qualname____firstlineno____doc____hash____array_ufunc__r>   r   	maketrans_superscript_mappingr   osr   r   propertyr   abcabstractmethodr#   r'   r*   staticmethodr0   r3   r6   r9   r?   rC   rJ   rM   rT   rX   r[   r_   rh   rk   ro   rt   ry   r   r   r   r   r   classmethodr   r   r   r   r   floatr   r   r   r   r   r   r   r   r   r  r  r	  r  r  r  r  r%  r)  r.  r1  r5  r8  r4  r@  r<  rF  rI  r   rN  rR  r}   rQ  r`  r   re  rh  rk  rn  rx  r|  r^  r  r  __static_attributes__r"   r    r   r   r      s   /d H O H ==*  (   ww$&L                                              *3 3 1 "H<,=;
,\     
3 
3 : : H H
"( " "u "&&2X
)


KKK	(

KKK)
	&	PB&.K.K:#NJ5: 2D KBK,=< CGXJ XJt %'S (F (FT  1  1D $; $;L %3 %3r    )r  r  r  r   typingr   numpyrd   r   r   r   __all__ABCr   r"   r    r   <module>r     s7    
 
    /Z3#'' Z3r    