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

Access element from MatrixXf and VectorXf

Tags: None
(comma "," separated)
hvn
Registered Member
Posts
4
Karma
0
Hi,

I've been searching all through Eigen docs, and found info about coeffs and how I should be able to access the first element of VectorXf using vector.x() or vector(0). This doesn't work for me though. When I use std::vector I can do it using vector[] and vector.at[]. But how can I do this using VectorXf and MatrixXf ?

Thanks.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Everything is explained there: http://eigen.tuxfamily.org/dox-devel/gr ... tml#title4

What is not working for you? Make sure you compiled without -DNDEBUG to get feedback on out of range accesses and other common programming mistakes.
hvn
Registered Member
Posts
4
Karma
0
Thank you for this link...is what I needed. Other problem is that I fail to convert from a VectorXf element to float. Using std::vector "float *t1 = std::vector &t.at[1];" works fine. However, "float *t1 = VectorXf &t(0);" does compile but ends with segmentation fault.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
float* t1 = &t(0); or better, float *t1 = t.data();
hvn
Registered Member
Posts
4
Karma
0
ggael wrote:float* t1 = &t(0); or better, float *t1 = t.data();


OK, found another detail I have to get used to using eigen: MatrixXf and VectorXf need their sizes set during initialization. Working now. Thank you.


Bookmarks



Who is online

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