Registered Member
|
I am a newbie on the Eigen. I want to solve the sparse linear system Ax = b by using CG.
Here is my code
A is symmetric matrix as shown below A = 2 -1 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 -1 3 -1 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 -1 3 -1 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 -1 2 0 0 0 -1 0 0 0 0 0 0 0 0 -1 0 0 0 3 -1 0 0 -1 0 0 0 0 0 0 0 0 -1 0 0 -1 4 -1 0 0 -1 0 0 0 0 0 0 0 0 -1 0 0 -1 4 -1 0 0 -1 0 0 0 0 0 0 0 0 -1 0 0 -1 3 0 0 0 -1 0 0 0 0 0 0 0 0 -1 0 0 0 3 -1 0 0 -1 0 0 0 0 0 0 0 0 -1 0 0 -1 4 -1 0 0 -1 0 0 0 0 0 0 0 0 -1 0 0 -1 4 -1 0 0 -1 0 0 0 0 0 0 0 0 -1 0 0 -1 3 0 0 0 -1 0 0 0 0 0 0 0 0 -1 0 0 0 2 -1 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 -1 3 -1 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 -1 3 -1 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 -1 2 b = zeros Actually x should be zeros, but x turns out to be not-a-number after solving by CG. I don't know why. I use it on OS X. Anyone know how to fix this? Thank you in advance. |
Registered Member
|
The matrix A is singular; the vector of all ones is in the kernel. According to http://eigen.tuxfamily.org/dox-devel/gr ... stems.html , ConjugateGradient requires the matrix to be positive definite.
|
Registered Member
|
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]