Registered Member
|
When will a member function for shifting vector values be supported in Eigen?
Thanks. |
Moderator
|
are you talking about bitewise shifting (e.g., apply operator<<(int) to each coeff) or element wise shifting (0 1 2 3 => _ _ 0 1) ?
If the former I realize that we won't be able to use operators like m << 2 because operator<<(scalar) is already overloaded for the comma initializer. |
Registered Member
|
I am talking about shifting elements.
Ex: rowVector = [1, 2, 3, 4] rowVector.leftShift(1) // shift elements by 1 to the left, adding a copy // adding a copy of the last element at the left // side. so now rowVector is [2, 3, 4, 4] I can do this myself, but I was wondering when the project will code methods like this in a possibly more efficient way. Thanks. |
Moderator
|
ok, this would require a new expression class. I can imagine 3 variants:
- circular shift, [1, 2, 3, 4] => [2, 3, 4, 1], the overhead is one integer modulo (= circshift in matlab) - shift with clamping (what you suggest), the overhead is one integer min or max. - shift with insertion of zeros, requires one if This feature is of low priority for us, so unless someone else is interested to do it, I cannot tell you when it will be available. |
Registered Member
|
Shifting is apparently still not implemented, but is fairly easily accomplished using the Map class. This should be scalable to matrices depending on the storage order of the matrix.
// Initialize int n = 4; float x[4] = { }; Map<MatrixXf> mf(x,1,n); mf << 1, 2, 3, 4; // Shift the matrix memcpy(x,&x[1],(n-1)*sizeof(&x[0])); |
Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]