Registered Member
|
Hi there,
I'm trying to write a generic function to get elements at certain 1D indexes of a Eigen object, the indexes are given by another Eigen object. This is like the Matlab indexing one vector into another. I got it working for concrete types but not quite for the generic case and I've been trying already for quite a while. Can someone can give me a hand? The function looks like:
Thanks, Martin |
Moderator
|
you should soon be able to do result = data(index), in the mean time:
typename Derived1::PlainObject result(data.rows(), index.size()); for(int i = 0; i < index.size(); ++i) result.col(i) = data.col(index(i)); return result; |
Registered Member
|
Oh! great news! I would be using result = data(index) a lot!
About the mean time solution, I still don't get it to work, now I've tried:
I get a compile error C2039: 'col' : is not a member of 'Eigen::EigenBase<Derived>' in the line result.col(i) = data.col(index(i)); Actually, instead of copying the whole column I would like to access data at 1D indexes and put the result in a Vector or 1D Array depending on the data type. Thanks Martin |
Moderator
|
oh, you have to replace EigenBase by DenseBase
|
Registered Member
|
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]