[eigen] a problem with RowsAtCompileTime in SparseVector |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: [eigen] a problem with RowsAtCompileTime in SparseVector
- From: Daniel Lowengrub <lowdanie@xxxxxxxxx>
- Date: Fri, 23 Jul 2010 11:00:28 +0300
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type:content-transfer-encoding; bh=q1wNZuZdbew2o2mC/PPqFEs0fHHF0LcaEPZW3M3bx7Y=; b=nLaSKTqyILK+ebqasV7ao3k97Qkgu7erYZ0AumWgpP1i5MRJtwLk4NP1CDIyaFVfR7 4iA3f5LPx5usOcxiBBOZ/WGYOHW5GlwcWiO0+doCWl10EdSozukiJ3DSQwu5lIkqjWd8 g70lwmKP0nrNRSGZKYiapDWwUv5uImoS4TjDY=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=wZJXBLQb5HuvpYUaNKtH8u8TZ5RiIvv11As3+p+zBEgivI4i90k6z9p0l0M7Ciugzi KitySg9CBM/xYzy8ptXD7y3zxg2sXN5dMChYSjnNIAE6o/Rs902DX/CTL0fsvddPVHN8 AQC7SvlWSHKWPtL1FWRJwa/LssrapeXwSVkqg=
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