Registered Member
|
Hi,
How can I sort a row of a matrix? I tried used the function below, but it gets a lot of errors Thanks
|
Moderator
|
in Eigen2 there is only a const version of the data() function, so instead you can use coeffRef:
std::sort(&xValues.coeffRef(0), &xValues.coeffRef(0)+xValues.size()); |
Registered Member
|
Thanks, but now the program segfaults!
|
Registered Member
|
Compile with -g3 and get a backtrace!
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Registered Member
|
Since you are passing pointers to std::sort, the memory block must be continuous and neighboring elements must have a distance of 1 in ptr arithmetic. This is not the case for a row when Eigen is configured to work with column major memory layout.
Or am I missing something? - Hauke |
Moderator
|
|
Registered Member
|
OK, the question remains: how do I sort a RowXpr or ColXpr in Eigen 2.0.15? Thanks |
Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft