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: Daniel Lowengrub <lowdanie@xxxxxxxxx>
- Date: Fri, 23 Jul 2010 15:55:48 +0200
- 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=EwqvhnckLZHxHLajSxihwVjNMjga3e4dgZrqgFOlxm0=; b=ViXNd0XXUrOh8BxZwxgh/O4c974lPkfblN6LP6soDNAIjoiva4L6j8XdkC6DT015qt yF1/yd9ZfK+L+Tky5z31trh153IMbEQEJbFRmw1++5npm+/ue/6qO4T1egYgD7vWR+SJ m39bH8fKAzUemHMOv+zo0Rydisy15Q/bTq3bo=
- 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=ZNhRBpCCy5WJrwt7+otrYMxOkINQN9C6zAB2a8D01S6qPP68sbsWZ3KfUWoqLn8fs8 TZxqienIyQ6NWncl2Paetmbx53LXU/zk0WkG36ZPFpx1YWb6DSJUdyL7kbY1bIt+cTD5 dP9I+PyAf1sc4CanhSf4e1+2lxIDCD3l0s9GM=
Ok, I'll try to fix it on sunday. From what I understand, the
SparseVector should first check the size of other and then call
resize, similar to the SparseMatrix assignment.
Daniel
On Fri, Jul 23, 2010 at 1:47 PM, Gael Guennebaud
<gael.guennebaud@xxxxxxxxx> wrote:
> 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
>>
>>
>>
>
>
>