Re: [eigen] Sparse Cholesky
• To: eigen <eigen@xxxxxxxxxxxxxxxxxxx>
• Subject: Re: [eigen] Sparse Cholesky
• From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
• Date: Tue, 3 Oct 2017 14:41:25 +0200
• Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=OZ3s4T3M3DVFJpH8Ko/aYTYdVKRTFM3+fjQippF7M4I=; b=CZQZuJxbtHT+EvdI0PaPxUY1r1cZd/XBfuVSBWK01e6RT7HZAOBxB4MqcqMFOtglTk TNxoVj1eTntamSSgVq2sudDU0ptSIKakyZKaPPifSxIRAlDs3YwmTLtDVEgRXkgMI6Qq PLmrN1bdBS7sYtTVAeF6IG+/8446kAJSvCoL5waPaU7jbg4mqA1x1MTWPWN+bxO1chVb 3DYUgHzcOg+aY0n/NNp/niOlnWJOIwPdP5jQJUrBNeXqy/kWWtraLYUEVGovUxvfCCvp zeBiqoSCqNrMPDLJ7Nlz4v0OLFGvGMqwHJaXU+EVAi5YZMPUr0IQG0sWpcjyyXzeV3A4 FuyA==

You are using SimplicialLDLT which performs P*A*P^T = L * D * L^T with D a diagonal matrix, and L a lower triangular matrix with ones on the diagonal. Use SimplicialLLT if you want the P*A*P^T = L  * L^T factorization with square roots.

gael.

On Sun, Oct 1, 2017 at 3:07 PM, Brad Bell wrote:
I do am trying to get a copy of the lower triangular matrix corresponding to a sparse Cholesky factorization. It seems to me that, in the case of a 1 by 1 matrix, this should be a 1 by 1 matrix with entry equal to the square root of the original matrix. But the following program is printing 1 instead of 2 for its result. What am I doing wrong ?

# include <iostream>
# include <Eigen/Sparse>
int main(void)
{   typedef Eigen::SparseMatrix<double, Eigen::ColMajor> sparse_matrix;
typedef Eigen::SimplicialLDLT<sparse_matrix, Eigen::Lower> sparse_cholesky;
typedef sparse_matrix::InnerIterator                       column_itr;
//
int n = 1;
sparse_matrix H(n, n);
H.insert(0, 0) = 4.0;
//
sparse_cholesky C;
C.compute( H );
sparse_matrix L = C.matrixL();
//
for(int j = 0; j < L.outerSize(); j++)
{   for(column_itr itr(L, j); itr; ++itr)
{   std::cout << "L(" << itr.row() << "," << itr.col() << ") = ";
std::cout << itr.value() << "\n";
}
}
return 0;
}

 Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/