From 9636d6739ebf330ef3fcc41ae838068e600c140b Mon Sep 17 00:00:00 2001 From: biouman Date: Mon, 30 Apr 2001 01:39:32 +0000 Subject: *** empty log message *** --- lib/polynom.c | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) (limited to 'lib/polynom.c') diff --git a/lib/polynom.c b/lib/polynom.c index eaa690d..9dc2517 100644 --- a/lib/polynom.c +++ b/lib/polynom.c @@ -194,13 +194,11 @@ polynome ply_multiplication(polynome poly1, polynome poly2) { /* multiplication de deux polynomes */ polynome temp = NULL, t, resultat = NULL, r, tempresult = NULL, poly2init; - poly2init=poly2; + poly2init = poly2; while (poly1) { - poly2=poly2init; + poly2 = poly2init; while (poly2) { - t = - ply_constr(rat_multiplication(poly1->coef, poly2->coef), - poly1->degre + poly2->degre); + t = ply_constr(rat_multiplication(poly1->coef, poly2->coef), poly1->degre + poly2->degre); if (t) { if (tempresult) { temp->suiv = t; @@ -213,11 +211,11 @@ polynome ply_multiplication(polynome poly1, polynome poly2) poly2 = poly2->suiv; } poly1 = poly1->suiv; - r=ply_addition(tempresult,resultat); + r = ply_addition(tempresult, resultat); ply_destruct(resultat); - resultat=r; + resultat = r; ply_destruct(tempresult); - tempresult=NULL; + tempresult = NULL; } return resultat; @@ -225,8 +223,8 @@ polynome ply_multiplication(polynome poly1, polynome poly2) polynome ply_division(polynome poly1, polynome poly2) { /* division de deux polynomes */ - polynome result=NULL; - + polynome result = NULL; + return result; @@ -235,7 +233,7 @@ polynome ply_division(polynome poly1, polynome poly2) polynome ply_modulo(polynome poly1, polynome poly2) { /* reste de la division de deux polynomes */ - polynome result=NULL; + polynome result = NULL; return result; } @@ -264,35 +262,35 @@ double ply_valuation(polynome poly, double point) double result = 0; while (poly) { - result += rat_to_double(poly->coef) * pow(point, (poly->degre)); - poly=poly->suiv; + result += rat_to_double(poly->coef) * pow(point, (poly->degre)); + poly = poly->suiv; } return result; } char *ply_affichage(polynome poly) { /* routine d'affichage d'un polynome */ - char buf[BUFSIZ] = {0}, temp[BUFSIZ]; - int count=0; - + char buf[BUFSIZ] = { 0 }, temp[BUFSIZ]; + int count = 0; + while (poly) { if (poly->degre != 0) { - if (poly->coef.denom==1) + if (poly->coef.denom == 1) sprintf(temp, "%+d*%s^%u ", poly->coef.num, mute, poly->degre); - else + else sprintf(temp, "%+d/%d*%s^%u ", poly->coef.num, poly->coef.denom, mute, poly->degre); } else { - if (poly->coef.denom==1) + if (poly->coef.denom == 1) sprintf(temp, "%+d ", poly->coef.num); - else - sprintf(temp, "%+d/%d ", poly->coef.num , poly->coef.denom); + else + sprintf(temp, "%+d/%d ", poly->coef.num, poly->coef.denom); } - count+=strlen(temp); - if (countsuiv; + exception(1, _("ply_affichage: strcat error, not enoug space in buffer")); + poly = poly->suiv; } return Estrdup(buf); } -- cgit v1.2.3