Registered Member
|
Hello everyone,
First of all I would like to say that I am using Eigen for my project and it's a great library, very convenient especially for the SVD solvers I am struggling now to solve a linear problem (Ax=b) using sparse matrices (well only A is sparse, x and b are dense). I have read on the forum that the solution is to use SuperLU since it's not built-in in Eigen. So here is what I do (I realise that I might do something very dumb, so please tell me if it's the case!), in a very simplified way (I fill a part of A with random values, and b with random values).
It doesn't work, x is filled with zeros, and the output is:
So the succeded() method works, but the solve() fails, and I don't know why. I use the setter since I want later to fill A in a random order. I am using the latest dev version of Eigen, but the problem is the same with the 2.10. Am I doing anything wrong? Also that might seem stupid but do I have to build anything? I am using Eigen by including the .h in my project, so far it was working perfectly. What about SuperLU? Is there a special thing to do for it to work with Eigen? I tried to build it (I am using VS2008) and add the paths of the .lib and the headers to my project, but it's the same. I don't even have an error when I don't explicitely add SuperLU to my project, is it included in Eigen in some way? Any idea? Sorry for the zillion questions! Cheers! |
Moderator
|
First of all you have to #define EIGEN_SUPERLU_SUPPORT before including Eigen. Without that it uses the default implementation which is empty (it even does not set m_succeed to false, that is not nice, I know, though in debug mode it triggers an assert telling you this is not implemented). Again I agree this current state is not ideal, you should get a compilation error, I'll try to improve that (and the doc!).
Then you should get a linkage error if you don't link your stuff to SuperLU. Finally, you should make sure that you have a at least one non zero per row of your matrix, otherwise the solver will likely complain... |
Registered Member
|
Thank you very much for this explanation
I tried what you said, and after struggling for several hours to compile SuperLU and BLAS on my windows machine, it works! Well the setter crashed after setting about 200 000 values, but I will think about a more efficient way to fill the matrix. BTW, my matrix will eventually be 1000000 x 1000000, filled with about 5*1000000 elements. Do you recommend any particular method to create an d fill the sparse matrix? About the solver, do you think that SuperLU & blas (ATLAS) are fine for that? Cheers! |
Registered Member
|
I downloaded the Eigen dev branch from this site:https://bitbucket.org/eigen/eigen/get/default.zip and used SuperLU as backend, but there's still a "not implemented" assertion.The SuperLU lib is correctedly compiled and linked. I wonder where did I do wrong? |
Moderator
|
Make sure you did not used deprecated stuff:
SuperLU<SparseMatrix<double> > slu; slu.compute(A); x = slu.solve(b); With the default branch you can also use the iterative, built-in BiCGSTAB solver: #include <Eigen/IterativeSolvers> BiCGSTAB<SparseMatrix<T>, DiagonalPreconditioner<T> > solver; // solver.setMaxIterations(....); // solver.setTolerance(...); x = solver.compute(A).solve(b); |
Registered Member
|
Thanks for reply! I didn't use the deprecated stuff you mentioned,the code snippet that I use is as follows, SparseLU<SparseMatrix<double,RowMajor>,SuperLU<SparseMatrix<double,RowMajor>>> lu(lhs); I tried to use SparseLU<SparseMatrix<double,RowMajor>,SuperLU> lu(lhs);as mentioned in the tutorial,but it can't compile correctedly. I don't know what's wrong and really get stuck here. Hope you could help me. Thanks! |
Moderator
|
SparseLU is deprecated, use the SuperLU class as mentioned above.
|
Registered Member
|
Thanks,ggael! I get your idea now |
Registered Member
|
Hi,ggael. I used the SuperLU as you mentioned above:
This time I get linking errors: "unresolved external symbol _dgssvx" "unresolved external symbol _Destroy_CompCol_Matrix" "unresolved external symbol _StatFree" "unresolved external symbol _Destroy_SuperNode_Matrix" "unresolved external symbol _set_default_options" "unresolved external symbol _StatInit" Is it that I didn't compile SuperLU correctly? Thanks. |
Registered Member
|
I've found the reason, it's problem of the libs that I use. Thanks anyway! |
Registered Member
|
How did you manage this problem? |
Registered users: bancha, Bing [Bot], Evergrowing, Google [Bot], lockheed, mesutakcan, sandyvee