1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
U
P±d5ã@sØdZddlZddlZddlZddlmZddlm    Z    eƒZ
ej   d¡rRe
  d¡Zn ej   d¡rje
  d¡Znedƒ‚e
 d¡e    ƒZejZejZejZd    d
„Zejed d Zee
 d e¡ƒZedeƒZeedd…ƒdS)a!
Building the required library in this example requires a source distribution
of NumPy or clone of the NumPy git repository since distributions.c is not
included in binary distributions.
 
On *nix, execute in numpy/random/src/distributions
 
export ${PYTHON_VERSION}=3.8 # Python version
export PYTHON_INCLUDE=#path to Python's include folder, usually \
    ${PYTHON_HOME}/include/python${PYTHON_VERSION}m
export NUMPY_INCLUDE=#path to numpy's include folder, usually \
    ${PYTHON_HOME}/lib/python${PYTHON_VERSION}/site-packages/numpy/core/include
gcc -shared -o libdistributions.so -fPIC distributions.c \
    -I${NUMPY_INCLUDE} -I${PYTHON_INCLUDE}
mv libdistributions.so ../../_examples/numba/
 
On Windows
 
rem PYTHON_HOME and PYTHON_VERSION are setup dependent, this is an example
set PYTHON_HOME=c:\Anaconda
set PYTHON_VERSION=38
cl.exe /LD .\distributions.c -DDLL_EXPORT \
    -I%PYTHON_HOME%\lib\site-packages\numpy\core\include \
    -I%PYTHON_HOME%\include %PYTHON_HOME%\libs\python%PYTHON_VERSION%.lib
move distributions.dll ../../_examples/numba/
éN)ÚFFI)ÚPCG64z./distributions.dllz./libdistributions.soz#Required DLL/so file was not found.z4
double random_standard_normal(void *bitgen_state);
cCs(t |¡}t|ƒD]}t|ƒ||<q|S)N)ÚnpÚemptyÚrangeÚrandom_standard_normal)ÚnÚ bit_generatorÚoutÚi©r úkd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\numpy/random/_examples/numba/extending_distributions.pyÚnormals5s
 rT)ZnopythonZ    uintptr_tièé )Ú__doc__ÚosZnumbaÚnbÚnumpyrZcffirZ numpy.randomrÚffiÚpathÚexistsZdlopenÚlibÚ RuntimeErrorZcdefÚxZxffir    rrZjitZnormalsjÚintÚcastZbit_generator_addressZnormÚprintr r r r Ú<module>s*