Registered Member
|
I use Matlab to LDLT decomposition the matrix, ok!
but failed using Eigen. Can anybody help me? matlab code: load GK27.txt; s27=spconvert(GK27); L27 = chol(s27,'lower'); c++: SimplicialLDLT<SparseMatrix<double>> _solver; _solver.compute(_GlobalK); if(_solver.info()!=Success) the matrix is: http://yunpan.cn/cyawfny2wn9bR password 4ecb |
Moderator
|
The rank of your matrix is only 272, and SimplicialLDLT does not support non full-rank matrices. You can use SparseQR<SpMat,COLAMDOrdering<int> > for non full rank problems.
|
Registered Member
|
thanks!
Now I use SparseQR<SpMat,COLAMDOrdering<int> > to decomposition the matrix; however it cannot get a correct R matrix; General, the diag value of R is the eigenvalue of the matrix; for non full-rank matrices,diag value will be zero at some way;now the diag value of R are all 1E120; how can i get a correct R matrix! Can you help me again? thank you! |
Registered Member
|
SimplicialLDLT<SparseMatrix<double>> _solver;
_solver.compute(_GlobalK); if(_solver.info()!=Success) { SparseMatrix<double> _GlobalK2; _GlobalK2=_GlobalK; for (int k2=0; k2<_GlobalK.outerSize(); ++k2) { for (SparseMatrix<double>::InnerIterator it(_GlobalK,k2); it; ++it) { if(it.col()!=it.row()) { GlobalK2.insert(it.col(),it.row()) = it.value(); } } } _GlobalK2.makeCompressed(); Eigen::SparseQR<SparseMatrix<double>,COLAMDOrdering<int>> _solverQR; _solverQR.compute(_GlobalK2); std::ofstream fout("Rmat.txt"); fout<<_solverQR.matrixR()<<endl; fout<<endl; fout.close(); } the R matrix is: http://yunpan.cn/cKtteLQRseCqr password 824b |
Moderator
|
This is correct, the singular values of your matrix are:
|
Registered Member
|
The result of R was unique; So,result of R should be consistent between "Eigen Solver" and "Matlab"; However,the result is not the same. Matlab Result and code: http://yunpan.cn/cKITUIrQRmUer password 44f4 matlab diag of R matrix:
for non full-rank matrices,diag value will be zero at some way the zero positions are very important for me. I am very happy to be able to use eigen solver,because it is fast and convenient. Thanks for the Eigen!Thank you! |
Moderator
|
SparseQR performs column pivoting for both numerical robustness and to reduce fill-in. So the actual decomposition is: A * P = Q * R which is why all non-zero diagonal elements appear first.
|
Registered Member
|
Thanks, This is a structural engineering problem, we use the finite element method, and the degrees of freedom at fixed position usually adopts the method of setting a big number(1E120); So,QR decomposition with column pivoting will set a big number(1E120) as a pivot element, Other elements is much less than big number(1E120) wiil be ignored. Now,I removed the fixed Row and column,and I got the correct rank of the matrix (the rank is 1916). Is there a way to get the position(row and column number) of the non-zero of diag,Just like the matlab? Thanks! |
Moderator
|
You should rather move the hard constraints to the right hand side or using Lagrange multipliers.
|
Moderator
|
You can also play with the pivot threshold to enforce SparseQR to see it as a full-rank problem:
SparseQR<SpMat,COLAMDOrdering<int> > qr; qr.setPivotThreshold(1e-16); qr.compute(A); |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]