Ajout de tests avec des matrices générées aléatoirement.

This commit is contained in:
Mysaa 2021-03-02 20:14:36 +01:00
parent 45d648bcd7
commit 1a2398444c
2 changed files with 23 additions and 4 deletions

View File

@ -67,3 +67,10 @@ let respecter y cs =
List.fold_right (fun c b -> b && (land) c ny > 0) cs true
;;
(* Sort une matrice binaire au hazard *)
let matriceAuPif l h =
let filtre = (deux_puissance (h+1))-1 in
let rec aux l h tmp = match l with
| 0 -> tmp
| l -> aux (l-1) h (((Random.bits ()) land filtre)::tmp)
in aux l h [];;

20
Test.ml
View File

@ -28,14 +28,26 @@ respecter 7 [3];;
let code_hamming =
construire_code_lineaire_systematique 4 7 [7; 3; 5; 6]
;;
let code_paparfait =
construire_code_lineaire_systematique
print_vecteur 6 (encoder code_hamming 6);;
distance_minimale code_paparfait;;
exception GTROUVE of matrice;;
for i=0 to 200000
do
Random.self_init ();
let matPapa = matriceAuPif 9 12 in
let code_paparfait = construire_code_lineaire_systematique 12 21 matPapa in
let dst = distance_minimale code_paparfait in
if dst>1
then raise (GTROUVE matPapa)
done;;
print_vecteur 21 (encoder code_paparfait 0b011011011001);;
print_matrice 3 (suivants 3 (suivants 3 (suivants 3 (suivants 3 [0b000]))));;
distance_minimale code_hamming;;
print_vecteur 7 (encoder code_hamming 0b0100);;