mirror of
https://github.com/aicodix/code.git
synced 2026-04-27 14:30:36 +00:00
added simple interleavers
This commit is contained in:
parent
3a860b9c73
commit
346245c4cc
1 changed files with 32 additions and 0 deletions
32
interleave.hh
Normal file
32
interleave.hh
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
Interleavers
|
||||||
|
|
||||||
|
Copyright 2023 Ahmet Inan <inan@aicodix.de>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace CODE {
|
||||||
|
|
||||||
|
template <int SIZE, int ORDER, typename TYPE>
|
||||||
|
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 <int SIZE, int ORDER, typename TYPE>
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue