summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbiouman <biouman>2001-04-29 00:21:39 +0000
committerbiouman <biouman>2001-04-29 00:21:39 +0000
commit2b7ed342c58d1e671728248fe2b41776ff6d9617 (patch)
treedc61cc858fdb8c65e8ff9126feccdd29afddcc53
parentb069bcfea86b2f0eee8cb0b9e7757922e2a68275 (diff)
*** empty log message ***
-rw-r--r--lib/pile.c43
-rw-r--r--lib/polynom.c1
-rw-r--r--src/Polynom.c4
3 files changed, 35 insertions, 13 deletions
diff --git a/lib/pile.c b/lib/pile.c
index f6760a0..3d4bb93 100644
--- a/lib/pile.c
+++ b/lib/pile.c
@@ -64,6 +64,7 @@ void push_pile(char *st)
void push_pile_poly(polynome poly)
{
+ pushcontext("entree dans push_pile_poly");
if (pile_ptr != PILE_MAX) {
pile[pile_ptr].type = T_POLY;
pile[pile_ptr].poly = poly;
@@ -71,11 +72,16 @@ void push_pile_poly(polynome poly)
} else {
exception(1, _("push_pile_poly: Stack Overflow"));
}
-
+ pushcontext("sortie de push_pile_poly");
+ popcontext();
+ popcontext();
}
void push_pile_int(int val)
{
+
+ pushcontext("appel a push_pile_int");
+ fprintf(stderr,"%d",val);
if (pile_ptr != PILE_MAX) {
pile[pile_ptr].type = T_INT;
pile[pile_ptr].val = val;
@@ -83,11 +89,16 @@ void push_pile_int(int val)
} else {
exception(1, _("push_pile_int: Stack Overflow"));
}
+ pushcontext("sortie de push-pile_int");
+ popcontext();
+ popcontext();
+
}
void push_pile_string(char *st)
{
+ pushcontext("appel a push_pile_string");
if (pile_ptr != PILE_MAX) {
pile[pile_ptr].type = T_STRING;
pile[pile_ptr].label = Estrdup(st);
@@ -95,6 +106,10 @@ void push_pile_string(char *st)
} else {
exception(1, _("push_pile_string: Stack Overflow"));
}
+ pushcontext("sortie de push_pile_string");
+ popcontext();
+ popcontext();
+
}
@@ -234,7 +249,7 @@ void act_pile(int func)
exception(1, _("act_pile: OP_EXP invalid arguments"));
}
break;
- case OP_ASSIGN: /* FIXME: sens de l evaluation ? poly label sto ou label poly sto */
+ case OP_ASSIGN:
operande1 = pop_pile(1);
operande2 = pop_pile(1);
if ((operande1.type == T_POLY) && (operande2.type == T_STRING)) {
@@ -242,8 +257,6 @@ void act_pile(int func)
InsererVarDansTab(&variables,
CreerElement(operande2.label,
(void *) operande1.poly));
- if (operande1.poly)
- ply_destruct(operande1.poly);
free(operande2.label);
} else {
exception(1, _("act_pile: OP_ASSIGN empty string"));
@@ -272,13 +285,21 @@ void act_pile(int func)
operande2 = pop_pile(1);
if ((operande1.type == T_POLY) && (operande2.type == T_POLY)) {
if (operande2.poly) {
- if (operande2.poly->degre == 0) {
- push_pile_poly(ply_constr
- (rat_constr_from_double
- (ply_valuation
- (operande1.poly,
- rat_to_double(operande2.poly->
- coef))), 1));
+ if (operande1.poly->degre == 0) {
+ double soja, soja2;
+ rationnel rat;
+ polynome pl;
+ fprintf(stderr,"soja");
+ soja=rat_to_double(operande1.poly->coef);
+ fprintf(stderr,"%f",soja);
+ soja2=ply_valuation(operande2.poly,soja);
+ fprintf(stderr,"%f", soja2);
+ rat=rat_constr_from_double(soja2);
+ fprintf(stderr,"pl");
+ pl=ply_constr(rat, 1);
+/*
+push_pile_poly(ply_constr(rat_constr_from_double(ply_valuation(operande2.poly,rat_to_double(operande1.poly->coef))), 1));
+*/
if (operande1.poly)
ply_destruct(operande1.poly);
ply_destruct(operande2.poly);
diff --git a/lib/polynom.c b/lib/polynom.c
index 8e15297..72f02bf 100644
--- a/lib/polynom.c
+++ b/lib/polynom.c
@@ -257,6 +257,7 @@ double ply_valuation(polynome poly, double point)
while (poly) {
result += rat_to_double(poly->coef) * pow(point, (double) (poly->degre));
+ poly++;
}
return result;
}
diff --git a/src/Polynom.c b/src/Polynom.c
index beebbb6..dd2fc8c 100644
--- a/src/Polynom.c
+++ b/src/Polynom.c
@@ -29,8 +29,8 @@ int main(void)
Initialise(&variables);
mute = Estrdup("x");
/* nom de la variable utilisee pour la saisie des polynomes, a recuperer en argv eventuellt */
- parse_line("(x^2) + x + 1;");
- //parse_line("P(2);");
+ parse_line("P=(x^2) + x + 1;");
+ parse_line("P(2);");
//printf("%s\n", affichage_level_1());
return 0;