This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Problem solving Ax = b

Tags: None
(comma "," separated)
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Problem solving Ax = b

Sat Jun 23, 2012 7:39 pm
renzh: since your matrix is singular, there is not a unique solution. Here the following solvers give me a solution with (A*x-b).cwiseAbs().maxCoeff() around 1e-11:

MatrixXcd A;
VectorXcd x, b;
SparseMatrix<double> S;
loadMarket(S,"Krr_1.dat");
int n = S.cols();
A = MatrixXcd(S);
x.setOnes(n);
b = A*x;

x.setZero();
x = SimplicialLDLT<SparseMatrix<double> >(S).solve(b);
//x = A.ldlt().solve(b);
//x = A.partialPivLu().solve(b);
//x = A.colPivHouseholderQr().solve(b);
std::cout << x.transpose() << "\n";
std::cout << (A*x-b).cwiseAbs().maxCoeff() << "\n";


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], rblackwell