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: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Mon, 6 Sep 2010 12:36:01 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=poh2HkwQHvDl3c5V6LVCk2CI25xtEt6LFNuYyuau/HY=; b=dOO89+yV+jrp8OkSNqhw45OYRJdl1H0FyXZHROYNYNH9ztXvMLVPNhb0Jf2nP0vBf/ DKu0jH8MmXyZ+UG/pOqVjOQfKXDU/lKixu+iaVok+7PRm6950wMs8zMcLFPWwX9MOaOz MDhdZ/lVOPm8teq91pa46ecp/Cm0HMVrNGrJs=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=WWzOf2qdiUJgbs8NBE5KGBb7EW0UvynA8B2VgrfuYpc213xl5NzYqPfWmhXrnQn2pz kLGZGVHDmDbHjO1ulClvlVlxeUB0c/0are/uQUU99eWyW6T/9wu5Fovi4OSe0CeBFMA0 iyWSHMRGs+PCBbZJC30OoLlfDz+UAFLq3+uZI=
thank you for the self-contained test case. problem solved with
respective unit tests.
gael
On Mon, Sep 6, 2010 at 12:42 AM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
> 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" ;
>> }
>>
>>
>>
>>
>>
>
>
>