This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Index based access to a Ref<Matrix>

Tags: None
(comma "," separated)
dandelin
Registered Member
Posts
6
Karma
0

Index based access to a Ref<Matrix>

Wed Jul 01, 2015 4:18 pm
Hi,

it seems that indexed-based access to a matrix wrapped in a Ref<> object leads to a compilation error ( "YOU_ARE_TRYING_TO_USE_AN_INDEX_BASED_ACCESSOR_ON_AN_EXPRESSION_THAT_DOES_NOT_SUPPORT_THAT").

This compiles:
MatrixXd M = MatrixXd::Random(3, 3);
Ref<MatrixXd> M_ref = M;
double a1 = M(1, 5);
double a2 = M(7);
double b1 = M_ref(1, 5);

Compilation fails if I add:
double b2 = M_ref(7);

I don't know if this is related to the error raised in viewtopic.php?f=74&t=121501?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Yes, this is because by default Ref<MatrixXd> accepts non trivial strides, meaning that the memory layout is not necessarily contiguous, and thus operator()(index) is disabled.


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]