Memory fix C code
Created by: dyang37
This PR completes the memory fix in C code, plus some memory-related improvements in Cython interface. It contains the following fixes:
- Installed new multialloc routine, and replaced all mem_alloc_2D and mem_alloc_3D functions with multialloc. This is to handle issue #10 (closed) .
- In C code, remove unnecessary copy of pointer arrays for img.vox, img.proxMapInput, sino.vox, sino.wgt in
interface.c
. - In Cython interface, initialize recon image directly with init image. This avoids unnecessary memory re-allocation of the recon image.
- In C code, added functionality of checking whether prox image and recon image are from the same memory address, and make a copy when necessary. This is to handle the corner case that might occur after fix 3, where x_init and prox_image might be the same variable.
- In Cython interface, only make contiguous array when necessary.
Testing
- recon testing: Cleared sys matrix cache, and ran
demo_3D_shepp_logan.py
anddemo_mace3D.py
. Results for both experiments are visually the same as before. - Unit test for fix 4: When doing proximal map mode recon, provide the same variable input of init image and proximal image. The memory address detection mechanism is triggered (as expected).