http://www.swig.org/) as an interface for many years and like its portability but I wondered about how to access a shared library from Python directly so did a bit of investigation and found the ctypes API to be very light weight and very easy to use.
To run SigLib (or any other shared library) from Python is very easy using ctypes.
For SigLib, copy the following code into a file "pythonSigLib.py" :
import numpy as np
import platform as _platform
A = np.array([3.4, 1.8, -2.8, 6.4])
B = np.zeros((A.size), dtype=np.double)
if _platform.system() == "Linux":
lib = ctypes.cdll.LoadLibrary('./siglib.so')
elif _platform.system() == "Darwin":
lib = ctypes.cdll.LoadLibrary('./siglib.dylib')
elif _platform.system() == "Windows":
lib = ctypes.cdll.LoadLibrary('.\siglib64.dll')
lib = ctypes.cdll.LoadLibrary('.\siglib.dll')
SDA_AbsMax = lib.SDA_AbsMax
SDA_AbsMax.restype = ctypes.c_double
absMax = SDA_AbsMax(ctypes.c_void_p(A.ctypes.data), ctypes.c_int(A.size))
SDA_SortMinToMax = lib.SDA_SortMinToMax
SDA_SortMinToMax(ctypes.c_void_p(A.ctypes.data), ctypes.c_void_p(B.ctypes.data), ctypes.c_int(A.size))
print ('absMax: ', absMax)
print ('B: %s' % B)
Now copy the SigLib shared object (.so, .dll or .dylib) file from /siglib/lib to the current working directory and run :
For further information about using SigLib, Python and SWIG, please see this blog post :
To download the evaluation version of the Numerix-DSP Libraries : http://www.numerix-dsp.com/eval/.