summaryrefslogtreecommitdiff
path: root/lib/polynom.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/polynom.c')
-rw-r--r--lib/polynom.c48
1 files changed, 23 insertions, 25 deletions
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 (count<BUFSIZ)
+ count += strlen(temp);
+ if (count < BUFSIZ)
strcat(buf, temp);
else
- exception(1,_("ply_affichage: strcat error, not enoug space in buffer"));
- poly=poly->suiv;
+ exception(1, _("ply_affichage: strcat error, not enoug space in buffer"));
+ poly = poly->suiv;
}
return Estrdup(buf);
}