This project demonstrates the calculation of the inverse of a matrix using both Python and Cython implementations.
To compile the Cython code and install the necessary dependencies, run the following command:
python setup.py build_ext --inplace
This command compiles the Cython code and generates the Python extension module required for the Cython implementation.
- Cython Installed: Make sure you have Cython installed on your system. You can install Cython using pip:
pip install cython
- Microsoft Studio C++ Version 14 or Greater: You need to have Microsoft Visual C++ Build Tools installed, specifically version 14.0 or greater. This is required for compiling the Cython code on Windows.
- Include NumPy's Include Directory: When setting up the project in setup.py, include NumPy's include directory to ensure compatibility:
include_dirs=[np.get_include()]
This file is used to set up the project for building the Cython extension module. It uses setuptools
and Cython.Build
to compile the Cython code (cython_matrix.pyx
). Additionally, it includes NumPy's include directory to ensure compatibility.
This file contains the main code for running the matrix operations. It imports the Python and Cython implementations of the inverse function from matrix_operations.pyx
and cython_matrix.pyx
respectively. The main()
function demonstrates the usage of both implementations and measures their running time.
This file contains the Python implementation of matrix operations. It includes functions for transposing a matrix, calculating its determinant recursively, computing the cofactor matrix, and finding the inverse of a matrix.
This file contains the Cython implementation of matrix operations. It includes functions similar to those in matrix_operations.pyx
, but with optimizations provided by Cython.
To run the matrix operations, execute the main.py
file:
python main.py
This will demonstrate the usage of both Python and Cython implementations and measure their running time.