/*************************************************************************************************************************************/ /* */ /* T E S T D E S O U T I L S " F O L K L O R I Q U E S " P O U R L E S N O M B R E S C O M P L E X E S : */ /* */ /* */ /* Author of '$xtc/OperationsFolkoriquesComplexes.01$vv$c' : */ /* */ /* Jean-Francois COLONNA (LACTAMME, 20220822112834). */ /* */ /*************************************************************************************************************************************/ #include <stdio.h> double a1111=0; double a1110=0; double a1101=0; double a1100=0; double a1011=0; double a1010=0; double a1001=0; double a1000=0; double a0111=0; double a0110=0; double a0101=0; double a0100=0; double a0011=0; double a0010=0; double a0001=0; double a0000=0; #define p_I2xR2xI1xR1 \ a1111 #define p_I2xR2xI1 \ a1110 #define p_I2xI1xR1 \ a1101 #define p_I2xI1 \ a1100 #define p_I2xR2xR1 \ a1011 #define p_I2xR2 \ a1010 #define p_I2xR1 \ a1001 #define p_I2 \ a1000 #define p_R2xI1xR1 \ a0111 #define p_R2xI1 \ a0110 #define p_I1xR1 \ a0101 #define p_I1 \ a0100 #define p_R2xR1 \ a0011 #define p_R2 \ a0010 #define p_R1 \ a0001 #define p_ \ a0000 #define aF \ a1111 #define aE \ a1110 #define aD \ a1101 #define aC \ a1100 #define aB \ a1011 #define aA \ a1010 #define a9 \ a1001 #define a8 \ a1000 #define a7 \ a0111 #define a6 \ a0110 #define a5 \ a0101 #define a4 \ a0100 #define a3 \ a0011 #define a2 \ a0010 #define a1 \ a0001 #define a0 \ a0000 #define REINITIALISATION \ { \ 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; \ } #define FORME_COMPLETE \ ((((((((((((((((((((a1111)) \ *(R1)))+(a1110)))) \ *(I1)))+((((((a1101))*(R1))) \ +(a1100))))))*(R2))) \ +(((((((((((a1011))*(R1))) \ +(a1010))))*(I1)))+((((((a1001)) \ *(R1)))+(a1000))))))))*(I2))) \ +((((((((((((((((a0111)) \ *(R1)))+(a0110))))*(I1))) \ +((((((a0101))*(R1))) \ +(a0100))))))*(R2)))+(((((((((((a0011)) \ *(R1))) \ +(a0010)))) \ *(I1)))+((((((a0001))*(R1))) \ +(a0000)))))))) #define R \ R1 #define I \ I1 #define r \ R2 #define i \ I2 #define FORME_SIMPLIFIEE \ (((((((aF*R)+aE)*I)+((aD*R)+aC))*r)+((((aB*R)+aA)*I)+((a9*R)+a8)))*i) \ +((((((a7*R)+a6)*I)+((a5*R)+a4))*r)+((((a3*R)+a2)*I)+((a1*R)+a0))) #define PRINT(code,valeur) \ { \ printf(" R1=%.0f I1=%.0f R2=%.0f I2=%.0f",R1,I1,R2,I2); \ printf(" F_COMPLETE=%.0f",FORME_COMPLETE); \ printf(" F_SIMPLIFIEE=%.0f",FORME_SIMPLIFIEE); \ printf(" ValeurAttendue=%.0f",(double)valeur); \ printf(" %s",code); \ \ if ((valeur != FORME_COMPLETE) || (valeur != FORME_SIMPLIFIEE)) \ { \ printf(" ERREUR"); \ } \ else \ { \ } \ \ printf("\n"); \ REINITIALISATION; \ } main() { double R1=2,I1=3; double R2=5,I2=7; /* L'usage des nombres premiers {2,3,5,7} permet d'identifier sans ambiguite les */ /* facteurs d'un produit... */ p_I2xR2xI1xR1=1 ; PRINT("p_I2xR2xI1xR1",I2*R2*I1*R1); p_I2xR2xI1=1 ; PRINT("p_I2xR2xI1",I2*R2*I1); p_I2xI1xR1=1 ; PRINT("p_I2xI1xR1",I2*I1*R1); p_I2xI1=1 ; PRINT("p_I2xI1",I2*I1); p_I2xR2xR1=1 ; PRINT("p_I2xR2xR1",I2*R2*R1); p_I2xR2=1 ; PRINT("p_I2xR2",I2*R2); p_I2xR1=1 ; PRINT("p_I2xR1",I2*R1); p_I2=1 ; PRINT("p_I2",I2); p_R2xI1xR1=1 ; PRINT("p_R2xI1xR1",R2*I1*R1); p_R2xI1=1 ; PRINT("p_R2xI1",R2*I1); p_I1xR1=1 ; PRINT("p_I1xR1",I1*R1); p_I1=1 ; PRINT("p_I1",I1); p_R2xR1=1 ; PRINT("p_R2xR1",R2*R1); p_R2=1 ; PRINT("p_R2",R2); p_R1=1 ; PRINT("p_R1",R1); p_=1 ; PRINT("p_",1); /* Cela a montre les erreurs suivantes avec les definitions des 'p_...' : */ /* */ /* F_COMPLETE=F_SIMPLIFIEE=70 ValeurAttendue=42 p_I2xI1xR1 en fait : I2xR2xR1 */ /* F_COMPLETE=F_SIMPLIFIEE=42 ValeurAttendue=70 p_I2xR2xR1 en fait : I2xI1xR1 */ /* */ /* F_COMPLETE=F_SIMPLIFIEE=35 ValeurAttendue=21 p_I2xI1 en fait : I2xR2 */ /* F_COMPLETE=F_SIMPLIFIEE=21 ValeurAttendue=35 p_I2xR2 en fait : I2xI1 */ /* */ /* F_COMPLETE=F_SIMPLIFIEE=10 ValeurAttendue=6 p_I1xR1 en fait : R2xR1 */ /* F_COMPLETE=F_SIMPLIFIEE=6 ValeurAttendue=10 p_R2xR1 en fait : I1xR1 */ /* */ /* F_COMPLETE=F_SIMPLIFIEE=5 ValeurAttendue=3 p_I1 en fait : R2 */ /* F_COMPLETE=F_SIMPLIFIEE=3 ValeurAttendue=5 p_R2 en fait : I1 */ /* */ }