rwl / CSparse.py

CSparse.py: a Concise Sparse matrix Python module
http://www.cise.ufl.edu/research/sparse/CSparse/
GNU Lesser General Public License v2.1
11 stars 5 forks source link

Port to cython #1

Closed SanPen closed 5 years ago

SanPen commented 5 years ago

Hello Richard,

This was triggered by the recent finding that scipy sparse classes introduce such an overhead that sparse matrix checks take more time in GridCal's power flows than the matrix multiplication and linear system solving combined. That is absurd.

So I started reading Davis's book and when googled "CSparse python", your repository appear (who else!)

Well, right now I am porting your code to python 3, with the final aim of taking critical parts into cython and maybe link MKL for the linear system solving. I think this code is perfect for that because it is written in system python with no numpy dependencies.

I am interested about your thoughts on this, and if you know any other competitive sparse lineal algebra library in python, preferably python wrapper of a C/Fortran library.

Best regards, Santiago

rwl commented 5 years ago

I'm not sure you will get the performance you desire using CSparse. It is optimised for readability. You will have more luck using KLU in combination with AMD preordering. I have translated these two into various languages over the years. Since you are using the GPL for GridCal I would recommend CVXOPT for your sparse matrix needs. That is what Federico Milano uses for Dome (http://faraday1.ucd.ie/dome.html). I used SciPy for Pylon/PYPOWER so that they could be published under more permissive licenses. @cuihantao has done a good job wrapping KLU for use with CVXOPT:

https://github.com/cuihantao/cvxoptklu

A pure Python translation would be interesting for use in combination with PyPy or Numba. I think there has been some work along those lines in pandapower:

https://www.pandapower.org/