-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect behavior and documentation for xsimd::rotate_left
/xsimd::rotate_right
#1062
Comments
According to https://en.wikipedia.org/wiki/Left_rotation rotate left should result in |
Great thanks! |
Their meaning was swapped, this should fix #1062
Their meaning was swapped, this should fix #1062
Can you confirm #1065 works as expected? |
@JohanMabille we'll have to do a minor release after this one, I think. |
I've tried with my simple example and it now works as expected. The updated documentation still mentions the
but there's no such function in xsimd. What does this refer to? Maybe this mention should be removed. Anyway thanks for fixing this! |
Their meaning was swapped, this should fix #1062
doc fixed, it should mentioning |
I had to use
xsimd::rotate_left
/xsimd::rotate_right
recently in order to get the following behavior:{0.0f, 1.0f, 2.0f, 3.0f}
->{1.0f, 2.0f, 3.0f, 0.0f}
.To me, this appears like I need to do a left rotation by one element, or by
sizeof(float)
(4) bytes.The documentation for
xsimd::rotate_left
states:Setup: I'm on mac (arm) and using
batch<float> x(0, 1, 2, 3)
.batch<float>::size
is 4 andsizeof(float)
is 4 bytes. I'm using the latest version (13.0.0)First I searched for
rol
but couldn't find it.So I tried to do:
xsimd::rotate_left<sizeof(float)>(x)
but this gives back the same unchanged batch. Then I tried tochange the rotation amount to 1 and I got a right rotation of 1 (->
{3, 0, 1, 2}
)Sidenote:
xsimd::rotate_right<4>(x)
does not compile whilexsimd::rotate_left<4>(x)
does.So to get what I wanted, I had to do:
xsimd::rotate_right<1>(x)
, which seem weird according to both the function name and the documentation.Two things appears to be wrong in the documentation:
Here's a reproducible example and its output (ran it on mac arm and on windows x86_64).
Output:
What do you think is the best way to address this? I'm happy to help if I can.
IMHO, I think that the behavior of
rotate_left
androtate_right
should be swapped, and the documentation updated. But that be a breaking change.Anyway, thanks for making xsimd, I love to work with this library!
The text was updated successfully, but these errors were encountered: