Expose Eigen's Direct and Iterative Sparse System Solvers
I've done the bare minimum here. Unfortunately in my use case (A = 20k x 15k, b = 20k x 7k) none of the solvers complete in less than 10 minutes. These seems egregious, so I suspect I must be doing something inefficient, but I haven't been able to figure out what exactly. It does appear that the time is being spent in the solve() function, and not in the preparation or unpacking functions.
Thanks for your help in getting this to work, and also for any advice you can offer.
I used scipy.sparse.linalg.spsolve which solves my system in about 30 seconds, compared to many minutes with eigen.
On Thu, Dec 12, 2019 at 11:22 AM Marcello Seri [email protected] wrote:
@mseri commented on this pull request.
In eigen_cpp/lib/sparse_solver.cpp https://github.com/owlbarn/eigen/pull/18#discussion_r357239640:
+::eigen_to_c(spmat& ref) +{
- return reinterpret_cast<c_spmat*>(&ref); +}
+template <class Solver,
typename spmat,typename spmat_elt,typename c_spmat>+SparseSolver<Solver, spmat, spmat_elt, c_spmat> +::SparseSolver(c_spmat *c_coefficients, c_spmat *c_observations) +{
- spmat row_major_coeffs = c_to_eigen(c_coefficients).pruned();
- spmat row_major_observ = c_to_eigen(c_observations).pruned();
- coefficients = new col_major_spmat(row_major_coeffs);
There is no rush! Thank you very much. Is it the one in numpy/scipy another one?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/owlbarn/eigen/pull/18?email_source=notifications&email_token=ADXJVQYORQBIAP6TSNNW6M3QYJQK7A5CNFSM4I7OI372YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCPAA76Q#discussion_r357239640, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXJVQ6DB23TCSXQCMOQXVLQYJQK7ANCNFSM4I7OI37Q .
I see. They use https://portal.nersc.gov/project/sparse/superlu/ as solver, it may well be that it is much more optimised. Afaik eigen does transform the sparse matrix to a dense matrix internally in some cases
Perf really depends on underlying solvers and eigen is definitely not the best one. Eigen was originally designed for providing tensor operations for TF's DNN applications, and can be optimised on various archs by exploiting c++ meta-proramming ... not really for solving sparse problems. Tho, Google itself now changes to new solutions.
For solving sparse problems, the state-of-the-art is suiteparse, and we are working on this hard, and soon we will release it https://github.com/owlbarn/owl_suitesparse