summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPixel <Pixel>2001-05-02 02:57:44 +0000
committerPixel <Pixel>2001-05-02 02:57:44 +0000
commitd3bfe2d1ee65f681ee04cfce0f5a3cdaae582f29 (patch)
tree5c8eeaca942525e74078ee59fedb11be29b503fc
parent903e2e8aac5151d505432757048537cc56844bca (diff)
Bla
-rw-r--r--doc/conclusion.tex8
-rw-r--r--doc/manuel.tex160
-rw-r--r--lib/interface.c2
-rw-r--r--lib/parser.c3
-rw-r--r--lib/pile.c13
-rw-r--r--po/cat-id-tbl.c35
-rw-r--r--src/Polynom.c11
7 files changed, 93 insertions, 139 deletions
diff --git a/doc/conclusion.tex b/doc/conclusion.tex
index e5d9edf..aef6e9c 100644
--- a/doc/conclusion.tex
+++ b/doc/conclusion.tex
@@ -3,7 +3,7 @@
\markboth{CONCLUSION}{CONCLUSION}
Ce projet a été mené à terme, et l'ensemble des conditions du sujet ont été respectées.
-L'effort de recherche mené sur la manière d'implémenter les algorithmes en C++ a
-sans aucun doute été profitable pour notre connaissance personnelle. De plus, les algorithmes
-implémentés sont "durables": ils peuvent nous resservir dans n'importe quel autre projet nécessitant
-des structures de files de priorités, ce qui porte un intérêt quant au développement de ce projet.
+Nous avons apporté des touches personnelles qui nous ont permi d'agrémenter le projet de quelques
+fonctionnalités supplémentaires, ainsi qu'un confort d'utilisation accru. Les différents efforts
+menés nous ont permi d'obtenir un projet agréable à utiliser, et qui pourra être utile par la suite
+en tant que calculatrice avancée.
diff --git a/doc/manuel.tex b/doc/manuel.tex
index fcdc3af..d1522f0 100644
--- a/doc/manuel.tex
+++ b/doc/manuel.tex
@@ -1,124 +1,74 @@
\chapter{Manuel d'utilisation}
\paragraph{}
-Ce projet génère deux binaire. Le premier appelé testTas n'est qu'une petite application nous permettant d'utiliser l'API
-C++ générée par notre classe de file de priorités. Voici un exemple d'exécution:
+Lorsque le programme principal se lance, nous obtenons un invite simple:
\begin{verbatim}
-Priority list type: 0 - Binary Heap
-Choice: Please select an action
-a - Add a key into the priority list
-c - Change priority list type
-d - Delete a Key from the priority list
-e - Extract Min onto the priority list
-l - Lower Key onto a key of the priority list
-p - Print the current priority list on the screen
-r - Remove the whole priority list
-t - Test the priority list algorithms
-q - Quit
-\end{verbatim}
+$ ./Polynom
+Polynomia v1.0
-A partir de cet instant, le programme nous propose un menu nous permettant d'effectuer plusieurs actions sur le tas. La
-fonction 'a' permet d'ajouter une clef dans le tas en cours. Comme il est impossible d'effectuer une recherche sur un tas
-pour y retrouver le pointeur d'un élément, le programme nous propose de sauvegarder le pointeur résultat dans un tableau:
-\begin{verbatim}
-Choice: Please select a slot to save the cell
-0 - Empty slot
-1 - Empty slot
-2 - Empty slot
-3 - Empty slot
-4 - Empty slot
-5 - Empty slot
-6 - Empty slot
-7 - Empty slot
-8 - Empty slot
-9 - Empty slot
-n - Don't store
-c - Cancel
-\end{verbatim}
+Performing initialisation...
-Ce tableau apparaitra régulièrement dans toutes les fonctions du menu afin de choisir une cellule sur laquelle agir. Toutes
-les fonctions du menu parlent d'elles mêmes. La fonction 't' va lancer une batterie de tests sur les algorithmes de la
-file de priorité sélectionnée.
-\paragraph{}
-Le deuxième binaire généré est 'Huffman'. Il sert à utiliser l'algorithme d'huffman implémenté. Voici sa ligne d'aide:
-\begin{verbatim}
-$ ./Huffman -h
-Huffman [{-f|-i} file] {type}
-Huffman -h
-This will encode the input file with the Huffman code
-using the priority list defined by type.
-Type is a number taken from this list:
- 0 : Binary Heap (default)
- 1 : Binomial Heap
- 2 : Fibonacci Heap
- 3 : Sorted chained list
--f file means that you specify a dictionnary file which is
- structured as described into the README file.
--i file means that you specify a file to encode. It will
- built a quiet dumb dictionnary.
-By default, a dictionnary will be built from stdin.
--h prints this help and exit.
+Starting interface...
+
+>
\end{verbatim}
-La structure d'un dictionnaire est la suivante:
+La flexibilité de l'interface est extrème, et nous permet, à la manière MAPLE, de taper sous une
+forme naturelle nos polynomes. Voici un exemple d'utilisation "simple":
+
\begin{verbatim}
-Mot1 : Fréquence1
-Mot2 : Fréquence2
-...
+> A = x^4 + 2*x^3 - x + 6;
+
+ . x^4 + 2x^3 - x + 6
+
+> B = x^3 - 6*x^2 + x + 4;
+
+ . x^3 - 6x^2 + x + 4
+
+> A + B;
+
+ . x^4 + 3x^3 - 6x^2 + 10
+
+> A - B;
+
+ . x^4 + x^3 + 6x^2 - 2x + 2
+
+> A / B;
+
+ . x + 8
+
+> A % B;
+
+ . 47x^2 - 13x - 26
+
+> A(2);
+
+ . 36
\end{verbatim}
-Chaque mot est une chaîne de caractères servant à identifier la fréquence associée. Voici un exemple complet de dictionnaire
-et d'utilisation du programme avec ce dictionnaire:
+Comme à la manière MAPLE, il est possible d'évaluer des polynomes en cours de route. Par exemple:
\begin{verbatim}
-Pixel@the-babel-tower:~/Projets_LI/Semestre1/Projet-Algo/src$ cat dict.sample
-MOT1 : 2000
-MOT2 : 1234
-MOT3 : 15987
-MOT4 : 1203
-MOT5 : 192837
-MOT6 : 12987
-Pixel@the-babel-tower:~/Projets_LI/Semestre1/Projet-Algo/src$ ./Huffman -f dict.sample
-MOT3 (15987) = 00
-MOT1 (2000) = 0100
-MOT4 (1203) = 01010
-MOT2 (1234) = 01011
-MOT6 (12987) = 011
-MOT5 (192837) = 1
-Bitstream length : 283957 bits (= 35495 bytes)
-Real size input : 7239936 bits (= 904992 bytes)
-Size squeezed by : 96.0779 percents
-Dictionnary size : 336 bits (= 42 bytes)
-Total bitstream length : 284293 bits (= 35537 bytes)
-Real gain (4 bytes header) : 96.0728 percents
+> P = A + 2*x - 3*B;
+
+ . x^4 - x^3 + 18x^2 - 2x - 6
\end{verbatim}
-Il est indiqué que le programme est capable de générer un dictionnaire à partir d'un fichier. Il s'agit simplement de compter
-les caractères provenant de l'entrée et d'en générer un dictionnaire. Exemple:
+Enfin, il y a des appels de fonctions prédéfinis, dont l'appel à la fonction d'évaluation d'un polynôme:
\begin{verbatim}
-$ cat dict.sample | Huffman
-\32 (12) = 00
-6 (1) = 01000
-4 (2) = 01001
-3 (4) = 0101
-0 (4) = 0110
-5 (2) = 01110
-7 (3) = 01111
-1 (6) = 1000
-M (6) = 1001
-: (6) = 1010
-\10 (6) = 1011
-O (6) = 1100
-8 (3) = 11010
-9 (3) = 11011
-2 (6) = 1110
-T (6) = 1111
-Bitstream length : 294 bits (= 37 bytes)
-Real size input : 608 bits (= 76 bytes)
-Size squeezed by : 51.6447 percents
-Dictionnary size : 512 bits (= 64 bytes)
-Total bitstream length : 806 bits (= 101 bytes)
-Real gain (4 bytes header) : -38.1579 percents
+> P(3);
+
+ . 204
\end{verbatim}
+
+Le parseur de ligne étant totalement flexible, il est possible de mélanger toutes les fonctionnalités ensembles:
+\begin{verbatim}
+> (2*P + B)(3);
+
+ . 388
+
+
+>
+\end{verbatim} \ No newline at end of file
diff --git a/lib/interface.c b/lib/interface.c
index e3fbe7a..f459215 100644
--- a/lib/interface.c
+++ b/lib/interface.c
@@ -94,7 +94,9 @@ void ifloop(void) {
break;
case 10: /* Entrée */
printf("\n");
+ clearterm();
parse_line(buffer);
+ initterm();
position = 0;
buffer[0] = 0;
printf("\n");
diff --git a/lib/parser.c b/lib/parser.c
index 6a2ab34..529516b 100644
--- a/lib/parser.c
+++ b/lib/parser.c
@@ -232,6 +232,7 @@ void parse_line(char *line)
exception(1, _("Parse error: too much left parenthesis"));
act_pile(get_func(op));
}
+ got_unary = 128;
move_to_resultat_pile();
break;
case ')':
@@ -273,7 +274,7 @@ void parse_line(char *line)
}
popcontext();
if (global_error) {
- got_unary = 0;
+ got_unary = 128;
while (pileop_pos) {
pop_op();
}
diff --git a/lib/pile.c b/lib/pile.c
index 9a755ff..55a0ff2 100644
--- a/lib/pile.c
+++ b/lib/pile.c
@@ -411,17 +411,18 @@ void act_pile(int func)
break;
case T_POLY:
if (operande2.poly) {
- if (operande1.poly->degre == 0) {
-
-
+ if (operande1.val != 1) {
+ exception(1, _("act_pile: OP_FUNC_CALL need only one argument for a polynom evaluation"));
+ }
+ if (operande[0].poly->degre == 0) {
push_pile_poly(ply_constr
(rat_constr_from_double
(ply_valuation
- (operande2.poly, rat_to_double(operande1.poly->coef))),
+ (operande2.poly, rat_to_double(operande[0].poly->coef))),
0));
- if (operande1.poly)
- ply_destruct(operande1.poly);
+ if (operande[0].poly)
+ ply_destruct(operande[0].poly);
ply_destruct(operande2.poly);
} else {
exception(1, _("act_pile: OP_FUNC_CALL incorrect value for 2nd arg"));
diff --git a/po/cat-id-tbl.c b/po/cat-id-tbl.c
index 3c3107b..e306c13 100644
--- a/po/cat-id-tbl.c
+++ b/po/cat-id-tbl.c
@@ -49,26 +49,31 @@ const struct _msg_ent _msg_tbl[] = {
{"act_pile: OP_MOINS_UNARY invalid argument", 40},
{"act_pile: OP_FUNC_CALL incorrect argument type", 41},
{"act_pile: OP_FUNC_CALL invalid operand type", 42},
- {"act_pile: OP_FUNC_CALL incorrect value for 2nd arg", 43},
- {"act_pile: OP_FUNC_CALL arg2 is an empty polynom", 44},
- {"act_pile: OP_FUNC_CALL incorrect argument number", 45},
- {"act_pile: Unknown operator", 46},
- {"\t-- Printing Stack\n", 47},
- {"\t-- End Printing Stack\n", 48},
- {"ply_affichage: strcat error, not enough space in buffer", 49},
- {"rat_constr: division by zero", 50},
- {"division by zero", 51},
- {"Signal received: segfault", 52},
- {"Signal received: break", 53},
+ {"act_pile: OP_FUNC_CALL need only one argument for a polynom evaluation", 43},
+ {"act_pile: OP_FUNC_CALL incorrect value for 2nd arg", 44},
+ {"act_pile: OP_FUNC_CALL arg2 is an empty polynom", 45},
+ {"act_pile: OP_FUNC_CALL incorrect argument number", 46},
+ {"act_pile: Unknown operator", 47},
+ {"\t-- Printing Stack\n", 48},
+ {"\t-- End Printing Stack\n", 49},
+ {"ply_affichage: strcat error, not enough space in buffer", 50},
+ {"rat_constr: division by zero", 51},
+ {"division by zero", 52},
+ {"Signal received: segfault", 53},
+ {"Signal received: break", 54},
{"\
\n\
Performing initialisation...\n\
-\n", 54},
+\n", 55},
+ {"\
+\n\
+Starting interface...\n\
+\n", 56},
{"\
\n\
Performing shutdown...\n\
-\n", 55},
- {"Exitting, bye!\n", 56},
+\n", 57},
+ {"Exitting, bye!\n", 58},
};
-int _msg_tbl_length = 56;
+int _msg_tbl_length = 58;
diff --git a/src/Polynom.c b/src/Polynom.c
index 98b083d..5a52228 100644
--- a/src/Polynom.c
+++ b/src/Polynom.c
@@ -41,6 +41,7 @@ void flush_all(void) {
}
void invite(void) {
+ fprintf(stderr, "Polynomia v1.0\n\n");
}
int main(void)
@@ -85,10 +86,11 @@ int main(void)
openterm();
initterm();
+ fprintf(stderr, _("\nStarting interface...\n\n"));
ifloop();
- clearterm();
fprintf(stderr, _("\nPerforming shutdown...\n\n"));
+ clearterm();
flush_all();
signal(SIGSEGV, NULL);
@@ -96,12 +98,5 @@ int main(void)
fprintf(stderr, _("Exitting, bye!\n"));
-
-
return 0;
-
-
-/* destruction de ts les polynomes stockes dans la table de hh */
-/* appel a la fonction de vidage de pile */
-/* vraiment utile? on quitte le prog, ttes les donnes dynamiques seront detruites ... */
}