Eigen library

Hello,
I faced a problem in solving sparse linear system of the form:
A*x = b
where:
A - is squared, symmetric and sparse matrix.
note: the matrix A contains only the upper triangular values (in order to
save memory)
b - a vector
x - a vector of variable

I tried:
1. Eigen::SparseLU<Eigen::SparseMatrix<double>, Eigen::COLAMDOrdering<int>>
2. Eigen::ConjugateGradient<Eigen::SparseMatrix<double>, Eigen::Upper>
None of them works well!

Any ideas?

Thanks in advance :)
Elias

How big is the matrix?

Might be best to consider writing your own, even if its a no frills Gauss Jordan solution. Cholesky isn’t onerous to program. It’s not a big job.
The matrix size is 300x300.
I will try to write my own.
But Eigen library must have a solver for this problem.
Elias123456 wrote:
None of them works well!

Means what?

Is there any structure to this matrix A (e.g. tri-diagonal, penta-diagonal etc)? Where does it come from and what does it look like? Have you tried simple iterative schemes like Gauss-Seidel (with or without over-relaxation), which have the benefit of creating no "fill-in" within your sparse matrix?

If it has no structure, other than the fact it is symmetric, then Eigen's SparseCholesky module might be better than SparseLU.

What particular application is creating this matrix?

(Note: I don't use Eigen.)


Last edited on
The matrix size is 300x300.
I will try to write my own.


I've got nothing against Eigen but a 300 x 300 (augmented) matrix no-frills solver you can write yourself on a half reasonable machine will eat it in seconds at the most.

Here's a start if you want some simple source code.
https://www.techsoftpl.com/matrix/

(I am not a salesman for Techsoft)

Or you can use/abuse/change/condemn my <vector> version which I adapted from it for my purposes. I'll post it shortly, if you like.

Opinions vary obviously, and I don't want to stifle any debate, but the optimisations for a 300x300 matrix are probably not worth the trouble and strife from the added potential for introducing errors via the additional complexity.
Time taken to solve augmented 300 x 300 matrix 226486 microseconds
Blooper 0.00107663 detected row 201
No. of bloopers for the given tolerance: 1
... TEST 02 complete.
Program ended with exit code: 0


I should have included the range which goes up to 10^9 so the bloopers aren't significant.
Last edited on
Topic archived. No new replies allowed.