![]() Registered Member ![]()
|
Good day!
I am trying to solve 1D adv-diff-reaction ODE(exactly, ODE not PDE) with Eigen sparse matrices but I can not get correct solution.
code could be found here: https://gist.github.com/pycckuu/10640287 I form sparse matrices and XD vectors. I solve the problem but get incorrect solution (I checked with Mathematica, Matlab(used the same matrices and made A\b) as well as I rewrote the same code in PETSC and got correct results). But Eigen give me the same incorrect result for 3 different solvers (CG, SimplicialLDLT, SimplicialLLT). I realize that it is something with how I use it but I can not understand where the problem... Thank you in advance By the way, Great toolbox! I would like to use it instead of PETSC due to EIGEN is very intuitive! Great work! |
![]() Moderator ![]()
|
How much incorrect? Are you sure that your problem is symmetric positive definite? Have you checked that solver.info()==Eigen::Success after calling .compute()? Can you try a not too large problem with a dense solver (use MatrixXd(*mpLhsMat) to construct a dense matrix from a sparse one )?
|
![]() Registered Member ![]()
|
Thank you very much for such quick reply.
Completely incorrect.
No, I am not sure about this. How can I check it? Is there any way to convert the matrix to symmetric positive definite?
This test didnt passed ![]()
Thank you for great suggestion. FullPivHouseholderQR worked for me. |
![]() Moderator ![]()
|
indeed, looking at your code, the matrix is not even symmetric. So for large scale problem, you can try SparseLU or BiCGSTAB.
|
![]() Registered Member ![]()
|
I've got BiCGSTAB working but can not force SparseLU to work for me:
but it tells me:
I was trying to find the problem on the forum but didn't have a success. Thank you in advance. |
![]() Moderator ![]()
|
This is because you matrix contains empty rows or columns.
|
![]() Registered Member ![]()
|
this solved the problem. But I didn't understand how ![]() |
Registered users: Baidu [Spider], Bing [Bot], Google [Bot], rblackwell