Skip to content
Extraits de code Groupes Projets
Valider c9b1059f rédigé par Louis Navarre's avatar Louis Navarre
Parcourir les fichiers

Add system function definitions

parent e9d1d204
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
#ifndef SYSTEM_H #ifndef SYSTEM_H
#define SYSTEM_H #define SYSTEM_H
#include <stdint.h>
typedef struct typedef struct
{ {
// TODO // TODO
} system_t; } system_t;
/**
*
* Add two vectors in a Galois Field 256
* @param symbol_1: the first symbol to add
* @param symbol_2: the second symbol to add
* @param symbol_size: size of the two symbols (of the same size!)
* @return: a new vector of `symbol_size` byte containing the result of symbol_1 + symbol_2 in GF(256)
*/
uint8_t *gf256_add_two_vectors(uint8_t *symbol_1, uint8_t *symbol_2, uint32_t symbol_size);
/**
*
* Add two vectors in a Galois Field 256 where the second vector is scaled
* @param symbol_1: the first symbol to add
* @param symbol_2: the second symbol to add (the scaled one)
* @param coef: the coefficient of the scaling
* @param symbol_size: size of the two symbols (of the same size!)
* @return: a new vector of `symbol_size` byte containing the result of symbol_1 + symbol_2 * coef in GF(256)
*/
uint8_t *gf256_add_two_vectors_scaled(uint8_t *symbol_1, uint8_t *symbol_2, uint8_t coef, uint32_t symbol_size);
/**
*
* Divide a vector in a Galois Field 25§ by a coefficient
* @param symbol: the symbol to add
* @param coef: the dividing coefficient
* @param symbol_size: size of the two symbols (of the same size!)
* @return: a new vector of `symbol_size` byte containing the result of symbol_1 / coef
*/
uint8_t *gf256_divide_vector_scaled(uint8_t *symbol, uint8_t coef, uint32_t symbol_size);
/**
*
* Resolve the linear system Ax=b in a Galois Field 256. The result is stored in the independent terms after the resolution
* @param A: matrix of coefficients
* @param b: independent terms
* @param symbol_size: size of the independent terms
* @param system_size: the size of the system (i.e., number of rows/columns)
*/
void gf256_gaussian_elimination(uint8_t **A, uint8_t **b, uint32_t symbol_size, uint32_t system_size);
/**
*
* Generate all coefficients for a block
* @param seed: the seed to generate the coefficients
* @param nss: number of source symbols in a block
* @param nrs: number of repair symbols in a block
* @return: a nss * nrs array of coefficients
*/
uint8_t **gen_coef(uint32_t seed, uint32_t nss, uint32_t nrs);
#endif /* SYSTEM_H */ #endif /* SYSTEM_H */
\ No newline at end of file
...@@ -142,19 +142,19 @@ int main(int argc, char *argv[]) ...@@ -142,19 +142,19 @@ int main(int argc, char *argv[])
// You may modify or delete the following lines. This is just an example of how to use tinymt32 // You may modify or delete the following lines. This is just an example of how to use tinymt32
uint32_t seed = 42; // Replace with the seed from the instance file! uint32_t seed = 42; // Replace with the seed from the instance file!
tinymt32_t prng; tinymt32_t prng;
memset(&prng, 0, sizeof(tinymt32_t)); memset(&prng, 0, sizeof(tinymt32_t));
// Do not modify these values! // Do not modify these values!
prng.mat1 = 0x8f7011ee; prng.mat1 = 0x8f7011ee;
prng.mat2 = 0xfc78ff1f; prng.mat2 = 0xfc78ff1f;
prng.tmat = 0x3793fdff; prng.tmat = 0x3793fdff;
tinymt32_init(&prng, seed); tinymt32_init(&prng, seed);
// You can generate coefficients by calling this function // You can generate coefficients by calling this function
// Do not forget that we use byte values, so we have to // Do not forget that we use byte values, so we have to
// cast the uint32_t returned value to only keep the last 8 bits. // cast the uint32_t returned value to only keep the last 8 bits.
uint8_t coef = (uint8_t)tinymt32_generate_uint32(&prng); uint8_t coef = (uint8_t)tinymt32_generate_uint32(&prng);
if (args.verbose) if (args.verbose)
{ {
printf("Coefficient: %u\n", coef); printf("Coefficient: %u\n", coef);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter