From 346245c4ccb57f4d26189b774dfc5e675b32267e Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Mon, 27 Mar 2023 11:07:04 +0200 Subject: [PATCH] added simple interleavers --- interleave.hh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 interleave.hh diff --git a/interleave.hh b/interleave.hh new file mode 100644 index 0000000..78c067e --- /dev/null +++ b/interleave.hh @@ -0,0 +1,32 @@ +/* +Interleavers + +Copyright 2023 Ahmet Inan +*/ + +#pragma once + +namespace CODE { + +template +static void Interleave(TYPE *out, const TYPE *in) +{ + static_assert(SIZE % ORDER == 0, "ORDER does not divide SIZE"); + int LENGTH = SIZE / ORDER; + for (int i = 0; i < LENGTH; ++i) + for (int j = 0; j < ORDER; ++j) + out[ORDER*i+j] = in[i+j*LENGTH]; +} + +template +static void Deinterleave(TYPE *out, const TYPE *in) +{ + static_assert(SIZE % ORDER == 0, "ORDER does not divide SIZE"); + int LENGTH = SIZE / ORDER; + for (int i = 0; i < LENGTH; ++i) + for (int j = 0; j < ORDER; ++j) + out[i+j*LENGTH] = in[ORDER*i+j]; +} + +} +