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

Subview of a vector

Tags: None
(comma "," separated)
allanmulin
Registered Member
Posts
14
Karma
0

Subview of a vector

Fri Jul 08, 2011 1:59 pm
Suppose I have two vectors of doubles, where one of them is supposed to store a subset of entries of the other:

Code: Select all
VectorXd vec(5), subvec(3);


Suppose the subset is determined by a vector of indexes:
Code: Select all
VectorXi id(3);

Is there a way in Eigen to work with a wrapper for the larger vector such that operations like:
Code: Select all
for(i = 0; i < 3; ++i)
   vec[id[i]] = subvec[i];

become:
Code: Select all
for(i = 0; i < 3; ++i)
   vec_wrapper[i] = subvec[i];

Its like a permutation view of the larger vector. Note that vec_wrapper would hold some reference to the vec data.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Subview of a vector

Fri Jul 08, 2011 4:11 pm
this is a common feature request, unfortunately nobody took the time to implement it yet. Actually you would even write:

vec(id) = subvec;


Bookmarks



Who is online

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