Ajout de tests avec des matrices générées aléatoirement.
This commit is contained in:
parent
45d648bcd7
commit
1a2398444c
7
Maths.ml
7
Maths.ml
@ -67,3 +67,10 @@ let respecter y cs =
|
|||||||
List.fold_right (fun c b -> b && (land) c ny > 0) cs true
|
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
20
Test.ml
@ -28,14 +28,26 @@ respecter 7 [3];;
|
|||||||
let code_hamming =
|
let code_hamming =
|
||||||
construire_code_lineaire_systematique 4 7 [7; 3; 5; 6]
|
construire_code_lineaire_systematique 4 7 [7; 3; 5; 6]
|
||||||
;;
|
;;
|
||||||
let code_paparfait =
|
|
||||||
construire_code_lineaire_systematique
|
distance_minimale code_paparfait;;
|
||||||
print_vecteur 6 (encoder code_hamming 6);;
|
|
||||||
|
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]))));;
|
print_matrice 3 (suivants 3 (suivants 3 (suivants 3 (suivants 3 [0b000]))));;
|
||||||
|
|
||||||
distance_minimale code_hamming;;
|
|
||||||
|
|
||||||
|
|
||||||
print_vecteur 7 (encoder code_hamming 0b0100);;
|
print_vecteur 7 (encoder code_hamming 0b0100);;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user