From 2b25cd3dcc0c403fb0074e884200f0b3b522c768 Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Tue, 24 Sep 2019 10:49:18 +0200 Subject: [PATCH] added code to explain rotate.hh --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e39d0b0..89157f4 100644 --- a/README.md +++ b/README.md @@ -89,5 +89,17 @@ Single instruction, multiple data ([SIMD](https://en.wikipedia.org/wiki/SIMD)) w ### [rotate.hh](rotate.hh) -([SIMD](https://en.wikipedia.org/wiki/SIMD)) element wise horizontal rotation +[SIMD](https://en.wikipedia.org/wiki/SIMD) element wise horizontal rotation + +It computes the following, but faster: + +``` +SIMD rotate(SIMD input, int shift, int WIDTH) +{ + SIMD output; + for (int n = 0; n < WIDTH; ++n) + output.v[(n + shift + WIDTH) % WIDTH] = input.v[n]; + return output; +} +```