Research visit at Harvard SEAS with Dr Ba
-
Use Makefile to generate
bandinverse.o
(object file corresponding to C version of Luca's code) -
The Python C extension will build a module
_bandinverse
that can be imported as one would any Python module
-
Compile the C extension as follows
python setup.py build_ext --inplace
, which will generate the module -
The
_bandinverse
module has one functionbandinv
that takes in arguments in the same format as Luca's C code. -
Test the function as follows
- Testing the code on a simple 3 by 3 matrix with bandwidth 2 (only one off diagonal):
import _bandinverse
U = np.array([0,1.0,0.7,1.0,0.7,1.0])
M, N = 2, 3
U.reshape(M,N,order='Fortran')
P = _bandinverse.bandinv(U,M,N)