/*************************************************************************************************************************************/ /* */ /* S U R J E C T I O N F R A C T A L E D E [ 0 , 1 ] D A N S [ 0 , 1 ] x [ 0 , 1 ] D E P E A N O : */ /* */ /* */ /* Author of '$xtc/Peano_SurjectionFractale.02$vv$c' : */ /* */ /* Jean-Francois COLONNA (LACTAMME, 20220322103133). */ /* */ /*************************************************************************************************************************************/ #include "INCLUDES.01.I" extern double pow(); #define BASE \ 3 int Parametre_t[]={0,0,0,0,0,0}; #define INDEX_0 \ 1 #define INDEXATION(vecteur,index) \ (vecteur[MAX2(index,INDEX_0)-INDEX_0]) #define N \ (sizeof(Parametre_t)/sizeof(int)) #define ALL \ ((int)pow((double)BASE,(double)N)) int editer_03=VRAI; #define EDITER_03(print) \ { \ if (editer_03 == VRAI) \ { \ print; \ } \ else \ { \ } \ } \ /* Edition conditionnelle en base 03. */ int editer_10=FAUX; #define EDITER_10(print) \ { \ if (editer_10 == VRAI) \ { \ print; \ } \ else \ { \ } \ } \ /* Edition conditionnelle en base 10. */ #define CONVERSION(titre,variable,liste,borne) \ { \ int n; \ double puissance=1.0; \ \ variable=0.0; \ \ for (n=INDEX_0 ; n <= borne ; n++) \ { \ puissance = puissance/((double)BASE); \ variable = variable + (((double)INDEXATION(liste,n))*puissance); \ } \ \ printf("%s%f\n",titre,variable); \ } \ /* Conversion de la base 3 vers la base 10. */ void Surjection(parametre) int parametre[]; { double t; int Coordonnee_x[N/2]; double x; int Coordonnee_y[N/2]; double y; int n; int p; EDITER_10(printf("\n");); for (n=INDEX_0 ; n <= N ; n++) { EDITER_10(printf("a(%d)=%d\n",n,INDEXATION(parametre,n));); if ((INDEXATION(parametre,n) >= 0) && (INDEXATION(parametre,n) <BASE)) { } else { printf("Le chiffre %d de rang %d n'est pas dans [0,%d].\n",INDEXATION(parametre,n),n-INDEX_0,BASE-1); } } EDITER_10(printf("\n");); for (n=INDEX_0 ; n <= (N/2) ; n++) { int somme_x=0; int somme_y=0; char *parite; EDITER_10(printf("n=%d ",n);); if (n > INDEX_0) { for (p=INDEX_0 ; p <= (n-1) ; p++) { EDITER_10(printf("a(%d)%s",(2*p)-0,COND(p<(n-0),"+",""));); somme_x = somme_x + INDEXATION(parametre,(2*p)-0); } if ((somme_x % (BASE-1)) == 0) { INDEXATION(Coordonnee_x,n) = INDEXATION(parametre,(2*n)-1); parite="__Pair"; } else { INDEXATION(Coordonnee_x,n) = (BASE-1)-INDEXATION(parametre,(2*n)-1); parite="ImPair"; } } else { INDEXATION(Coordonnee_x,n) = INDEXATION(parametre,INDEX_0); parite="__Pair"; } EDITER_10(printf(" --> b(%d)=%s(a(%d))=%d\n",n,parite,(2*n)-1,INDEXATION(Coordonnee_x,n));); EDITER_10(printf("n=%d ",n);); for (p=INDEX_0 ; p <= n ; p++) { EDITER_10(printf("a(%d)%s",(2*p)-1,COND(p<(n-0),"+",""));); somme_y = somme_y + INDEXATION(parametre,(2*p)-1); } if ((somme_y % (BASE-1)) == 0) { INDEXATION(Coordonnee_y,n) = INDEXATION(parametre,(2*n)+0); parite="__Pair"; } else { INDEXATION(Coordonnee_y,n) = (BASE-1)-INDEXATION(parametre,(2*n)+0); parite="ImPair"; } EDITER_10(printf(" --> c(%d)=%s(a(%d))=%d\n",n,parite,(2*n)+0,INDEXATION(Coordonnee_y,n));); EDITER_10(printf("\n");); } EDITER_03(printf("\n");); EDITER_10(printf("\n");); EDITER_03(printf("t=0.{");); EDITER_10(printf("t=0.");); for (n=INDEX_0 ; n <= N ; n++) { EDITER_03(printf("%d",INDEXATION(parametre,n));); EDITER_10(printf("%d",INDEXATION(parametre,n));); } EDITER_03(printf("}\n");); EDITER_10(printf(" ");); EDITER_03(printf("x=0.{");); EDITER_10(printf("x(t)=0.");); for (n=INDEX_0 ; n <= (N/2) ; n++) { EDITER_03(printf("%d ",INDEXATION(Coordonnee_x,n));); EDITER_10(printf("%d",INDEXATION(Coordonnee_x,n));); } EDITER_03(printf("}\n");); EDITER_10(printf(" ");); EDITER_03(printf("y=0.{");); EDITER_10(printf("y(t)=0.");); for (n=INDEX_0 ; n <= (N/2) ; n++) { EDITER_03(printf(" %d",INDEXATION(Coordonnee_y,n));); EDITER_10(printf("%d",INDEXATION(Coordonnee_y,n));); } EDITER_03(printf("}\n");); EDITER_10(printf("\n");); if (editer_03 == VRAI) { } else { CONVERSION("t=",t,parametre,N); CONVERSION("x(t)=",x,Coordonnee_x,N/2); CONVERSION("y(t)=",y,Coordonnee_y,N/2); } return; } void main() { int i1; if ((N%2) != 0) { printf("ERREUR : la liste 't' a un nombre impair d'elements.\n\n"); } else { } for (i1=1 ; i1 <= ALL ; i1++) { int i2; int retenue=1; Surjection(Parametre_t); for (i2=(N-1) ; i2 >= 0 ; i2--) { Parametre_t[i2] = Parametre_t[i2] + retenue; /* Incrementation du parametre 't'... */ if (Parametre_t[i2] == BASE) { Parametre_t[i2] = 0; retenue=1; } else { retenue=0; } } } }