The functions, prefixed by the name of the ring, provide a coherent calling interface. They do not require the user to manage the memory.
void vec_init(vec r);
Initialize the vector r
.
This function must called before anything else.
void vec_inits(vec r,...);
Initialize a NULL-terminated list of vectors. This function must called before anything else.
void vec_clear(vec r);
Free the memory occupied by the vector r
.
You must not use r
after a call to this function.
If you want to use r
you must make a call to vec_init
.
void vec_clears(vec r,...);
Free a NULL-terminated list of vectors.
You must not use the vectors after a call to this function.
If you want to use some or all of the vectors you must make
calls vec_init
or vec_inits
.
void vec_zero(vec r);
Set all the components of r
to zero.
void vec_append(vec r,R a);
Append a
to r
.
void vec_random(vec r);
Set all the compoenets of r
to random elements of the ring.
void vec_random_hamming_weight(vec r,int nr,int w);
Set r
to be a random vector of length nr
and
Hamming weight w
.
void vec_add(vec r,vec a,vec b);
Set r
to a + b
.
If a
and b
have not the same length
the shortest vector is padded with zeros.
void vec_sub(vec r,vec a,vec b);
Set r
to a - b
.
If a
and b
have not the same length
the shortest vector is padded with zeros.
void vec_mul_by_cte(vec r,vec a,R b);
Set r
to a * b
.
void vec_set_coeff(vec r,R a,int i);
Set the i
th coefficient of r
to a
.
void vec_get_coeff(R r,vec a,int i);
Set r
to the i
th ceofficient of a
.
int vec_get_len(vec a);
Return the length of a
.
int vec_hamming_weight(vec a);
Return the Hamming weight of a
.
int vec_hamming_distance(vec a,vec b);
Return the Hamming distance between a
and b
.
If a
and b
have the not the same size then
-1
is returned.
int vec_copy(vec r,vec a);
Make a deep copy of a
into r
.
int vec_cmp(vec a,vec b);
Return 0
if and only if a
equals b
.
If a
and b
do not have the same length they
are not equal.
void vec_ptr_clear(vec *a,int n);
Clear the array a
of vectors of size n
.
void vec_print(FILE *out,vec_ptr a);
Print a
into out
.
void rs_code_init(rs_code rs,int n,int k);
Initialize rs
of length n
and dimension k
.
This function must be called before doing anything else with rs
.
The support of rs
will be a zero vector.
void rs_code_init_with_support(rs_code rs,int n,int k);
Initialize rs
of length n
and dimension k
.
This function must be called before doing anything else with rs
.
Decoding
will attempt to create the support of rs
:
it will first set the first coordinate to zero, then
it will use R_next
to set the other coordinates.
Make sure that the ring you are using has enough elements.
For exemple, if the ring is a prime field gfp
then the
support will be set to [0,1,2,3,...,n]
.
void rs_code_clear(rs_code rs);
Free the memory occupied by rs
.
void rs_code_random(vec r,rs_code rs);
Set r
to be a random codeword of rs
.
int rs_code_sudan_koetter(vec **r,rs_code rs,vec y,int tau);
Given a Reed-Solomon code rs
and a received word y
with at most
tau
errors, return the number of codewords within distance tau
of y
and set r
to an array containing the codewords.
The Sudan algorithm is used, the interpolation step is done with the
Koetter algorithm.
int rs_code_guruswami_sudan_koetter(vec **r,rs_code rs,vec y,int tau);
Given a Reed-Solomon code rs
and a received word y
with at most
tau
errors, return the number of codewords within distance tau
of y
and set r
to an array containing the codewords.
The Guruswami-Sudan algorithm is used, the interpolation step is done
with the Koetter algorithm.
void *ll_malloc(int n);
Allocate n
bytes of memory and return a pointer to the allocated
region.
If any error occur during malloc
the SIGABRT
signal is raised
by the abort
function.
void *ll_realloc(void *ptr,int n);
Change the size of the memory block pointed to by ptr
to n
bytes.
If any error occur during malloc
the SIGABRT
signal is raised
by the abort
function.
void *ll_calloc(int n);
Allocate n
bytes of memory and return a pointer to the allocated
region. The memory is set to zero.
If any error occur during malloc
the SIGABRT
signal is raised
by the abort
function.
void ll_free(void *p);
Free the memory space pointed to by p
.
The following functions alloes one to compute the parameters to give to the Sudan and Guruswami-Sudan algorithms. They apply to all Reed-Solomon codes over any kind of ring. That's the reason they take as arguments only the length and the dimension of the Reed-Solomon code and, for some, the number of errors to be corrected.
int sudan_max_errors(int n,int k);
Return the maximum number of errors that can be corrected by the
Sudan algorithm for a Reed-Solomon code of length n
and
dimension k
. (Lemma 8, page 6 of Decoding Reed-Solomon codes
beyond the Error-Correction Diameter, Madhu Sudan.)
int sudan_list_size(int n,int k,int tau);
Return the list-size for the Sudan algorithm given the length
n
and the dimension k
of the Reed-Solomon code, and the
number of errors tau
that one wants to correct.
int guruswami_sudan_max_errors(int n,int k);
Return the maximum number of errors that can be corrected by the
Guruswami-Sudan algorithm for a Reed-Solomon code of length n
and
dimension k
. (Theorem 8, page 8 of Improved Decoding of
Reed-Solomon and Algebraic-Geometry Codes, Venkatesan Guruswami
and Madhu Sudan.)
int guru_sudan_mult(int n,int k,int tau);
Return the multitplicity of the interpolating curve
of the Guruswami-Sudan algorithm for a Reed-Solomon code
of length n
and dimensions k
where tau
errors have
to be corrected. (Lemma 7, page 8 of Improved Decoding of
Reed-Solomon and Algebraic-Geometry Codes, Venkatesan Guruswami
and Madhu Sudan.)
int guruswami_sudan_list_size(int n,int k,int tau,int m);
Return the list-size for the Guruswami-Sudan algorithm given the
length n
and the dimension k
of the Reed-Solomon code, and the
number of errors tau
that one wants to correct with multiplicity
m
.
int guruswami_sudan_errors(int n,int k,int m);
Return the maximum number of errors that can be corrected
by the Guruswami-Sudan algorithm given a Reed-Solomon code
of length n
, dimension k
and the multiplicity m
.
int bitsize(unsigned long a);
Return the minimum number of bits neede to represent a
.
int half_log2(unsigned long a);
Return the greatest exponent n
such that 2^n < a
.
void print_compile_flags(FILE *out);
Print to out
the flags passed to the compiler during
the building of decoding
.
Written by Guillaume Quintin (quintin@lix.polytechnique.fr).
decoding-defines
(3),
decoding-alphabets
(3).