Re: [eigen] triangular solve
• To: eigen <eigen@xxxxxxxxxxxxxxxxxxx>
• Subject: Re: [eigen] triangular solve
• From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
• Date: Thu, 20 Dec 2012 23:39:31 +0100
• Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=yN8vUfbpR5hMDUTEdEElFRXaTUSa9kJKHtEqm909YqE=; b=pFp/0Gkkm8D9j15jrehTHBo+WBr0Rwkmz/X3IUn/n9kmNm7LC5SuwJvjCoXz1gicoo NC0AFeHaN89f6iF1mFr8srd+edDqInrFGYXC+K69SNbhTvyFdt+M+jrKCQweLgUakILa ee4lRzt0baoONFYYWDSRHteqzvmz0ohkp/ZFPXLXZot6ATNvzUpRBF6k/1yLYOPGv05c XRLkqODOwN+vpDQSzOGeRKvOXOws+cIfjBII/AVi51U5UoqNRXRYkYhgONH+43ykQvYD L7P8BHl908wkSh0da1Saxp0ULRAyRRrPZQXk/TA9Yz2BQha2DN0usxbmuCFRFHrM5Mwx 6myg==

Hi,

you cannot take advantage of the triangular nature of the matrix for the right hand side, so you have to copy it into a full matrix:

float denom = total_cov.matrixL().solve(MatrixXf(this->matrixL())).squaredNorm();

cheers,
Gael.

On Thu, Dec 20, 2012 at 10:53 PM, M A wrote:
I'm having trouble compiling eigen code to do a solve with two lower
triangular matrices. That is I want L1^{-1} * L2 where L1 and L2 both
come from LLT objects by way of matrixL(). Here is my class and
function,

class Covariance_comp : public LLT<MatrixXf> {
public:
float variance;

Covariance_comp( const MatrixXf &pdmat, float var) : LLT<MatrixXf>
(pdmat), variance( var ) {}

float update_fixedpt( const Covariance_comp &total_cov, VectorXf resids ) {
float numer = (this->matrixU() *
total_cov.solve(resids)).array().square().sum();
cout << "numer = " << numer << endl;
// This next line is the problem:
float denom = total_cov.matrixL().solve(this->matrixL()).array().square().sum();
cout << "denom = " << denom << endl;
variance *= numer / denom;
return variance;
}
};

The problem comes in the line float denom = .... with g++ complaining

error: no matching function for call to ‘Eigen::TriangularView<const
Eigen::Matrix<float, -0x00000000000000001, -0x00000000000000001, 0,
-0x00000000000000001, -0x00000000000000001>, 1u>::solve(const
Eigen::TriangularView<const Eigen::Matrix<float, -0x00000000000000001,
-0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001>,
1u>) const’

I don't understand the problem. Both total_cov and this are
essentially LLT objects. Is the problem using this->matrixL() as the
argument to solve? What is the best way to do this that takes
advantage of the triangular nature of the matrices? This is using
eigen 3.1.2.

Thanks!

Mark A

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