39 B =
"0 1 1 1 1 1 1 1 1 1 1 1;1 1 1 0 1 1 1 0 0 0 1 0;1 1 0 1 1 1 0 0 0 1 0 1;1 0 1 1 1 0 0 0 1 0 1 1;1 1 1 1 0 0 0 1 0 1 1 0;1 1 1 0 0 0 1 0 1 1 0 1;1 1 0 0 0 1 0 1 1 0 1 1;1 0 0 0 1 0 1 1 0 1 1 1;1 0 0 1 0 1 1 0 1 1 1 0;1 0 1 0 1 1 0 1 1 1 0 0;1 1 0 1 1 0 1 1 1 0 0 0;1 0 1 1 0 1 1 1 0 0 0 1";
46 int no_bits = uncoded_bits.length();
47 int no_blocks =
floor_i(no_bits / 12.0);
49 coded_bits.set_size(24*no_blocks,
false);
53 for (i = 0; i < no_blocks; i++)
54 coded_bits.replace_mid(24*i, Gt * uncoded_bits.mid(i*12, 12));
60 encode(uncoded_bits, coded_bits);
66 int no_bits = coded_bits.length();
67 int no_blocks =
floor_i(no_bits / 24.0);
69 decoded_bits.set_size(12*no_blocks,
false);
71 bvec S(12), BS(12), r(12), temp(12), e(24), c(24);
74 for (i = 0; i < no_blocks; i++) {
75 r = coded_bits.mid(i * 24, 24);
85 for (j = 0; j < 12; j++) {
87 temp = S + B.get_col(j);
89 e =
concat(temp, eyetemp.get_row(j));
104 for (j = 0; j < 12; j++) {
105 temp = BS + B.get_row(j);
107 e =
concat(eyetemp.get_row(j), temp);
118 decoded_bits.replace_mid(i*12, c.left(12));
125 decode(coded_bits, decoded_bits);
133 it_error(
"Extended_Golay::decode(vec, bvec); soft-decision decoding is not implemented");
138 it_error(
"Extended_Golay::decode(vec, bvec); soft-decision decoding is not implemented");
Mat< Num_T > concat_horizontal(const Mat< Num_T > &m1, const Mat< Num_T > &m2)
Horizontal concatenation of two matrices.
virtual void encode(const bvec &uncoded_bits, bvec &coded_bits)
Encoder. Will truncate some bits if not length = integer * 12.
ITPP_EXPORT bvec zeros_b(int size)
A Binary vector of zeros.
Definition of the Extended Golay Code (24, 12, 8)
int weight(const bvec &a)
Calculate the Hamming weight of a.
Definitions of converters between different vector and matrix types.
Extended_Golay()
Constructor.
virtual void decode(const bvec &coded_bits, bvec &decoded_bits)
Decoder. Will truncate some bits if not length = integer * 24.
Definitions of some specific functions useful in communications.
int floor_i(double x)
The nearest smaller integer.
Definitions of special vectors and matrices.
#define it_error(s)
Abort unconditionally.
ITPP_EXPORT bmat eye_b(int size)
A Binary (size,size) unit matrix.
Mat< bin > bmat
bin matrix
const Array< T > concat(const Array< T > &a, const T &e)
Append element e to the end of the Array a.