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

Eigen method equivalent to std::vector erase?

Tags: None
(comma "," separated)
a1re
Registered Member
Posts
16
Karma
0
Hi,

Is there an Eigen::VectorXd method equivalent to std::vector erase?

Thank You.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
no but you can use vec.data() and vec.data()+vec.size() as begin/end iterators and then call conservativeResize...
a1re
Registered Member
Posts
16
Karma
0
I actually would like to remove the i-th element from an object of type Eigen::VectorXd. With the std::vector, I can just do
Code: Select all
my_vec.erase(my_vec.begin() + i)


but with Eigen, should I just write my own method. For example, just use something like
Code: Select all
copy(my_eigen_vec.data() + i + 1, my_eigen_vec.data() + my_eigen_vec.size(), my_eigen_vec.data() + i)


and then do a conservative resize.


Thank You.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], q.ignora, watchstar