Re: [eigen] a problem with RowsAtCompileTime in SparseVector |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] a problem with RowsAtCompileTime in SparseVector
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Fri, 23 Jul 2010 13:47:32 +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=9EmDh+d39pT/LjgNEeZBtAr2fyLVxngX15QiWgE5NKA=; b=chITi+nmO75sn97ize9dk0nppxa6SVgbi/hBA1j3z8F0To3Ltvcxtq0RWxEpw/QX48 us0pdpH3za3IPUKPaiWQmdwxhGmxiG39it8uuI2hnOMMO0Zv3mWZGPf1BBv8hMUOeMlo qrjLhLlgSjTFF/aV7W0Xi6IDJnyZLjjY8ci3k=
- 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=kcltDDc8l45TppJtWRYj339MkB3vNJkhHam8vTKY4O4CAYJs7nIs+oAFzzBUQazQW4 OUa9ygTcRT30DIHg/mftPqSg77FnSZC7Yq8qjbnTLNXutUOYNEy0urKsrvcOn3SRqF9c 0F+xv5j6NUFrcwTyUJt5pg+/RVPZDtBBdyR54=
Hi,
yes the bug is rather in SparseVector where Dynamic sized was assumed.
Feel free to fix it if you have time.
gael
On Fri, Jul 23, 2010 at 10:00 AM, Daniel Lowengrub <lowdanie@xxxxxxxxx> wrote:
> Hi,
> I noticed that the following code complies but crashes with an assert:
> Vector10d d = Vector10d::Random(); //Vector10d is the obvious typedef
> sd = d.sparseView();
>
> The assert is:
> Assertion `( ((ei_traits<Derived>::SupportedAccessPatterns&OuterRandomAccessPattern)==OuterRandomAccessPattern)
> || (!((Flags & RowMajorBit) != (OtherDerived::Flags & RowMajorBit))))
> && "the transpose operation is supposed to be handled in
> SparseMatrix::operator="' failed.
>
> On the other hand, this code is fine:
> VectorXd d = Vector10d::Random();
> sd = d.sparseView();
>
> I think that the problem is that in the SparseVector assignment
> operator, the RowsAtCompileTime is checked:
> inline SparseVector& operator=(const SparseMatrixBase<OtherDerived>& other)
> {
> if (int(RowsAtCompileTime)!=int(OtherDerived::RowsAtCompileTime))
> return Base::operator=(other..transpose());
> ...
> }
> And then since d.sparseView() takes the same RowsAtCompileTime as d
> (which is 10 in the first case but -1 in the second) but sd has -1
> RowsAtCompileTime, d.sparseView() is transposed in the first case
> which leads to the assertation.
>
>
> Should SparseView explicitly set RowsAtCompileTime to -1 (Dynamic)?
> Or should the assignment operator call the resize method like in the
> SparseMatrix class?
>
> Daniel
>
>
>