From 1a2398444c81ac3842bf5c855ca19b02165e9e94 Mon Sep 17 00:00:00 2001 From: Mysaa Date: Tue, 2 Mar 2021 20:14:36 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20tests=20avec=20des=20matrices=20g?= =?UTF-8?q?=C3=A9n=C3=A9r=C3=A9es=20al=C3=A9atoirement.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Maths.ml | 7 +++++++ Test.ml | 20 ++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Maths.ml b/Maths.ml index b9ab12e..e122d67 100644 --- a/Maths.ml +++ b/Maths.ml @@ -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 [];; diff --git a/Test.ml b/Test.ml index 367b64b..ebc6c80 100644 --- a/Test.ml +++ b/Test.ml @@ -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);;