
    g                         ddZ d ZdS )printc                 n     sd ndk    rdgfdsd ndk    rdgfd fd}|S )az  
    Returns a wrapped copy of *f* that monitors evaluation by calling
    *input* with every input (*args*, *kwargs*) passed to *f* and
    *output* with every value returned from *f*. The default action
    (specify using the special string value ``'print'``) is to print
    inputs and outputs to stdout, along with the total evaluation
    count::

        >>> from mpmath import *
        >>> mp.dps = 5; mp.pretty = False
        >>> diff(monitor(exp), 1)   # diff will eval f(x-h) and f(x+h)
        in  0 (mpf('0.99999999906867742538452148'),) {}
        out 0 mpf('2.7182818259274480055282064')
        in  1 (mpf('1.0000000009313225746154785'),) {}
        out 1 mpf('2.7182818309906424675501024')
        mpf('2.7182808')

    To disable either the input or the output handler, you may
    pass *None* as argument.

    Custom input and output handlers may be used e.g. to store
    results for later analysis::

        >>> mp.dps = 15
        >>> input = []
        >>> output = []
        >>> findroot(monitor(sin, input.append, output.append), 3.0)
        mpf('3.1415926535897932')
        >>> len(input)  # Count number of evaluations
        9
        >>> print(input[3]); print(output[3])
        ((mpf('3.1415076583334066'),), {})
        8.49952562843408e-5
        >>> print(input[4]); print(output[4])
        ((mpf('3.1415928201669122'),), {})
        -1.66577118985331e-7

    c                     d S N vs    L/var/www/html/ai-engine/env/lib/python3.11/site-packages/mpmath/usertools.py<lambda>zmonitor.<locals>.<lambda>*   s    $     r       c                 n    | \  }}t          dd         d|d|           dxx         dz  cc<   d S )Nzin  r       r   )valueargskwargsincounts      r	   inputzmonitor.<locals>.input-   sJ     LD&EGAJJJff=>>>AJJJ!OJJJJJr   c                     d S r   r   r   s    r	   r
   zmonitor.<locals>.<lambda>2   s    4 r   c                 ^    t          dd         d|            dxx         dz  cc<   d S )Nzout r   r   r   r   )r   outcounts    r	   outputzmonitor.<locals>.output5   s<    E!ee4555QKKK1KKKKKr   c                  H     | |f            | i |} |           |S r   r   )r   r   r   fr   r   s      r	   f_monitoredzmonitor.<locals>.f_monitored8   s=    tVnAtvq			r   r   )r   r   r   r   r   r   s   ``` @@r	   monitorr      s    N  	'		#	 	 	 	 	  	7		3	 	 	 	 	      
 r   c                 P                         d          }dv rd= sr,t                    dk    rsd          fd}n
 fd}n }ddlm}  |            } |            } |            }||z
  }	|	dk    s|r|	S t	          d          D ]}
 |            } |              |              |              |              |              |              |              |              |              |              |            }t          |	||z
  d	z            }	|	S )
z
    Returns time elapsed for evaluating ``f()``. Optionally arguments
    may be passed to time the execution of ``f(*args, **kwargs)``.

    If the first call is very quick, ``f`` is called
    repeatedly and the best time is returned.
    oncer   r   c                                  S r   r   )argr   s   r	   r
   ztiming.<locals>.<lambda>M   s    # r   c                        i S r   r   )r   r   r   s   r	   r
   ztiming.<locals>.<lambda>O   s    4*6** r   )default_timerg?   
   )getlentimeitr#   rangemin)r   r   r   r   gclockt1r   t2tir!   s   ```        @r	   timingr1   ?   s{    ::fD6N v t99>>&>q'CAA******AA------uwwB!!##%%''rRU14xx4x1XX  577 	
AACCCAACCCAACCCAACCCAACCC577
aB


Hr   N)r   r   )r   r1   r   r   r	   <module>r2      s3   ; ; ; ;z    r   