/*************************************************************************************************************************************/ /* */ /* T E S T D E L A F O N C T I O N ' HORNER_4_01(...) ' : */ /* */ /* */ /* Author of '$xtc/HORNER_4_01.distributivite.01$c' : */ /* */ /* Jean-Francois COLONNA (LACTAMME, 20181214143155). */ /* */ /*************************************************************************************************************************************/ #include <stdio.h> #define ADD2(a,b) ((a)+(b)) #define ADD3(a,b,c) ADD2(ADD2(a,b),c) #define MUL2(a,b) ((a)*(b)) #define DIST1(a,b,c) MUL2(ADD2(a,b),c) #define DIST2(a,b,c) ADD2(MUL2(a,c),MUL2(b,c)) #define DIST(a,b,c) DIST1(a,b,c) #define P3(V1,V3) ADD3(DIST(MUL2(a1111,V1),a1110,V3),MUL2(a1101,V1),a1100) #define P2(V1,V3) ADD3(DIST(MUL2(a1011,V1),a1010,V3),MUL2(a1001,V1),a1000) #define P1(V1,V3) ADD3(DIST(MUL2(a0111,V1),a0110,V3),MUL2(a0101,V1),a0100) #define P0(V1,V3) ADD3(DIST(MUL2(a0011,V1),a0010,V3),MUL2(a0001,V1),a0000) #define HORNER_4_01(V1,V2,V3,V4) ADD3(DIST(MUL2(P3(V1,V3),V2),P2(V1,V3),V4),MUL2(P1(V1,V3),V2),P0(V1,V3)) #define CALCUL(legende,initialisation) \ { \ a1111=0; \ a1110=0; \ a1101=0; \ a1100=0; \ a1011=0; \ a1010=0; \ a1001=0; \ a1000=0; \ a0111=0; \ a0110=0; \ a0101=0; \ a0100=0; \ a0011=0; \ a0010=0; \ a0001=0; \ a0000=0; \ \ initialisation; \ \ printf("HORNER_4_01[%s] = %+f\n",legende,HORNER_4_01(R1,I1,R2,I2)); \ } main() { double a1111,a1110,a1101,a1100; /* Definition du premier polynome. */ double a1011,a1010,a1001,a1000; /* Definition du second polynome. */ double a0111,a0110,a0101,a0100; /* Definition du troisieme polynome. */ double a0011,a0010,a0001,a0000; /* Definition du dernier polynome. */ double R1=2,R2=30,I1=4,I2=50; CALCUL("R1+R2",a0001=+1;a0010=+1;); /* Definition de la partie Reelle de 'FgCsomme(...)' : */ /* */ /* R1+R2 */ /* */ CALCUL("I1+I2",a0100=+1;a1000=+1;); /* Definition de la partie Imaginaire de 'FgCsomme(...)' : */ /* */ /* I1+I2 */ /* */ CALCUL("(R1.R2) - (I1.I2)",a0011=+1;a1100=-1;); /* Definition de la partie Reelle de 'FgCproduit(...)' : */ /* */ /* (R1.R2) - (I1.I2) */ /* */ CALCUL("(R1.I2) + (R2.I1)",a1001=+1;a0110=+1;); /* Definition de la partie Imaginaire de 'FgCproduit(...)' : */ /* */ /* (R1.I2) + (R2.I1) */ /* */ CALCUL("R1+R2 + alpha.(R1.I1)",a0001=+1;a0010=+1;a0101=0.0001;); /* Definition de la partie Reelle "folklorique" (alpha=a0101=0.0001) de 'FgCsomme(...)' : */ /* */ /* R1+R2 + alpha.(R1.I1) */ /* */ /* ('v $xiMl/JULK.7n.21$ANGLAIS.$m4.$I'). */ CALCUL("I1+I2 + beta.(R2.I1)",a0100=+1;a1000=+1;a0110=0.0001;); /* Definition de la partie Imaginaire "folklorique" (beta=a0110=0.0001) de 'FgCsomme(...)' : */ /* */ /* I1+I2 + beta.(R2.I1) */ /* */ /* ('v $xiMl/JULK.7n.21$ANGLAIS.$m4.$I'). */ }