
    shu                         S SK r S SKrS SKrS SKrS SKJr  S SKJrJr  S SK	J
r
JrJrJr  \" S5      r\" S5      rSS/rSS	 jrS
 r\" S5      S 5       rg)    N)import_module)skipskip_under_pyodide)compile_link_import_py_extcompile_link_import_stringscompile_sourcesget_abspathnumpycython)z	sigmoid.cz
#include <math.h>

void sigmoid(int n, const double * const restrict in,
             double * const restrict out, double lim){
    for (int i=0; i<n; ++i){
        const double x = in[i];
        out[i] = x*pow(pow(x/lim, 8)+1, -1./8.);
    }
}
)z_sigmoid.pyxaw  
import numpy as np
cimport numpy as cnp

cdef extern void c_sigmoid "sigmoid" (int, const double * const,
                                      double * const, double)

def sigmoid(double [:] inp, double lim=350.0):
    cdef cnp.ndarray[cnp.float64_t, ndim=1] out = np.empty(
        inp.size, dtype=np.float64)
    c_sigmoid(inp.size, &inp[0], &out[0], lim)
    return out
c                 "    X U-  S-  S-   S-  -  $ )N      g      ? )datalims     ڇ/Users/tiagomarins/Projetos/claudeai/copy_bank/venv/lib/python3.13/site-packages/sympy/utilities/_compilation/tests/test_compilation.pynpyr   )   s    s(QqD)))    c                  V   [         (       d  [        S5        [        (       d  [        S5        SSKJn   U " 5       (       d  [        S5        S[         R                  5       /S.nS n [        [        US9u  p2[         R                  R                  S	5      nUR                  U5      n[        U5      n[         R                  XV5      (       d   e U(       a%  US
   (       a  [        R                  " US
   5        g g g ! U(       a%  US
   (       a  [        R                  " US
   5        f f f = f)Nznumpy not installed.zcython not installed.r   has_cNo C compiler found.c99)stdinclude_dirs)compile_kwargsi   	build_dir)r
   r   r   sympy.utilities._compilationr   get_includer   	_sources1randomsigmoidr   allcloseshutilrmtree)r   
compile_kwinfomodr   res_modres_npys          r    test_compile_link_import_stringsr+   -   s    5#$6$%277#$1B1B1D0EFJD-/	*U	||"";/++d#d)~~g////D%MM${+, &44D%MM${+, &4s   %A'C: :.D(z(Emscripten does not support subprocessesc                  V   [         R                  " 5       n SSKJn  U" 5       (       d  [	        S5        [        U 5      n[         R                  " SUS9u  p4[        US5       nUR                  S5        S S S 5        [        U/US9u  n[        XbS9n[        R                  R                  U5      (       d   e [        R                  " S	S
/5      n[        R                  " S	U/5      n	SU	R!                  S5      ;   d   e [$        (       d  g [         R                  " SUS9u  p:[        U
S5       nUR                  S5        S S S 5        ['        U
/U/US9nUR)                  S5      S:X  d   eg ! , (       d  f       GN= f! [        R"                   a     Nf = f! , (       d  f       N_= f)Nr   r   r   z.c)dirwtzH
        int foo(int bar) {
            return 2*bar;
        }
        )cwdnmz--helpfoozutf-8z.pyxz;cdef extern int foo(int)
def _foo(arg):
    return foo(arg))
extra_objsr      *   )tempfilemkdtempr   r   r   strmkstempopenwriter   r	   ospathexists
subprocesscheck_outputdecodeCalledProcessErrorr   r   _foo)tmpdirr   r   _handle	file_pathofhobjobj_path_nm_outpyx_pathr(   s               r   test_compile_sourcesrL   D   su   F277#$FI!))$I>G	i	#		  	 
 I;I6DC3.H77>>(####/##T8$45 (($)9:g....6 ((Y?G	h			 ) 	+ 
 %hZXJR[
\C88B<25 
	 ((  
	s*   !E.8F  /F.
E= FF
F()g     u@)r$   r;   r>   r5   sympy.externalr   sympy.testing.pytestr   r   (sympy.utilities._compilation.compilationr   r   r   r	   r
   r   r    r   r+   rL   r   r   r   <module>rP      sm     	   ( 9 K  Kg	x	 
	8*-. >?# @#r   