2

I wish to speed up the sparse system solver part of my code using Numba. Here is what I have up till now:

# Both numba and numba-scipy packages are installed. I am using PyCharm IDE
import numba
import numba_scipy
# import other required stuff

@numba.jit(nopython=True)
def solve_using_numba(A, b):
    return sp.linalg.gmres(A, b)

# total = the number of points in the system

A = sp.lil_matrix((total, total), dtype=float)
# populate A with appropriate data
A = A.tocsc()

b = np.zeros((total, 1), dtype=float)
# populate b with appropriate data

y, exit_code = solve_using_numba(A, b)

# plot solution

This raises the error

argument 0: cannot determine Numba type of <class 'scipy.sparse.csc.csc_matrix'>   

In the official documentation, numba-scipy extends Numba to make it aware of SciPy. But it seems that here, numba cannot work with scipy sparse matrix classes. Where am I going wrong and what can I do to fix this?

I only need to speed up the sparse system solution part of the code because the other stuff is pretty lightweight like taking a couple of user inputs, constructing the A and b matrices, and plotting the end result.

  • A quick glance and `numba_scipy` indicates that it has only added support for the `scipy.special` submodule. It looks like a pretty new (and experimental) addition. – hpaulj Jun 05 '20 at 04:01
  • So basically numba is no good for sparse matrices? – Amit Hasan Arpon Jun 05 '20 at 07:23
  • 1
    All the solvers that I know of are implemented in C. Numba will not do anything to increase the performance of code that is already written in C. Even if the sparse matrices were valid numba types it wouldn't matter for this. – CJR Jun 05 '20 at 12:54

0 Answers0