Nouvel algorithme de décodage avec enregistrement dans un dictionnaire des syndromes
Fin de la rédaction du dossier (manque encore des finitions)
This commit is contained in:
parent
2c825f16a8
commit
36875fc40a
35
Code.ml
35
Code.ml
@ -22,8 +22,8 @@
|
||||
* on représente un vecteur dans F_2 par un entier dont la décomposition binaire correspond aux composantes du vecteur
|
||||
* on représente une matrice par un liste d'entier, il s'agit de la liste de ses colonnes (qui sont donc des vecteurs)
|
||||
|
||||
*)
|
||||
(*
|
||||
|
||||
|
||||
#cd "/home/mysaa/Documents/Arbeiten/TIPE2021/";;
|
||||
#load "Math.cmo";;
|
||||
*)
|
||||
@ -132,6 +132,37 @@ let decoder code z =
|
||||
;;
|
||||
|
||||
|
||||
(*** Décodage avec stockage des syndromes ***)
|
||||
|
||||
(* syndr est une fonction qui à un vecteur associe son syndrome.
|
||||
En effet, la notion de syndrome dépend de quelle matrice H nous avons choisi.
|
||||
Créer cette fonction ici permet de ne plus dépendre de la matrice H de code_lineaire *)
|
||||
type classesLaterales = {syndr : Math.vecteur -> Math.vecteur;
|
||||
erreur : Math.vecteur -> Math.vecteur;
|
||||
babr : Math.vecteur Math.binabr};;
|
||||
|
||||
|
||||
let genererClasses code =
|
||||
let syndr = function z -> Math.produit code.h z in
|
||||
let compacteur babr v = if BFeuille<>babr && not (appartenir code v)
|
||||
then (print_int v;putWho babr (syndr v)) v false
|
||||
else BFeuille in
|
||||
let rec iter babr0 lst =
|
||||
let svts = suivants code.n lst in
|
||||
let babr = List.fold_left compacteur babr0 svts in
|
||||
if babr<>BFeuille
|
||||
then iter babr svts
|
||||
else babr0 (*On a dépassé la capacité de correction*)
|
||||
in
|
||||
let babr = iter (put BFeuille 0 0) [0] in
|
||||
let erreur = function z -> get babr z
|
||||
in {syndr=syndr;erreur=erreur;babr=babr}
|
||||
;;
|
||||
|
||||
let decoder2 classes z :vecteur=
|
||||
let s = classes.syndr z in
|
||||
let e = classes.erreur s in
|
||||
z lxor e;;
|
||||
end;;
|
||||
|
||||
(*************************************************************)
|
||||
|
||||
14
Code.mli
14
Code.mli
@ -6,12 +6,22 @@ type t = {
|
||||
g : Math.matrice;
|
||||
h : Math.matrice; }
|
||||
type code_lineaire = t
|
||||
exception PasDansLeCodeException
|
||||
|
||||
val encoder : code_lineaire -> Math.vecteur -> Math.vecteur
|
||||
val systematiqueFromRedondance : int -> int -> matrice -> code_lineaire
|
||||
val systematiqueFromRedondance : int -> int -> Math.matrice -> code_lineaire
|
||||
val distance_minimale : code_lineaire -> int
|
||||
val decoder : code_lineaire -> int -> Math.vecteur
|
||||
val decoder : code_lineaire -> Math.vecteur -> Math.vecteur
|
||||
val appartenir : code_lineaire -> Math.vecteur -> bool
|
||||
|
||||
type classesLaterales = {
|
||||
syndr : Math.vecteur -> Math.vecteur;
|
||||
erreur : Math.vecteur -> Math.vecteur;
|
||||
babr : Math.vecteur Math.binabr;
|
||||
}
|
||||
val genererClasses : t -> classesLaterales
|
||||
val decoder2 : classesLaterales -> Math.vecteur -> Math.vecteur
|
||||
|
||||
end
|
||||
|
||||
module CCyclique :
|
||||
|
||||
1
CompteRendu/.gitignore
vendored
1
CompteRendu/.gitignore
vendored
@ -6,3 +6,4 @@
|
||||
*.toc
|
||||
*.thm
|
||||
svg-inkscape/
|
||||
print_output_path.svg
|
||||
|
||||
@ -123,6 +123,7 @@
|
||||
|
||||
$$d_C \leqslant n+1-k$$
|
||||
|
||||
Enfin, on peut utiliser que la distance minimale d'un code linéaire est le nombre minimal de colonnes linéairement dépendantes de la matrice de contrôle $H$.
|
||||
\end{theoreme}
|
||||
|
||||
Voici ici quelques concepts qui seront utiles au décodage.
|
||||
@ -149,11 +150,10 @@
|
||||
On définit le mot binaire associé au polynôme $P=\displaystyle\sum_{i=0}^{n-1}{a_i\cdotp X^i}$ comme étant le mot $a_0a_1\cdots a_{n-1}$. Le polynôme réciproquement associé à un mot binaire par ce procédé est appelé \textbf{représentation polynomiale} du mot.
|
||||
\end{definition}
|
||||
|
||||
\begin{definition}[Polynôme générateur]
|
||||
Un polynôme $P$ de $\FD\,[X]$ de degré $n-k$ est dit \textbf{générateur du code cyclique $C$ de paramètre $(k,n)$} lorsque $P | X^n + 1$ et que $(\sigma^i(w))_{i\in \llbracket 0,k-1\rrbracket}$ est une base de $C$ avec $\sigma$ l'opérateur de décalage binaire cyclique est $w$ le mot associé à $P$
|
||||
\end{definition}
|
||||
\begin{theoreme}[Théorème fondamental des codes cycliques]
|
||||
Tout code cyclique admet un et un seul polynôme générateur.
|
||||
Pour tout code cyclique $C$ de paramètres $(n,k)$, il existe un unique polynôme $g$ tel que le mot associé à $g$ engendre $C$ et que $g|X^n-1$. Ce polynôme est alors appelé \textbf{polynôme générateur du code cyclique $C$}.
|
||||
|
||||
On démontre que ce $g$ est alors de degré $n-k$ et que $(\sigma^i(w))_{i\in \llbracket 0,k-1\rrbracket}$ est une base de $C$ avec $\sigma$ l'opérateur de décalage binaire cyclique est $w$ le mot associé à $y$
|
||||
\end{theoreme}
|
||||
|
||||
\begin{remarque}
|
||||
@ -211,20 +211,25 @@
|
||||
|
||||
Nous avons ensuite écrit des fonctions permettant de manipuler les codes linéaires:
|
||||
\begin{itemize}
|
||||
\fsign{encoder}{code\_lineaire \into Math.vecteur \into Math.vecteur}{}
|
||||
\fsign{encoder}{code\_lineaire \into vecteur \into vecteur}{k}
|
||||
Encode le vecteur de $\FD^k$ suivant le code linéaire spécifié, il s'agit alors d'un simple produit avec la matrice génératrice.
|
||||
\fsign{appartenir}{code_lineaire -> Math.vecteur -> bool}
|
||||
\fsign{appartenir}{code\_lineaire -> vecteur -> bool}{n}
|
||||
Renvoie \textit{vrai} si et seulement si le vecteur appartient au code, c'est à dire, si et seulement si $HX=0$ avec $H$ la matrice de contrôle et $X$ le vecteur de $\FD^n$ en question.
|
||||
\fsign{distance\_minimale}{code\_lineaire -> int}{}
|
||||
Renvoie la distance minimale du code, utilisée pour calculer les capacités de détéction et de correction du code (voir \ref{thCapacité})
|
||||
\fsign{decoder}{code\_lineaire \into int \into Math.vecteur}{}
|
||||
\fsign{distance\_minimale}{code\_lineaire -> int}{non}
|
||||
Renvoie la distance minimale du code, utilisée pour calculer les capacités de détéction et de correction du code (voir \ref{thCapacité}). Le calcul s'effectue en recherchant le plus petit mot (au sens du poids) qui soit dans le code.
|
||||
\fsign{decoder}{code\_lineaire \into vecteur \into Math.vecteur}{euhhhhhhhh}
|
||||
Décode le mot de $\FD^n$ donné. L'algorithme recherche le mot le plus proche du mot recu qui soit dans le code et à une distance inferieure à la distance de correction. Si il est impossible de décoder, renvoie une exception du type \verb|IndecodableException|.
|
||||
|
||||
\fsign{genererClasses}{code\_cyclique \into classes\_latérales}{well ...}Génère les classes latérales associées au code spécifié. Parcours les vecteurs par poids croissant (d'abord ceux de poids 1, puis 2, etc…) et référence leur syndrome dans \verb|classes.rpz : vecteur -> vecteur| qui à un syndrome associe le représentant de la classe latérale de poids le plus faible.
|
||||
|
||||
\fsign{decoder2}{classes\_latérales \into vecteur \into vecteur}{n\cdot \ln(n)} Décode le mot $Z$ de $\FD^n$ donné. L'algorithme calcule le syndrome du mot, obtient le représentant de la classe latérale associée à ce vecteur $E$. Dans l'hypothèse où le mot reçu est effectivement décodable, alors, son «erreur» $E = Z-Y$, avec $Y$ le mot du code initialement envoyé, a la même classe latérale que $Z$. Donc $Y = Z+E$, on obtient un mot du code que l'on peut décoder.
|
||||
\end{itemize}
|
||||
|
||||
\part*{Annexes}
|
||||
\begin{figure}[h]
|
||||
\begin{center}
|
||||
\label{print_matriceExemple}
|
||||
\includesvg[scale=.3]{print_output.svg}
|
||||
\includesvg[scale=.3]{print_output_path.svg}
|
||||
\caption{Exemple d'affichage de vecteur,matrice et polynômes}
|
||||
\end{center}
|
||||
\end{figure}
|
||||
|
||||
@ -25,9 +25,9 @@
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="1.979899"
|
||||
inkscape:cx="10.04794"
|
||||
inkscape:cy="216.89603"
|
||||
inkscape:zoom="0.35"
|
||||
inkscape:cx="-109.9148"
|
||||
inkscape:cy="-17.849234"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
@ -48,7 +48,7 @@
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
@ -58,120 +58,178 @@
|
||||
id="layer1"
|
||||
transform="translate(-0.53453934,-1.3999026)">
|
||||
<rect
|
||||
style="opacity:1;fill:#686868;fill-opacity:1;stroke:none;stroke-width:1.76637125;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
style="opacity:1;fill:#686868;fill-opacity:1;stroke:none;stroke-width:3.70219326;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="rect827"
|
||||
width="66.282837"
|
||||
height="117.06406"
|
||||
x="0.53453934"
|
||||
y="1.3999026" />
|
||||
<g
|
||||
aria-label="┌011┐
|
||||
│101│
|
||||
│111│
|
||||
│100│
|
||||
└001┘"
|
||||
style="font-style:normal;font-weight:normal;font-size:17.08358955px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="text12">
|
||||
<path
|
||||
d="m 12.454936,16.851757 h 5.980925 v 1.434754 h -4.646269 v 9.576153 h -1.334656 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path822" />
|
||||
<path
|
||||
d="m 23.399111,23.683524 q -2.001983,0 -3.011317,-1.634953 -1.017674,-1.643294 -1.017674,-4.821442 0,-3.18649 1.017674,-4.829785 1.009334,-1.634953 3.011317,-1.634953 2.001983,0 3.019658,1.634953 0.500495,0.800794 0.759085,2.001983 0.258589,1.192849 0.258589,2.827802 0,1.634953 -0.258589,2.827801 -0.25859,1.192848 -0.759085,1.993641 -1.026017,1.634953 -3.019658,1.634953 z m 0,-1.334655 q 1.192848,0 1.768418,-1.267923 0.57557,-1.267922 0.57557,-3.853817 0,-2.602578 -0.57557,-3.853818 -0.57557,-1.276264 -1.768418,-1.276264 -1.176165,0 -1.751735,1.267922 -0.291956,0.62562 -0.442105,1.576562 -0.141807,0.942601 -0.141807,2.285598 0,2.610919 0.583912,3.853817 0.583911,1.267923 1.751735,1.267923 z m 0.01668,-2.210523 q -0.25859,0 -0.408738,-0.358689 -0.150149,-0.358689 -0.250248,-0.842501 -0.08342,-0.392055 -0.141807,-0.925917 -0.05005,-0.542204 -0.05005,-0.825818 0,-0.200199 0.03337,-0.717378 0.03337,-0.517179 0.133465,-0.975966 0.241906,-1.192849 0.650645,-1.192849 0.233564,0 0.392055,0.316981 0.166832,0.316981 0.283614,0.900892 0.08342,0.408739 0.133465,0.925918 0.05005,0.517179 0.05005,0.809134 0,0.166832 -0.03337,0.658987 -0.02502,0.492154 -0.108441,1.009333 -0.20854,1.217873 -0.684011,1.217873 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path824" />
|
||||
<path
|
||||
d="m 30.789765,22.023547 h 2.619262 v -8.93385 l -1.9853,2.260572 -0.917576,-1.117774 2.886192,-3.244881 h 1.685003 v 11.035933 h 2.585895 v 1.418071 h -6.873476 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path826" />
|
||||
<path
|
||||
d="m 41.066611,22.023547 h 2.619262 v -8.93385 l -1.9853,2.260572 -0.917576,-1.117774 2.886192,-3.244881 h 1.685003 v 11.035933 h 2.585895 v 1.418071 h -6.873476 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path828" />
|
||||
<path
|
||||
d="m 53.562324,18.286511 h -4.637928 v -1.434754 h 5.972583 v 11.010907 h -1.334655 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path830" />
|
||||
<path
|
||||
d="m 12.454936,28.529992 h 1.334656 v 20.687159 h -1.334656 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path832" />
|
||||
<path
|
||||
d="m 20.512918,43.378034 h 2.619262 v -8.93385 l -1.9853,2.260572 -0.917576,-1.117774 2.886192,-3.244881 h 1.685003 v 11.035933 h 2.585895 v 1.418071 h -6.873476 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path834" />
|
||||
<path
|
||||
d="m 33.675958,45.038011 q -2.001983,0 -3.011317,-1.634953 -1.017674,-1.643294 -1.017674,-4.821442 0,-3.18649 1.017674,-4.829785 1.009334,-1.634953 3.011317,-1.634953 2.001983,0 3.019658,1.634953 0.500495,0.800793 0.759085,2.001983 0.258589,1.192849 0.258589,2.827802 0,1.634952 -0.258589,2.827801 -0.25859,1.192848 -0.759085,1.993641 -1.026017,1.634953 -3.019658,1.634953 z m 0,-1.334655 q 1.192848,0 1.768418,-1.267923 0.57557,-1.267923 0.57557,-3.853817 0,-2.602579 -0.57557,-3.853818 -0.57557,-1.276264 -1.768418,-1.276264 -1.176165,0 -1.751736,1.267922 -0.291955,0.62562 -0.442104,1.576562 -0.141807,0.942601 -0.141807,2.285598 0,2.610919 0.583911,3.853817 0.583912,1.267923 1.751736,1.267923 z m 0.01668,-2.210523 q -0.25859,0 -0.408738,-0.358689 -0.150149,-0.358689 -0.250248,-0.842501 -0.08342,-0.392055 -0.141807,-0.925917 -0.05005,-0.542204 -0.05005,-0.825818 0,-0.200199 0.03337,-0.717378 0.03337,-0.517179 0.133466,-0.975967 0.241906,-1.192848 0.650644,-1.192848 0.233565,0 0.392055,0.316981 0.166832,0.316981 0.283615,0.900892 0.08342,0.408738 0.133465,0.925917 0.05005,0.517179 0.05005,0.809135 0,0.166832 -0.03337,0.658986 -0.02502,0.492155 -0.108441,1.009334 -0.20854,1.217873 -0.684011,1.217873 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path836" />
|
||||
<path
|
||||
d="m 41.066611,43.378034 h 2.619262 v -8.93385 l -1.9853,2.260572 -0.917576,-1.117774 2.886192,-3.244881 h 1.685003 v 11.035933 h 2.585895 v 1.418071 h -6.873476 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path838" />
|
||||
<path
|
||||
d="m 53.562324,28.529992 h 1.334655 v 20.687159 h -1.334655 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path840" />
|
||||
<path
|
||||
d="m 12.454936,49.884479 h 1.334656 v 20.687159 h -1.334656 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path842" />
|
||||
<path
|
||||
d="m 20.512918,64.73252 h 2.619262 v -8.933849 l -1.9853,2.260572 -0.917576,-1.117774 2.886192,-3.244881 h 1.685003 V 64.73252 h 2.585895 v 1.418072 h -6.873476 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path844" />
|
||||
<path
|
||||
d="m 30.789765,64.73252 h 2.619262 v -8.933849 l -1.9853,2.260572 -0.917576,-1.117774 2.886192,-3.244881 h 1.685003 V 64.73252 h 2.585895 v 1.418072 h -6.873476 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path846" />
|
||||
<path
|
||||
d="m 41.066611,64.73252 h 2.619262 v -8.933849 l -1.9853,2.260572 -0.917576,-1.117774 2.886192,-3.244881 h 1.685003 V 64.73252 h 2.585895 v 1.418072 h -6.873476 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path848" />
|
||||
<path
|
||||
d="m 53.562324,49.884479 h 1.334655 v 20.687159 h -1.334655 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path850" />
|
||||
<path
|
||||
d="m 12.454936,71.238966 h 1.334656 v 20.687159 h -1.334656 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path852" />
|
||||
<path
|
||||
d="m 20.512918,86.087007 h 2.619262 v -8.933849 l -1.9853,2.260572 -0.917576,-1.117774 2.886192,-3.244881 h 1.685003 v 11.035932 h 2.585895 v 1.418072 h -6.873476 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path854" />
|
||||
<path
|
||||
d="m 33.675958,87.746985 q -2.001983,0 -3.011317,-1.634953 -1.017674,-1.643294 -1.017674,-4.821443 0,-3.186489 1.017674,-4.829784 1.009334,-1.634953 3.011317,-1.634953 2.001983,0 3.019658,1.634953 0.500495,0.800793 0.759085,2.001983 0.258589,1.192849 0.258589,2.827801 0,1.634953 -0.258589,2.827802 -0.25859,1.192848 -0.759085,1.993641 -1.026017,1.634953 -3.019658,1.634953 z m 0,-1.334655 q 1.192848,0 1.768418,-1.267923 0.57557,-1.267923 0.57557,-3.853818 0,-2.602578 -0.57557,-3.853817 -0.57557,-1.276264 -1.768418,-1.276264 -1.176165,0 -1.751736,1.267922 -0.291955,0.62562 -0.442104,1.576562 -0.141807,0.9426 -0.141807,2.285597 0,2.61092 0.583911,3.853818 0.583912,1.267923 1.751736,1.267923 z m 0.01668,-2.210523 q -0.25859,0 -0.408738,-0.358689 -0.150149,-0.358689 -0.250248,-0.842501 -0.08342,-0.392055 -0.141807,-0.925918 -0.05005,-0.542203 -0.05005,-0.825818 0,-0.200198 0.03337,-0.717377 0.03337,-0.517179 0.133466,-0.975967 0.241906,-1.192848 0.650644,-1.192848 0.233565,0 0.392055,0.316981 0.166832,0.31698 0.283615,0.900892 0.08342,0.408738 0.133465,0.925917 0.05005,0.517179 0.05005,0.809135 0,0.166832 -0.03337,0.658986 -0.02502,0.492155 -0.108441,1.009334 -0.20854,1.217873 -0.684011,1.217873 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path856" />
|
||||
<path
|
||||
d="m 43.952804,87.746985 q -2.001984,0 -3.011317,-1.634953 -1.017675,-1.643294 -1.017675,-4.821443 0,-3.186489 1.017675,-4.829784 1.009333,-1.634953 3.011317,-1.634953 2.001983,0 3.019658,1.634953 0.500495,0.800793 0.759085,2.001983 0.258589,1.192849 0.258589,2.827801 0,1.634953 -0.258589,2.827802 -0.25859,1.192848 -0.759085,1.993641 -1.026017,1.634953 -3.019658,1.634953 z m 0,-1.334655 q 1.192848,0 1.768418,-1.267923 0.57557,-1.267923 0.57557,-3.853818 0,-2.602578 -0.57557,-3.853817 -0.57557,-1.276264 -1.768418,-1.276264 -1.176166,0 -1.751736,1.267922 -0.291956,0.62562 -0.442104,1.576562 -0.141807,0.9426 -0.141807,2.285597 0,2.61092 0.583911,3.853818 0.583912,1.267923 1.751736,1.267923 z m 0.01668,-2.210523 q -0.25859,0 -0.408738,-0.358689 -0.150149,-0.358689 -0.250248,-0.842501 -0.08342,-0.392055 -0.141807,-0.925918 -0.05005,-0.542203 -0.05005,-0.825818 0,-0.200198 0.03337,-0.717377 0.03337,-0.517179 0.133466,-0.975967 0.241906,-1.192848 0.650644,-1.192848 0.233565,0 0.392055,0.316981 0.166832,0.31698 0.283615,0.900892 0.08342,0.408738 0.133465,0.925917 0.05005,0.517179 0.05005,0.809135 0,0.166832 -0.03337,0.658986 -0.02502,0.492155 -0.10844,1.009334 -0.20854,1.217873 -0.684011,1.217873 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path858" />
|
||||
<path
|
||||
d="m 53.562324,71.238966 h 1.334655 v 20.687159 h -1.334655 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path860" />
|
||||
<path
|
||||
d="m 12.454936,92.593453 h 1.334656 v 9.676247 h 4.646269 v 1.43476 h -5.980925 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path862" />
|
||||
<path
|
||||
d="m 23.399111,109.10147 q -2.001983,0 -3.011317,-1.63495 -1.017674,-1.6433 -1.017674,-4.82144 0,-3.186493 1.017674,-4.829788 1.009334,-1.634953 3.011317,-1.634953 2.001983,0 3.019658,1.634953 0.500495,0.800793 0.759085,2.001983 0.258589,1.192845 0.258589,2.827805 0,1.63495 -0.258589,2.8278 -0.25859,1.19285 -0.759085,1.99364 -1.026017,1.63495 -3.019658,1.63495 z m 0,-1.33465 q 1.192848,0 1.768418,-1.26793 0.57557,-1.26792 0.57557,-3.85381 0,-2.60258 -0.57557,-3.853821 -0.57557,-1.276264 -1.768418,-1.276264 -1.176165,0 -1.751735,1.267922 -0.291956,0.62562 -0.442105,1.576563 -0.141807,0.9426 -0.141807,2.2856 0,2.61092 0.583912,3.85381 0.583911,1.26793 1.751735,1.26793 z m 0.01668,-2.21053 q -0.25859,0 -0.408738,-0.35869 -0.150149,-0.35868 -0.250248,-0.8425 -0.08342,-0.39205 -0.141807,-0.92591 -0.05005,-0.54221 -0.05005,-0.82582 0,-0.2002 0.03337,-0.71738 0.03337,-0.51718 0.133465,-0.97597 0.241906,-1.192844 0.650645,-1.192844 0.233564,0 0.392055,0.316984 0.166832,0.31698 0.283614,0.90089 0.08342,0.40874 0.133465,0.92592 0.05005,0.51718 0.05005,0.80913 0,0.16683 -0.03337,0.65899 -0.02502,0.49215 -0.108441,1.00933 -0.20854,1.21787 -0.684011,1.21787 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path864" />
|
||||
<path
|
||||
d="m 33.675958,109.10147 q -2.001983,0 -3.011317,-1.63495 -1.017674,-1.6433 -1.017674,-4.82144 0,-3.186493 1.017674,-4.829788 1.009334,-1.634953 3.011317,-1.634953 2.001983,0 3.019658,1.634953 0.500495,0.800793 0.759085,2.001983 0.258589,1.192845 0.258589,2.827805 0,1.63495 -0.258589,2.8278 -0.25859,1.19285 -0.759085,1.99364 -1.026017,1.63495 -3.019658,1.63495 z m 0,-1.33465 q 1.192848,0 1.768418,-1.26793 0.57557,-1.26792 0.57557,-3.85381 0,-2.60258 -0.57557,-3.853821 -0.57557,-1.276264 -1.768418,-1.276264 -1.176165,0 -1.751736,1.267922 -0.291955,0.62562 -0.442104,1.576563 -0.141807,0.9426 -0.141807,2.2856 0,2.61092 0.583911,3.85381 0.583912,1.26793 1.751736,1.26793 z m 0.01668,-2.21053 q -0.25859,0 -0.408738,-0.35869 -0.150149,-0.35868 -0.250248,-0.8425 -0.08342,-0.39205 -0.141807,-0.92591 -0.05005,-0.54221 -0.05005,-0.82582 0,-0.2002 0.03337,-0.71738 0.03337,-0.51718 0.133466,-0.97597 0.241906,-1.192844 0.650644,-1.192844 0.233565,0 0.392055,0.316984 0.166832,0.31698 0.283615,0.90089 0.08342,0.40874 0.133465,0.92592 0.05005,0.51718 0.05005,0.80913 0,0.16683 -0.03337,0.65899 -0.02502,0.49215 -0.108441,1.00933 -0.20854,1.21787 -0.684011,1.21787 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path866" />
|
||||
<path
|
||||
d="m 41.066611,107.44149 h 2.619262 v -8.933845 l -1.9853,2.260575 -0.917576,-1.117777 2.886192,-3.244881 h 1.685003 v 11.035928 h 2.585895 v 1.41808 h -6.873476 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path868" />
|
||||
<path
|
||||
d="m 48.924396,102.2697 h 4.637928 v -9.676247 h 1.334655 v 11.111007 h -5.972583 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;fill:#00f829;fill-opacity:1;stroke:none;stroke-width:0.42708972;stroke-opacity:1"
|
||||
id="path870" />
|
||||
</g>
|
||||
width="256.40485"
|
||||
height="132.93906"
|
||||
x="-1.7333201"
|
||||
y="-5.4036703" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:13.04045963px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.32601148"
|
||||
x="2.3512421"
|
||||
y="89.607773"
|
||||
id="text841"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan839"
|
||||
x="2.3512421"
|
||||
y="89.607773"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.11111069px;line-height:1;font-family:Hack;-inkscape-font-specification:Hack;fill:#09ff26;fill-opacity:1;stroke-width:0.32601148">X^1 + X^2 + X^3</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="2.3512421"
|
||||
y="105.90835"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.11111069px;line-height:1;font-family:Hack;-inkscape-font-specification:Hack;fill:#09ff26;fill-opacity:1;stroke-width:0.32601148"
|
||||
id="tspan843">1 + X^2</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="2.3512421"
|
||||
y="122.20892"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.11111069px;line-height:1;font-family:Hack;-inkscape-font-specification:Hack;fill:#09ff26;fill-opacity:1;stroke-width:0.32601148"
|
||||
id="tspan845">1 + X^1 + X^4 + X^6 + X^9</tspan></text>
|
||||
<flowRoot
|
||||
xml:space="preserve"
|
||||
id="flowRoot847"
|
||||
style="fill:black;fill-opacity:1;stroke:none;font-family:sans-serif;font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;letter-spacing:0px;word-spacing:0px"><flowRegion
|
||||
id="flowRegion849"><rect
|
||||
id="rect851"
|
||||
width="137.14285"
|
||||
height="50"
|
||||
x="291.42856"
|
||||
y="16.732544" /></flowRegion><flowPara
|
||||
id="flowPara853"></flowPara></flowRoot> <text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:13.04045963px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.32601148"
|
||||
x="151.86282"
|
||||
y="13.561927"
|
||||
id="text841-2"><tspan
|
||||
sodipodi:role="line"
|
||||
x="151.86282"
|
||||
y="13.561927"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.11111069px;line-height:1;font-family:Hack;-inkscape-font-specification:Hack;fill:#09ff26;fill-opacity:1;stroke-width:0.32601148"
|
||||
id="tspan845-9">┌011┐</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="151.86282"
|
||||
y="29.862503"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.11111069px;line-height:1;font-family:Hack;-inkscape-font-specification:Hack;fill:#09ff26;fill-opacity:1;stroke-width:0.32601148"
|
||||
id="tspan883">│101│</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="151.86282"
|
||||
y="46.163078"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.11111069px;line-height:1;font-family:Hack;-inkscape-font-specification:Hack;fill:#09ff26;fill-opacity:1;stroke-width:0.32601148"
|
||||
id="tspan885">│111│</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="151.86282"
|
||||
y="62.463654"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.11111069px;line-height:1;font-family:Hack;-inkscape-font-specification:Hack;fill:#09ff26;fill-opacity:1;stroke-width:0.32601148"
|
||||
id="tspan887">│100│</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="151.86282"
|
||||
y="78.764229"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.11111069px;line-height:1;font-family:Hack;-inkscape-font-specification:Hack;fill:#09ff26;fill-opacity:1;stroke-width:0.32601148"
|
||||
id="tspan889">└001┘</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:11.29124641px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.28228116"
|
||||
x="222.2482"
|
||||
y="9.1106415"
|
||||
id="text841-2-7"><tspan
|
||||
sodipodi:role="line"
|
||||
x="222.2482"
|
||||
y="9.1106415"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12.21828365px;line-height:1;font-family:Hack;-inkscape-font-specification:Hack;fill:#09ff26;fill-opacity:1;stroke-width:0.28228116"
|
||||
id="tspan889-0">┌1┐</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="222.2482"
|
||||
y="23.224701"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12.21828365px;line-height:1;font-family:Hack;-inkscape-font-specification:Hack;fill:#09ff26;fill-opacity:1;stroke-width:0.28228116"
|
||||
id="tspan981">│1│</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="222.2482"
|
||||
y="37.338757"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12.21828365px;line-height:1;font-family:Hack;-inkscape-font-specification:Hack;fill:#09ff26;fill-opacity:1;stroke-width:0.28228116"
|
||||
id="tspan983">│0│</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="222.2482"
|
||||
y="51.452816"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12.21828365px;line-height:1;font-family:Hack;-inkscape-font-specification:Hack;fill:#09ff26;fill-opacity:1;stroke-width:0.28228116"
|
||||
id="tspan985">│1│</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="222.2482"
|
||||
y="65.566872"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12.21828365px;line-height:1;font-family:Hack;-inkscape-font-specification:Hack;fill:#09ff26;fill-opacity:1;stroke-width:0.28228116"
|
||||
id="tspan987">│0│</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="222.2482"
|
||||
y="79.680931"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12.21828365px;line-height:1;font-family:Hack;-inkscape-font-specification:Hack;fill:#09ff26;fill-opacity:1;stroke-width:0.28228116"
|
||||
id="tspan989">│0│</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="222.2482"
|
||||
y="93.794983"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12.21828365px;line-height:1;font-family:Hack;-inkscape-font-specification:Hack;fill:#09ff26;fill-opacity:1;stroke-width:0.28228116"
|
||||
id="tspan991">│1│</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="222.2482"
|
||||
y="107.90904"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12.21828365px;line-height:1;font-family:Hack;-inkscape-font-specification:Hack;fill:#09ff26;fill-opacity:1;stroke-width:0.28228116"
|
||||
id="tspan993">│1│</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="222.2482"
|
||||
y="122.02309"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12.21828365px;line-height:1;font-family:Hack;-inkscape-font-specification:Hack;fill:#09ff26;fill-opacity:1;stroke-width:0.28228116"
|
||||
id="tspan995">└0┘</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:13.04045963px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.32601148"
|
||||
x="8.7948952"
|
||||
y="16.916115"
|
||||
id="text841-2-6"><tspan
|
||||
sodipodi:role="line"
|
||||
x="8.7948952"
|
||||
y="16.916115"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.11111069px;line-height:1;font-family:Hack;-inkscape-font-specification:Hack;fill:#09ff26;fill-opacity:1;stroke-width:0.32601148"
|
||||
id="tspan889-2">┌100101110┐</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="8.7948952"
|
||||
y="33.21669"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.11111069px;line-height:1;font-family:Hack;-inkscape-font-specification:Hack;fill:#09ff26;fill-opacity:1;stroke-width:0.32601148"
|
||||
id="tspan1011">│101011000│</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="8.7948952"
|
||||
y="49.517265"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.11111069px;line-height:1;font-family:Hack;-inkscape-font-specification:Hack;fill:#09ff26;fill-opacity:1;stroke-width:0.32601148"
|
||||
id="tspan1013">│011000000│</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="8.7948952"
|
||||
y="65.817833"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.11111069px;line-height:1;font-family:Hack;-inkscape-font-specification:Hack;fill:#09ff26;fill-opacity:1;stroke-width:0.32601148"
|
||||
id="tspan1015">└101011001┘</tspan></text>
|
||||
<rect
|
||||
style="opacity:1;fill:#09ff26;fill-opacity:1;stroke:none;stroke-width:1.14285779;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="rect1019"
|
||||
width="146.68878"
|
||||
height="1"
|
||||
x="-1.7673719"
|
||||
y="71.728836" />
|
||||
<rect
|
||||
style="opacity:1;fill:#09ff26;fill-opacity:1;stroke:none;stroke-width:1.1620723;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="rect1021"
|
||||
width="75.831482"
|
||||
height="1"
|
||||
x="144.16548"
|
||||
y="92.517525" />
|
||||
<rect
|
||||
style="opacity:1;fill:#09ff26;fill-opacity:1;stroke:none;stroke-width:1.19583499;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="rect1023"
|
||||
width="1"
|
||||
height="132.93539"
|
||||
x="219.00478"
|
||||
y="-5.4000192" />
|
||||
<rect
|
||||
style="opacity:1;fill:#09ff26;fill-opacity:1;stroke:none;stroke-width:1.80716944;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="rect1025"
|
||||
width="1"
|
||||
height="21.788689"
|
||||
x="144.16548"
|
||||
y="71.728836" />
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 12 KiB |
10
Makefile
10
Makefile
@ -7,14 +7,12 @@ ascii: $(shell find textes/ -type f -iname "*.txt" ! -iname "*.ascii.txt" | sed
|
||||
%.cmx: %.ml
|
||||
ocamlopt -c $<
|
||||
|
||||
Code.cmo: Code.ml Math.cmo
|
||||
Code.cmo: Code.ml Code.mli Math.cmo
|
||||
ocamlc -c "Code.mli"
|
||||
ocamlc -c "Code.ml"
|
||||
%.cmi: %.mli
|
||||
ocamlc -c $<
|
||||
%.cmo: %.ml
|
||||
if [ -f $*".mli" ]; then ocamlc -c $*".mli" ; fi
|
||||
ocamlc -c $<
|
||||
Math.cmo: Math.ml Math.mli
|
||||
ocamlc -c Math.mli
|
||||
ocamlc -c Math.ml
|
||||
|
||||
tipe: tipe.cmx
|
||||
ocamlopt -o tipe str.cmxa tipe.cmx
|
||||
|
||||
43
Math.ml
43
Math.ml
@ -130,11 +130,44 @@ let poldiveuc (p:polynome) (q:polynome) : (polynome * polynome) =
|
||||
let poldiv (p:polynome) (q:polynome) : polynome = fst (poldiveuc p q);;
|
||||
let polrst (p:polynome) (q:polynome) : polynome = snd (poldiveuc p q);;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(***************** Arbres de recherche de 'vecteurs' *****************)
|
||||
type 'a binabr = BNoeud of 'a binabr * 'a binabr | BVal of 'a * 'a binabr | BFeuille;;
|
||||
|
||||
let isEmpty babr = babr=BFeuille;;(* Ne renvoie que les biens fondés, c'est à dire sans Noeud vide*)
|
||||
|
||||
exception NoSuchKeyException;;
|
||||
let rec get ba (k:vecteur) =
|
||||
match (ba,k) with
|
||||
| (BNoeud(_,_) ,0)
|
||||
| (BFeuille ,_) -> raise NoSuchKeyException
|
||||
| (BVal(v,rr) ,0) -> v
|
||||
| (BVal(v,rr) ,_) -> get rr k
|
||||
| (BNoeud(t0,t1),_) ->
|
||||
match k mod 2 with
|
||||
| 0 -> get t0 (k lsr 1)
|
||||
| 1 -> get t1 (k lsr 1)
|
||||
| _ -> failwith "Félicitations, vous avez cassé les maths";;
|
||||
|
||||
|
||||
let rec putWho ba (k:vecteur) v keepNew =
|
||||
match (ba,k) with
|
||||
| (BVal(old,rr) ,0) -> if keepNew then BVal(v,rr) else BVal(old,rr)
|
||||
| (BFeuille ,0)
|
||||
| (BNoeud(_,_) ,0) -> BVal(v,ba)
|
||||
| (BVal(o,rr) ,_) -> BVal(o,putWho rr k v keepNew)
|
||||
| (BFeuille ,_) -> putWho (BNoeud(BFeuille,BFeuille)) k v keepNew
|
||||
(*match k mod 2 with
|
||||
| 0 -> BNoeud(putWho BFeuille (k lsr 1) v keepNew, BFeuille)
|
||||
| 1 -> BNoeud(BFeuille, putWho BFeuille (k lsr 1) v keepNew)
|
||||
| _ -> failwith "Ich gratuliere Sie. Sie haben Mathe zerbrochen"
|
||||
end*)
|
||||
| (BNoeud(t0,t1),_) ->
|
||||
match k mod 2 with
|
||||
| 0 -> BNoeud(putWho t0 (k lsr 1) v keepNew, t1)
|
||||
| 1 -> BNoeud(t0, putWho t1 (k lsr 1) v keepNew)
|
||||
| _ -> failwith "99 7'4 c0mp1373m3n7 c4553 135 m47h5. 7u 73 23nd5 c0mp73 ?!";;
|
||||
|
||||
let put ba k v = putWho ba k v true;; (* Par défaut, on garde le nouveau *)
|
||||
|
||||
|
||||
|
||||
|
||||
8
Math.mli
8
Math.mli
@ -24,3 +24,11 @@ val polmul : polynome -> polynome -> polynome
|
||||
val poldiveuc : polynome -> polynome -> polynome * polynome
|
||||
val poldiv : polynome -> polynome -> polynome
|
||||
val polrst : polynome -> polynome -> polynome
|
||||
|
||||
|
||||
type 'a binabr = BNoeud of 'a binabr * 'a binabr | BVal of 'a * 'a binabr | BFeuille
|
||||
|
||||
exception NoSuchKeyException
|
||||
val get : 'a binabr -> vecteur -> 'a
|
||||
val putWho : 'a binabr -> vecteur -> 'a -> bool -> 'a binabr
|
||||
val put : 'a binabr -> vecteur -> 'a -> 'a binabr
|
||||
|
||||
20
Test.ml
20
Test.ml
@ -6,6 +6,24 @@ Sys.command "make Math.cmo Code.cmo";;
|
||||
open Math;;
|
||||
open Code;;
|
||||
|
||||
let print_boolean b = match b with
|
||||
| true -> print_string "true"
|
||||
| false -> print_string "false";;
|
||||
|
||||
let codeh = CLineaire.systematiqueFromRedondance 4 7 [7; 3; 5; 6];;
|
||||
let vecteurs = matriceAuPif 9 (8-1);;
|
||||
print_matrice 4 vecteurs;;
|
||||
let classes = CLineaire.genererClasses codeh;;
|
||||
let test v = try
|
||||
CLineaire.encoder codeh (CLineaire.decoder codeh v) <> CLineaire.decoder2 classes v
|
||||
with
|
||||
Code.CLineaire.PasDansLeCodeException -> (print_int v;print_endline "*\n";false) in
|
||||
List.find_opt test vecteurs;;
|
||||
CLineaire.decoder codeh 119;;
|
||||
CLineaire.encoder codeh 1;;
|
||||
CLineaire.decoder2 classes 119;;
|
||||
exit 0;;
|
||||
|
||||
(* Test du produit de matrice *)
|
||||
let matest = [0b01110; 0b00101; 0b10111];;
|
||||
print_matrice 5 matest;;
|
||||
@ -78,7 +96,7 @@ print_matrice 4 cocylined.h;;
|
||||
|
||||
CLineaire.distance_minimale cocylined;;
|
||||
|
||||
print_vecteur 7 (cyclencode cocycl 0b1010);;
|
||||
print_vecteur 9 203;;
|
||||
|
||||
(* Essayons de générer une table d'addition *)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user