
    [h)                         S r SSKJrJr  SSKJr  SSKJr   " S S\5      r	SS	/S
SS
S
/ S
4S jr
S r/ SQrS rSS	/SS	/SS
SS
S
S
4S jrSS	/SS	/SSSS
S
S
4S jr\
\	l
        \\	l        \\	l        \\	l        \\	l        g
)z 
Plotting (requires matplotlib)
    )
hsv_to_rgb
hls_to_rgb   )NoConvergence)xrangec                        \ rS rSr\\\\4rSr	g)VisualizationMethods	    N)
__name__
__module____qualname____firstlineno__
ValueErrorArithmeticErrorZeroDivisionErrorr   plot_ignore__static_attributes__r       L/var/www/auris/envauris/lib/python3.13/site-packages/mpmath/visualization.pyr	   r	   	   s    0A=QKr   r	      N   c	           	         U(       a  SnSn	U(       d%  SSK n
U
R                  5       n	U	R                  S5      n[        U[        [
        45      (       d  U/nUu  p/ SQn[        U5       GHW  u  pU R                  XX-
  [        U5      -  5      n/ n/ nSn[        [        U5      5       GHI  n US:w  a&  U H   nUUS-
     U::  d  M  UU   U:  d  M  [        e   U" UU   5      nU R                  U5      (       d  [        U5      S:  a  [        e[        US5      (       ay  UR                  (       ah  [        UR                   5      n[        UR                  5      nU(       d  S	nUR#                  U5        / nUR#                  [        UU   5      UU45        M  U(       a  SnUR#                  U5        / n[        US
5      (       a  UR                   nUR#                  [        UU   5      U45        GML     U(       a  UR#                  U5        U H  nU Vs/ s H  nUS   PM
     nnU Vs/ s H  nUS   PM
     nnU(       d  M6  X[        U5      -     n[        US   5      S:X  aA  U Vs/ s H  nUS   PM
     nnUR'                  UUSU-   SS9  UR'                  UUSU-   SS9  M  UR'                  UUUSS9  M     GMZ     UR)                  U Vs/ s H  n[        U5      PM     sn5        U(       a+  UR+                  U Vs/ s H  n[        U5      PM     sn5        UR-                  S5        UR/                  S5        UR1                  S	5        U	(       a(  U(       a  W
R3                  XVS9  gW
R5                  5         gg! U R$                   a    U(       a  UR#                  U5        / n GM
  f = fs  snf s  snf s  snf s  snf s  snf )a  
Shows a simple 2D plot of a function `f(x)` or list of functions
`[f_0(x), f_1(x), \ldots, f_n(x)]` over a given interval
specified by *xlim*. Some examples::

    plot(lambda x: exp(x)*li(x), [1, 4])
    plot([cos, sin], [-4, 4])
    plot([fresnels, fresnelc], [-4, 4])
    plot([sqrt, cbrt], [-4, 4])
    plot(lambda t: zeta(0.5+t*j), [-20, 20])
    plot([floor, ceil, abs, sign], [-5, 5])

Points where the function raises a numerical exception or
returns an infinite value are removed from the graph.
Singularities can also be excluded explicitly
as follows (useful for removing erroneous vertical lines)::

    plot(cot, ylim=[-5, 5])   # bad
    plot(cot, ylim=[-5, 5], singularities=[-pi, 0, pi])  # good

For parts where the function assumes complex values, the
real part is plotted with dashes and the imaginary part
is plotted with dots.

.. note :: This function requires matplotlib (pylab).
Nr   o   )brgmkFr   gu <7~imagTreal      z--)	linewidth:xzf(x)dpi)pylabfigureadd_subplot
isinstancetuplelist	enumeratearangefloatr   lenr   isnanabshasattrr!   r"   appendr   plotset_xlimset_ylim
set_xlabel
set_ylabelgridsavefigshow)ctxfxlimylimpointsfiler)   singularitiesaxesfigr*   ar   colorsnfuncr'   segmentssegment
in_complexisingvreimsycz_s                                 r   r8   r8      s>   8 
Cllns#a%''CDA&FQ<JJqac5=01
AA6 -QqS6T>addl",, !. 1J99Q<<3q6E>$$1f%%!&&qvvBqvvB%%)
 0"$NNE!A$KR#89!%*
 0"$q&))FFNNE!A$K#341  : OOG$G&'w!1wA'&'w!1wA'3v;'A71:!##*+7aQqT7+		!QQ!	4		!QA	3		!QQ	/  I  ` 	MMT*T58T*+.AuQx./OOCOOFIIdO
MM$M(JJL	 1 ?? OOG, ('
 ,
 +.sD   .NNCNANN7-N<-OOO*N43N4c                 8   U R                  U5      (       a  gU R                  U5      (       a  gSn[        U R                  U5      5      U R                  -   SU R                  -  -  nUS-   S-  nS[        SS[        U5      S-  -   -  5      -
  n[        X4S	5      $ )
N      ?r\   r\         ?r^   r^   (-DT!	@r$   r^   r\   r   333333?皙?)isinfr4   r2   argpir5   r   )r@   rX   rd   rI   r   s        r   default_color_functionre   o   s    
yy||
yy||	B	swwqz	SVV	##&&1A	
SCAeAs3q63;'((AaC  r   )
)              rh   rh   )gffffff)皙?g?r^   )g      )rh   r^   r\   )g)g?ra   ra   )rh   r[   )g?)r\   ?r`   )r^   )rj   r^   rh   )gffffff?)gffffff?ri   rh   )r\   rg   )       @rg   c                    U R                  U5      (       a  gU R                  U5      (       a  gSn[        U R                  U5      5      U-  n[	        [        US5      S5      n[        S[        [        5      5       H\  n[        U   S   U:  d  M  [        US-
     u  nu  pgn[        U   u  n	u  pnX5-
  X-
  -  nXjU-
  U-  -   X{U-
  U-  -   XU-
  U-  -   4s  $    g )Nr[   r]   r_   r\   rf   r   r   )	rb   r4   r2   rc   maxminranger3   blue_orange_colors)r@   rX   rd   wrP   rI   ragabar   rbgbbbrU   s                 r   phase_color_functionrx      s    
yy||
yy||	BcggajBAC3KA1S+,-a #a'015OA|03OA|A"uai<UAIrb5!)|;; .r   i  Fc
                    Ub  US:X  a  U R                   nUS:X  a  U R                  nSSKn
U(       a  Sn	SnU	(       d!  U
R                  5       nUR	                  S5      n	Uu  pUu  pX-
  nX-
  n[        U R                  UU-  U-  5      S-   5      n[        U R                  UU-  U-  5      S-   5      nU
R                  XU5      nU
R                  XU5      nU
R                  UUS45      n[        U5       Ho  n[        U5       H1  nU R                  UU   UU   5      n U" U" U5      5      nUUUU4'   M3     U(       d  ML  [        [        U5      S	-   [        U5      -   5        Mq     XX4 Vs/ s H  n[        U5      PM     snu  ppU	R                  UXX4S
S9  U	R!                  S5        U	R#                  S5        U(       a(  U(       a  U
R%                  XxS9  gU
R'                  5         gg! U R                   a    Sn Nf = fs  snf )ak  
Plots the given complex-valued function *f* over a rectangular part
of the complex plane specified by the pairs of intervals *re* and *im*.
For example::

    cplot(lambda z: z, [-2, 2], [-10, 10])
    cplot(exp)
    cplot(zeta, [0, 1], [0, 50])

By default, the complex argument (phase) is shown as color (hue) and
the magnitude is show as brightness. You can also supply a
custom color function (*color*). This function should take a
complex number as input and return an RGB 3-tuple containing
floats in the range 0.0-1.0.

Alternatively, you can select a builtin color function by passing
a string as *color*:

  * "default" - default color scheme
  * "phase" - a color scheme that only renders the phase of the function,
     with white for positive reals, black for negative reals, gold in the
     upper half plane, and blue in the lower half plane.

To obtain a sharp image, the number of points may need to be
increased to 100,000 or thereabout. Since evaluating the
function that many times is likely to be slow, the 'verbose'
option is useful to display progress.

.. note :: This function requires matplotlib (pylab).
Ndefaultphaser   r   r   r#   r]   z of lower)extentoriginzRe(z)zIm(z)r(   )re   rx   r*   r+   r,   intsqrtlinspacezerosr   mpcr   printstrr2   imshowr;   r<   r>   r?   )r@   rA   rS   rT   rD   colorverboserE   r)   rG   r*   rH   rearebimaimbdredimMNr'   rV   rq   rK   r   rX   rR   rY   s                               r   cplotr      s   @ }***((
Cllns#HCHC
)C
)CCHHVCZ^$Q&'ACHHVCZ^$Q&'As#As#A
 	Q1IAAYA!ad#A$!A$K AacF  7#a&6/CF*+  .1s,@A,@q%(,@ACcKK3S.wK?OOGOOG
MM$M(JJL	  ?? $#$
 Bs   "G11H	1HHd   Tc
           	      ^   SSK n
SSKJn  U(       a  Sn	SnU	(       d+  U
R                  5       nUR                  R                  U5      n	Uu  pUu  nnX-
  nUU-
  n[        U[        [        45      (       d  XD/nUu  nnU
R                  XU5      nU
R                  UUU5      n[        S5       Vs/ s H  nU
R                  UU45      PM     snu  nnn[        S5       Vs/ s H  nSS/PM	     snu  nnn[        U5       H  n[        U5       H  nU" U R                  UU   5      U R                  UU   5      5      n Uu  UUU4'   UUU4'   UUU4'   UUU4   U4UUU4   U4UUU4   U44 H$  u  nn UU S   :  a  UU S'   UU S   :  d  M  UU S'   M&     M     M     U(       a  U	R                  UUUSSS9  OU	R                  UUUSSS9  U	R!                  S5        U	R#                  S5        U	R%                  S	5        U(       a  UUU4 V s/ s H  n U S   U S   -
  PM     sn u  n!n"n#['        U!U"U#5      n$U!U$:  a)  U$U!-
  n%U	R)                  US   U%S
-  -
  US   U%S
-  -   5        U"U$:  a)  U$U"-
  n%U	R+                  US   U%S
-  -
  US   U%S
-  -   5        U#U$:  a)  U$U#-
  n%U	R-                  US   U%S
-  -
  US   U%S
-  -   5        U(       a(  U(       a  U
R/                  XxS9  gU
R1                  5         ggs  snf s  snf ! [         a     UU   UU   UsUUU4'   UUU4'   UUU4'    GNf = fs  sn f )a  
Plots the surface defined by `f`.

If `f` returns a single component, then this plots the surface
defined by `z = f(x,y)` over the rectangular domain with
`x = u` and `y = v`.

If `f` returns three components, then this plots the parametric
surface `x, y, z = f(u,v)` over the pairs of intervals `u` and `v`.

For example, to plot a simple function::

    >>> from mpmath import *
    >>> f = lambda x, y: sin(x+y)*cos(y)
    >>> splot(f, [-pi,pi], [-pi,pi])    # doctest: +SKIP

Plotting a donut::

    >>> r, R = 1, 2.5
    >>> f = lambda u, v: [r*cos(u), (R+r*sin(u))*cos(v), (R+r*sin(u))*sin(v)]
    >>> splot(f, [0, 2*pi], [0, 2*pi])    # doctest: +SKIP

.. note :: This function requires matplotlib (pylab) 0.98.5.3 or higher.
r   Nr#   r      )rstridecstrider'   rV   rX   rk   r(   )r*   mpl_toolkits.mplot3dmplot3dr+   axes3dAxes3Dr-   r/   r.   r   r   r   convert	TypeErrorplot_wireframeplot_surfacer;   r<   
set_zlabelrm   
set_xlim3d
set_ylim3d
set_zlim3dr>   r?   )&r@   rA   urR   rD   keep_aspect	wireframerE   r)   rG   r*   r   rH   uaubvavbdudvr   r   rP   r'   rV   rX   xabyabzabrK   r   fdatarW   cabdxdydzmaxddeltas&                                         r   splotr      si   4 *
Clln~~$$S)FBFB	B	bBftUm,,!DAqrq!Ar2q!A,21I6Iqu{{Aq6"I6GAq!%+AY/YaVY/MCcAYAckk!A$'QqT):;E;).&!A#!A#!A# acFC=1QqS63-!AaC&#G3s1v:CFs1v:CF	 H   Aq!Q:!Q1a8OOCOOCOOC25sCA#c!fs1voA
B2r292IEOOCFUS[0#a&53;2FG92IEOOCFUS[0#a&53;2FG92IEOOCFUS[0#a&53;2FG
MM$M(JJL	 C 7/  ;)*1qtU&!A#!A#!A#; Bs$   /K3 K8?K=L*=&L'&L')__doc__colorsysr   r   libmpr   libmp.backendr   objectr	   r8   re   rp   rx   r   r   r   r   r   <module>r      s    ,   !R6 R !f4$D4aF	! < VAt4$TJX Fr!fSd$TPf !  .D  +,@  )"  "  r   