CyMath provides Cython wrappers for libm
. The wrappers are:
- cdef functions to avoid Python overhead
- made generic by using fused types
- GIL-free to allow for easy parallelization.
CyMath requires that Cython is installed and that the C compiler being used supports C99.
To install CyMath:
- Clone the git repository.
- Run
pip install .
in the top-levelcymath
directory.
To run the tests after installing:
- run
setup.py build_ext -i
incymath/tests
- run
python -c "import tests; tests.run()"
.
A basic example of use is:
cimport cymath
cdef double x = 1.0
cdef double y
cdef double complex z = 1.0 + 1.0j
cdef double complex w
with nogil:
y = cymath.sin(x)
w = cymath.sin(z)
print("y, w = {}, {}".format(y, w))