Re: [eigen] Eigen 3.0-beta1 operator+= problem |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Eigen 3.0-beta1 operator+= problem
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Sun, 5 Sep 2010 18:42:17 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=o7vK63qcxBlqUwZzWwhLWg6irxIIMxMQT9a0JBQLIPY=; b=dE1Lfek7UKcPIjr6P7JwFpVOqgJrB+65vG55ckWTW0+IDV8eUGvvsnR7XfI0jwi4Ro HD+P5Q9NKtIdqDOHNoA1z3qrnmt2cAJhVRBBwzM2CSvNbwfBlQVnVQnsAUuOPM1HBkn/ xmRsSuBE70bDISzcKCxIHKPAyzY7YflLSD8rc=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=iL///s6ytJYq2GT3Xc5spu0uVeWLilRRzCRBQ6/seNYttrItZz/xzDPt6eWeh9ioMO tZdWqCTKU8l1eLgmpTQPCoWFLt9o6ITyQyPTklci+8nsodws+iSgenia2yd/kPqgDl1g 7XrD4VwVbWwa8TZ9OC0u26EdDtQAVO6xnSfro=
Problem confirmed with current development branch.
gdb tells me it's picking up the operator+= defined at
Eigen/src/Core/CwiseBinaryOp.h:232:
template<typename Derived>
template<typename OtherDerived>
EIGEN_STRONG_INLINE Derived &
MatrixBase<Derived>::operator+=(const MatrixBase<OtherDerived>& other)
{
SelfCwiseBinaryOp<ei_scalar_sum_op<Scalar>, Derived, OtherDerived>
tmp(derived());
tmp = other.derived();
return derived();
}
So this is likely a bug in SelfCwiseBinaryOp. That's all I can do for today....
Benoit
2010/9/5 Gavin Band <gavin.band@xxxxxxxxxxxxx>:
> Dear Eigen list,
>
> I decided to evaluate Eigen and (wanting to dive in at the deep end) downloaded Eigen 3.0 beta. However, I immediately ran into the problem exemplified by the code below, in which using operator+= seems to give a different answer than using operators + and = separately when the rhs is the result of ColPivHouseholderQR::solve(). (The problem did not occur with a plain MatrixXd on the right.) Is this behaviour a bug, or am I doing something wrong?
>
> Many thanks,
> Gavin Band.
>
> // ==== begin code ====
>
> #include <iostream>
> #include <Eigen/Dense>
>
> int main()
> {
> Eigen::VectorXd pt( 1 ), v1( 1 ), v2( 1 ) ;
> pt << 1 ;
> v1 << 1 ;
> v2 << 1 ;
>
> Eigen::MatrixXd M( 1, 1 ) ;
> M << 1.0 ;
>
> Eigen::ColPivHouseholderQR< Eigen::MatrixXd > decomposer( M ) ;
>
> v1 += decomposer.solve( pt ) ; // value is 1 ???
> v2 = v2 + decomposer.solve( pt ) ; // value is 2, ok.
>
> std::cerr << "QR = " << decomposer.matrixQR() << ", v1 = " << v1 << ", v2 = " << v2 << ".\n" ;
> }
>
>
>
>
>