61 it_assert((t > 0) && (2 * t < n),
"BCH::BCH(): in_t must be positive and smaller than n/2");
162 for (
i = 0;
i < n - k;
i++)
165 for (
i = 0;
i < iterations;
i++) {
168 for (
j = 0;
j < k;
j++) {
169 degree =
static_cast<int>(
mbit(k -
j - 1)) - 1;
173 m[
j] =
GF(n + 1, degree);
189 for (
j = 0;
j < n;
j++) {
190 if (
c[
j] ==
GF(n + 1, 0)) {
218 GFX r(n + 1, n - 1),
c(n + 1, n - 1), m(n + 1, k - 1),
S(n + 1, 2 * t), Lambda(n + 1),
223 for (
i = 0;
i < iterations;
i++) {
227 for (
j = 0;
j < n;
j++) {
228 degree =
static_cast<int>(
rbin(n -
j - 1)) - 1;
230 r[
j] =
GF(n + 1, degree);
234 for (
j = 1;
j <= 2 * t;
j++) {
235 S[
j] = r(
GF(n + 1,
j));
237 if (
S.get_true_degree() >= 1) {
240 Lambda =
GFX(n + 1, (
char*)
"0");
241 T =
GFX(n + 1, (
char*)
"0");
248 T =
GFX(n + 1, (
char*)
"-1 -1 0") * T;
258 for (
j = 0;
j <= n - 1;
j++) {
259 if (Lambda(
GF(n + 1,
j)) ==
GF(n + 1, -1)) {
276 for (
j = 0;
j < n;
j++) {
277 degree =
static_cast<int>(
rbin(n -
j - 1)) - 1;
278 c[
j] =
GF(n + 1, degree);
282 for (
j = 1;
j <= 2 * t;
j++) {
285 if (
S.get_true_degree() <= 0) {
299 if (
c.get_true_degree() > 1) {
301 for (
j = 0;
j < k;
j++)
308 for (
j = 0;
j <= m.get_true_degree();
j++) {
309 if (m[
j] ==
GF(n + 1, 0)) {
316 m =
GFX(n + 1, (
char*)
"-1");
361 it_error(
"BCH::decode(): Soft-decision decoding is not implemented");
366 it_error(
"BCH::decode(): Soft-decision decoding is not implemented");
Definition of Array class (container)
Definition of a BCH encoder/decoder class.
Array< T > mid(int pos, int n) const
Get n elements of the array starting from pos.
void set_length(int n, bool copy=false)
Resizing an Array<T>.
void set_size(int n, bool copy=false)
Resizing an Array<T>.
int length() const
Returns the number of data elements in the array object.
virtual bool decode(const bvec &coded_bits, bvec &decoded_message, bvec &cw_isvalid)
Decode the BCH code bits. Return false if there has been any decoding failure.
BCH(int in_n, int in_k, int in_t, const ivec &genpolynom, bool sys=false)
Initialize a (n,k)-code that can correct t errors.
virtual void encode(const bvec &uncoded_bits, bvec &coded_bits)
Encode a bvec of indata.
Polynomials over GF(q)[x], where q=2^m, m=1,...,16.
int get_true_degree() const
Return true degree of GF(q)[x].
void set(int qvalue, const char *invalues)
Set the GF(q)[x] polynomial.
#define it_error(s)
Abort unconditionally.
#define it_assert(t, s)
Abort if t is not true.
int int2bits(int n)
Calculate the number of bits needed to represent an integer n.
int length(const Vec< T > &v)
Length of vector.
ITPP_EXPORT bvec zeros_b(int size)
A Binary vector of zeros.
ITPP_EXPORT ivec zeros_i(int size)
A Int vector of zeros.
ITPP_EXPORT bvec oct2bin(const ivec &octalindex, short keepzeros=0)
Convert ivec of octal form to bvec.
GFX divgfx(const GFX &c, const GFX &g)
Division of two GFX (local help function)
int floor_i(double x)
The nearest smaller integer.
GFX modgfx(const GFX &a, const GFX &b)
Modulo function of two GFX (local help function)
Definitions of special vectors and matrices.