This project demonstrates wrapping C/C++ functions in Cython. It also shows how to pass numpy arrays to C/C++ arrays and vice versa.
There are potential execution speed advantages to this mixed language approach.
The sample source code uses this approach to calculate a Fourier transform from a time history signal.
The scripts on this page require the utility module tompy.py
The C/C++ source code and its header file are: fourier_ccode.cpp & fourier_ccode.h
The Cython file and its setup script are: fourier_trans.pyx & ft_setup.py
The Cython & C/C++ files are compiled in command-line via: python ft_setup.py build_ext –inplace
The main Python file is: fourier_c.py
This project was developed using the reference material at: Wrapping Cython
Tom Irvine
[…] Cython: Fourier transform […]
LikeLike