What is the best (by which I mean the fastest and/or most efficient) way to perform a circular shift on a 2D Eigen array?
For example, I would like to circularly shift a ArrayXXd
to the right. I think I can do something like the following:
circShiftRight (ArrayXXd &arraytoshift)
{
Matrix<double, Dynamic, 1> tmp;
tmp = arraytoshift.col (arraytoshift.cols ()-1);
arraytoshift.rightCols(_radForceVelocity.cols()-1) = arraytoshift.leftCols(_radForceVelocity.cols()-1).eval ();
arraytoshift.col(0) = tmp;
}
but will this work and is there a better way? I assume the .eval()
is necessary to avoid Aliasing. I'm new to using the Eigen Library.