
    [hq>                        S SK JrJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ r    " S S\!5      r" " S S\"\\\
\\\\\\\\\\5      r#g)    )gtlt   )xrange)SpecialFunctions)RSCache)QuadratureMethods) LaplaceTransformInversionMethods)CalculusMethods)OptimizationMethods)
ODEMethods)MatrixMethods)MatrixCalculusMethods)LinearAlgebraMethods)Eigen)IdentificationMethods)VisualizationMethods)libmpc                       \ rS rSrSrg)Context    N)__name__
__module____qualname____firstlineno____static_attributes__r       G/var/www/auris/envauris/lib/python3.13/site-packages/mpmath/ctx_base.pyr   r      s    r   r   c                   Z   \ rS rSr\R
                  r\R                  rS rS rSr	Sr
S rS rS rS rS	 rS
 rS rS rS rS rS"S jrS#S jrS rS$S jrS%S jrS&S jrS rS rS rS rS r\ " \RB                  5      r"\ " \RF                  5      r#\ " \RH                  5      r$\ " \RJ                  5      r%\ " \RL                  5      r&\ " \RN                  5      r(\ " \RR                  5      r*\ " \RV                  5      r,\ " \RZ                  5      r.S'S jr/S'S jr0S r1S r2S r3S  r4S!r5g)(StandardBaseContext   c                    0 U l         [        R                  " U 5        [        R                  " U 5        [        R                  " U 5        [
        R                  " U 5        [        R                  " U 5        [        R                  " U 5        g N)_aliasesr   __init__r   r	   r
   r   r   )ctxs    r   r&   StandardBaseContext.__init__*   s]    !!#&""3'(11#6  %s#r   c           	          U R                   R                  5        H  u  p [        X[        X5      5        M     g ! [         a     M-  f = fr$   )r%   itemssetattrgetattrAttributeError)r'   aliasvalues      r   _init_aliases!StandardBaseContext._init_aliases4   sC    LL..0LEGC$78 1 " s   ;
A	A	Fc                     [        SU5        g )NzWarning:)printr'   msgs     r   warnStandardBaseContext.warn@   s    j#r   c                     [        U5      er$   )
ValueErrorr4   s     r   
bad_domainStandardBaseContext.bad_domainC   s    or   c                 @    [        US5      (       a  UR                  $ U$ )Nreal)hasattrr=   r'   xs     r   _reStandardBaseContext._reF   s    1f66Mr   c                 T    [        US5      (       a  UR                  $ U R                  $ )Nimag)r>   rD   zeror?   s     r   _imStandardBaseContext._imK   s!    1f66Mxxr   c                     U$ r$   r   r?   s     r   
_as_pointsStandardBaseContext._as_pointsP   s    r   c                 &    U R                  U5      * $ r$   convert)r'   r@   kwargss      r   fnegStandardBaseContext.fnegS   s    Ar   c                 H    U R                  U5      U R                  U5      -   $ r$   rL   r'   r@   yrN   s       r   faddStandardBaseContext.faddV       {{1~ckk!n,,r   c                 H    U R                  U5      U R                  U5      -
  $ r$   rL   rR   s       r   fsubStandardBaseContext.fsubY   rV   r   c                 H    U R                  U5      U R                  U5      -  $ r$   rL   rR   s       r   fmulStandardBaseContext.fmul\   rV   r   c                 H    U R                  U5      U R                  U5      -  $ r$   rL   rR   s       r   fdivStandardBaseContext.fdiv_   rV   r   c                    U(       aA  U(       a  [        S U 5       U R                  5      $ [        S U 5       U R                  5      $ U(       a  [        S U 5       U R                  5      $ [        XR                  5      $ )Nc              3   >   #    U  H  n[        U5      S -  v   M     g7f   Nabs.0r@   s     r   	<genexpr>+StandardBaseContext.fsum.<locals>.<genexpr>e   s     4t!CFAIts   c              3   8   #    U  H  n[        U5      v   M     g 7fr$   rd   rf   s     r   rh   ri   f   s     -1As   c              3   *   #    U  H	  oS -  v   M     g7frb   r   rf   s     r   rh   ri   h   s     +d1ds   )sumrE   )r'   argsabsolutesquareds       r   fsumStandardBaseContext.fsumb   s_    4t4chh??--sxx88+d+SXX664""r   Nc                    ^ Ub  [        X5      nU(       a,  U R                  m[        U4S jU 5       U R                  5      $ [        S U 5       U R                  5      $ )Nc              3   >   >#    U  H  u  pUT" U5      -  v   M     g 7fr$   r   )rg   r@   rS   cfs      r   rh   +StandardBaseContext.fdot.<locals>.<genexpr>p   s     0REQ"Q%Rs   c              3   .   #    U  H  u  pX-  v   M     g 7fr$   r   )rg   r@   rS   s      r   rh   ru   r   s     ,s   )zipconjrl   rE   )r'   xsys	conjugatert   s       @r   fdotStandardBaseContext.fdotk   sK    >RBB0R0#((;;,,chh77r   c                 8    U R                   nU H  nX#-  nM	     U$ r$   )one)r'   rm   prodargs       r   fprodStandardBaseContext.fprodt   s!    wwCKD r   c                 <    [        U R                  " X40 UD65        g)z&
Equivalent to ``print(nstr(x, n))``.
N)r3   nstr)r'   r@   nrN   s       r   nprintStandardBaseContext.nprintz   s     	chhq&v&'r   c                   ^ ^ Tc  ST R                   -  m T R                  U5      n[        U5      n[        U5      T:  a  T R                  $ T R	                  U5      (       ai  [        TUT-  5      n[        UR                  5      U:  a  UR                  $ [        UR                  5      U:  a  T R                  SUR                  5      $ U$ ! [         as    [        UT R                  5      (       a  UR                  U U4S j5      s $ [        US5      (       a+  U Vs/ s H  nT R                  UT5      PM     Os  snf sns $  U$ f = f)a~  
Chops off small real or imaginary parts, or converts
numbers close to zero to exact zeros. The input can be a
single number or an iterable::

    >>> from mpmath import *
    >>> mp.dps = 15; mp.pretty = False
    >>> chop(5+1e-10j, tol=1e-9)
    mpf('5.0')
    >>> nprint(chop([1.0, 1e-20, 3+1e-18j, -4, 2]))
    [1.0, 0.0, 3.0, -4.0, 2.0]

The tolerance defaults to ``100*eps``.
d   r   c                 (   > TR                  U T5      $ r$   )chop)ar'   tols    r   <lambda>*StandardBaseContext.chop.<locals>.<lambda>   s    !S)9r   __iter__)epsrM   re   rE   _is_complex_typemaxrD   r=   mpc	TypeError
isinstancematrixapplyr>   r   )r'   r@   r   absxpart_tolr   s   ` `   r   r   StandardBaseContext.chop   s    ;cgg+C	5AAq6D1v|xx##A&&sDH-qvv;)66Mqvv;)771aff--   	5!SZZ((ww9::q*%%234!QC(!44 &	5s0   6C A	C 4C ;EE D=<	E
Ec                    U R                  U5      nUc$  Uc!  U R                  SU R                  * S-   5      =p4Uc  UnOUc  Un[        X-
  5      nXT::  a  g[        U5      n[        U5      nXg:  a  XW-  nX:*  $ XV-  nX:*  $ )a  
Determine whether the difference between `s` and `t` is smaller
than a given epsilon, either relatively or absolutely.

Both a maximum relative difference and a maximum difference
('epsilons') may be specified. The absolute difference is
defined as `|s-t|` and the relative difference is defined
as `|s-t|/\max(|s|, |t|)`.

If only one epsilon is given, both are set to the same value.
If none is given, both epsilons are set to `2^{-p+m}` where
`p` is the current working precision and `m` is a small
integer. The default setting typically allows :func:`~mpmath.almosteq`
to be used to check for mathematical equality
in the presence of small rounding errors.

**Examples**

    >>> from mpmath import *
    >>> mp.dps = 15
    >>> almosteq(3.141592653589793, 3.141592653589790)
    True
    >>> almosteq(3.141592653589793, 3.141592653589700)
    False
    >>> almosteq(3.141592653589793, 3.141592653589700, 1e-10)
    True
    >>> almosteq(1e-20, 2e-20)
    True
    >>> almosteq(1e-20, 2e-20, rel_eps=0, abs_eps=0)
    False

r      T)rM   ldexpprecre   )	r'   strel_epsabs_epsdiffabssabsterrs	            r   almosteqStandardBaseContext.almosteq   s    B KKN?w #		!chhYq[ 99G?G_G13x?1v1v;)C ~ )C~r   c                 Z   [        U5      S::  d  [        S[        U5      -  5      e[        U5      S:  d  [        S[        U5      -  5      eSnSn[        U5      S:X  a  US   nO[        U5      S:  a
  US   nUS   n[        U5      S:X  a  US   nU R                  U5      U R                  W5      U R                  U5      p4nX#-   U:w  d   S5       eX$:  a  US:  a  / $ [        nOUS:  a  / $ [        n/ nSnUn X#U-  -   nUS-  nU" X5      (       a  UR                  U5        O U$ M0  )a  
This is a generalized version of Python's :func:`~mpmath.range` function
that accepts fractional endpoints and step sizes and
returns a list of ``mpf`` instances. Like :func:`~mpmath.range`,
:func:`~mpmath.arange` can be called with 1, 2 or 3 arguments:

``arange(b)``
    `[0, 1, 2, \ldots, x]`
``arange(a, b)``
    `[a, a+1, a+2, \ldots, x]`
``arange(a, b, h)``
    `[a, a+h, a+h, \ldots, x]`

where `b-1 \le x < b` (in the third case, `b-h \le x < b`).

Like Python's :func:`~mpmath.range`, the endpoint is not included. To
produce ranges where the endpoint is included, :func:`~mpmath.linspace`
is more convenient.

**Examples**

    >>> from mpmath import *
    >>> mp.dps = 15; mp.pretty = False
    >>> arange(4)
    [mpf('0.0'), mpf('1.0'), mpf('2.0'), mpf('3.0')]
    >>> arange(1, 2, 0.25)
    [mpf('1.0'), mpf('1.25'), mpf('1.5'), mpf('1.75')]
    >>> arange(1, -1, -0.75)
    [mpf('1.0'), mpf('0.25'), mpf('-0.5')]

   z+arange expected at most 3 arguments, got %ir   z+arange expected at least 1 argument, got %ir   rc   z0dt is too small and would cause an infinite loop)lenr   mpfr   r   append)	r'   rm   r   dtbopresultir   s	            r   arangeStandardBaseContext.arange   sJ   @ 4yA~I!$i( ) )4yA~I!$i( ) ) t9>QAY!^QAQAt9>aB771:swwqz3772;bv{NNN{5Av	BAv	BqDAFA!xxa  r   c                    [        U5      S:X  a7  U R                  US   5      nU R                  US   5      n[        US   5      nOi[        U5      S:X  aC  [        US   S5      (       d   eUS   R                  nUS   R
                  n[        US   5      nO[        S[        U5      -  5      eUS:  a  [        S5      eSU;  d
  US   (       aW  US:X  a  U R                  U5      /$ XC-
  U R                  US-
  5      -  n[        U5       Vs/ s H
  owU-  U-   PM     nnXHS	'   U$ XC-
  U R                  U5      -  n[        U5       Vs/ s H
  owU-  U-   PM     nnU$ s  snf s  snf )
aT  
``linspace(a, b, n)`` returns a list of `n` evenly spaced
samples from `a` to `b`. The syntax ``linspace(mpi(a,b), n)``
is also valid.

This function is often more convenient than :func:`~mpmath.arange`
for partitioning an interval into subintervals, since
the endpoint is included::

    >>> from mpmath import *
    >>> mp.dps = 15; mp.pretty = False
    >>> linspace(1, 4, 4)
    [mpf('1.0'), mpf('2.0'), mpf('3.0'), mpf('4.0')]

You may also provide the keyword argument ``endpoint=False``::

    >>> linspace(1, 4, 4, endpoint=False)
    [mpf('1.0'), mpf('1.75'), mpf('2.5'), mpf('3.25')]

r   r   r   rc   _mpi_z*linspace expected 2 or 3 arguments, got %izn must be greater than 0endpoint)	r   r   intr>   r   r   r   r9   r   )	r'   rm   rN   r   r   r   stepr   rS   s	            r   linspaceStandardBaseContext.linspace   se   * t9>Q AQ ADGAY!^47G,,,,Q		AQ		ADGAH!$i( ) )q5788V#vj'9Av
|#ESWWQU^+D%+AY/Y4!YA/bE  ESWWQZ'D%+AY/Y4!YA/ 0 0s   E E%c                 N    U R                   " U40 UD6U R                  " U40 UD64$ r$   )cossinr'   zrN   s      r   cos_sinStandardBaseContext.cos_sinN  s)    wwq#F#SWWQ%9&%999r   c                 N    U R                   " U40 UD6U R                  " U40 UD64$ r$   )cospisinpir   s      r   cospi_sinpiStandardBaseContext.cospi_sinpiQ  s)    yy%f%syy'=f'===r   c                 0    [        SUS-  -  SU-  -   5      $ )Ni  g      ?r   )r   )r'   ps     r   _default_hyper_maxprec*StandardBaseContext._default_hyper_maxprecT  s    4!T'>AaC'((r   c                    U R                   n Sn X4-   S-   U l         U R                  nU R                  nSnU" 5        H]  nXh-  nXr-  (       dH  U(       aA  U R                  U5      n	[	        XY5      nU R                  U5      n
X-
  U R                   :  a    O	US-  nM_     UW
-
  nX:w  a  O2X:  d  U R
                  (       a  OU[        U R                   U5      -  nM  UX0l         $ ! X0l         f = fN
   r      r   )r   ninfrE   magr   _fixed_precisionmin)r'   terms
check_stepr   	extraprecmax_magr   ktermterm_magsum_magcancellations               r   sum_accurately"StandardBaseContext.sum_accuratelya  s    xx	I+a/((HH!GDIAN#&774="%g"8"%''!*"-8!FA $  '0/+s/C/CS<88	' ( HtH   CC$ $C,c                    U R                   n Sn X4-   S-   U l         U R                  nU R                  nUnSnU" 5        H[  n	Xy-  nX-
  n
X-  (       dB  U R                  U
5      n[	        X[5      nU R                  Xv-
  5      nU* U R                   :  a    O	US-  nM]     UW-
  nX:w  a  O2X:  d  U R
                  (       a  OU[        U R                   U5      -  nM  UX0l         $ ! X0l         f = fr   )r   r   r   r   r   r   r   )r'   factorsr   r   r   r   r   r   r   factorr   r   r   r   s                 r   mul_accurately"StandardBaseContext.mul_accurately}  s    xx	I+a/((gg%iFKA!<DN#&774="%g"8"%''!%. %9sxx/!FA (  '0/+s/C/CS<88	/ 0 HtHr   c                 H    U R                  U5      U R                  U5      -  $ )a  Converts `x` and `y` to mpmath numbers and evaluates
`x^y = \exp(y \log(x))`::

    >>> from mpmath import *
    >>> mp.dps = 30; mp.pretty = True
    >>> power(2, 0.5)
    1.41421356237309504880168872421

This shows the leading few digits of a large Mersenne prime
(performing the exact calculation ``2**43112609-1`` and
displaying the result in Python would be very slow)::

    >>> power(2, 43112609)-1
    3.16470269330255923143453723949e+12978188
rL   )r'   r@   rS   s      r   powerStandardBaseContext.power  s      {{1~Q//r   c                 $    U R                  U5      $ r$   )zeta)r'   r   s     r   	_zeta_intStandardBaseContext._zeta_int  s    xx{r   c                 &   ^ ^^^ S/mUUU U4S jnU$ )a  
Return a wrapped copy of *f* that raises ``NoConvergence`` when *f*
has been called more than *N* times::

    >>> from mpmath import *
    >>> mp.dps = 15
    >>> f = maxcalls(sin, 10)
    >>> print(sum(f(n) for n in range(10)))
    1.95520948210738
    >>> f(10) # doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
      ...
    NoConvergence: maxcalls: function evaluated 10 times

r   c                  h   > TS==   S-  ss'   TS   T:  a  TR                  ST-  5      eT" U 0 UD6$ )Nr   r   z%maxcalls: function evaluated %i times)NoConvergence)rm   rN   Ncounterr'   fs     r   f_maxcalls_wrapped8StandardBaseContext.maxcalls.<locals>.f_maxcalls_wrapped  sC    AJ!OJqzA~''(ORS(STTd%f%%r   r   )r'   r   r   r   r   s   ``` @r   maxcallsStandardBaseContext.maxcalls  s      #	& 	&
 "!r   c                 d   ^ ^^ 0 mU UU4S jnTR                   Ul         TR                  Ul        U$ )a  
Return a wrapped copy of *f* that caches computed values, i.e.
a memoized copy of *f*. Values are only reused if the cached precision
is equal to or higher than the working precision::

    >>> from mpmath import *
    >>> mp.dps = 15; mp.pretty = True
    >>> f = memoize(maxcalls(sin, 1))
    >>> f(2)
    0.909297426825682
    >>> f(2)
    0.909297426825682
    >>> mp.dps = 25
    >>> f(2) # doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
      ...
    NoConvergence: maxcalls: function evaluated 1 times

c                     > U(       a  U [        UR                  5       5      4nOU nTR                  nUT	;   a  T	U   u  pEXC:  a  U7$ T" U 0 UD6nX64T	U'   U$ r$   )tupler*   r   )
rm   rN   keyr   cpreccvaluer/   r'   r   f_caches
          r   f_cached-StandardBaseContext.memoize.<locals>.f_cached  sf    E&,,.1188Dg~ '="7Nt&v&E =GCLLr   )r   __doc__)r'   r   r   r   s   `` @r   memoizeStandardBaseContext.memoize  s.    ( 	 JJ99r   r   )FF)NF)   r$   )NN)r   )6r   r   r   r   r   r   ComplexResultr&   r0   r   verboser6   r:   rA   rF   rI   rO   rT   rX   r[   r^   rp   r|   r   r   r   r   r   r   r   r   r   staticmethodgcd_gcdlist_primesisprimebernfracmoebiusifac_ifaceulernum	_eulernum	stirling1
_stirling1	stirling2
_stirling2r   r   r   r   r   r  r   r   r   r   r!   r!      sB    ''M''M$  G

----#8("H1fGR,\:>) 		"Du001K5==)GENN+H5==)G$EU^^,Ieoo.Jeoo.J8@0$"0$r   r!   N)$operatorr   r   libmp.backendr   functions.functionsr   functions.rszetar   calculus.quadraturer	   calculus.inverselaplacer
   calculus.calculusr   calculus.optimizationr   calculus.odesr   matrices.matricesr   matrices.calculusr   matrices.linalgr   matrices.eigenr   identificationr   visualizationr    r   objectr   r!   r   r   r   <module>r(     sv     ! 1 % 2 E . 6 % , 4 1 ! 1 / 	f 	V'$	Vr   