/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        R E C H E R C H E   D E S   D I V I S E U R S   P R E M I E R S   D ' U N   F I C H I E R   N U M E R I Q U E  :           */
/*                                                                                                                                   */
/*                                                                                                                                   */
/*        Author of '$xrv/DivPrem.01$K' :                                                                                            */
/*                                                                                                                                   */
/*                    Jean-Francois COLONNA (LACTAMME, 20120919131317).                                                              */
/*                                                                                                                                   */
/*************************************************************************************************************************************/

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        I N T E R F A C E   ' listG '  :                                                                                           */
/*                                                                                                                                   */
/*                                                                                                                                   */
/*        :Debut_listG:                                                                                                              */
/*        :Fin_listG:                                                                                                                */
/*                                                                                                                                   */
/*************************************************************************************************************************************/

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        D I R E C T I V E S   S P E C I F I Q U E S   D E   C O M P I L A T I O N  :                                               */
/*                                                                                                                                   */
/*************************************************************************************************************************************/

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        F I C H I E R S   D ' I N C L U D E S  :                                                                                   */
/*                                                                                                                                   */
/*************************************************************************************************************************************/
#include  INCLUDES_BASE

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        V A L E U R S   I M P L I C I T E S   D E S   P A R A M E T R E S  :                                                       */
/*                                                                                                                                   */
/*************************************************************************************************************************************/
#define   COMPATIBILITE_20220528                                                                                                        \
                    FAUX                                                                                                                \
                                        /* Permet de faire des calculs compatibles a ceux faits anterieurement au 20220528151029...  */

#define   PREMIER_DIVISEUR                                                                                                              \
                    DEUX                                                                                                                \
                                        /* Definition du premier diviseur qui est evidemment le premier nombre premier...            */

#define   EDITER_LES_DIVISEURS_PREMIERS                                                                                                 \
                    VRAI
#define   EDITER_LA_DECOMPOSITION_EN_FACTEURS_PREMIERS                                                                                  \
                    FAUX
                                        /* Afin de controler l'edition des diviseurs premiers. L'edition explicite de la             */
                                        /* decomposition a ete introduite le 20220527180441...                                       */

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        D E F I N I T I O N   D U   F I C H I E R  :                                                                               */
/*                                                                                                                                   */
/*************************************************************************************************************************************/
#include  xrv/ARITHMET.1d.I"
                                        /* Passage a l'allocation dynamique le 20060214192531...                                     */
#include  xrv/ARITHMET.21.I"
#include  xrv/champs_5.41.I"

#define   VALEUR_IMPLICITE                                                                                                              \
                    FZERO

gGENERATION_D_UN_FICHIER(fichier_des_valeurs,liste_des_valeurs);
                                        /* Definition en memoire du fichier.                                                         */

#define   ELEMENT_DU_FICHIER(index)                                                                                                     \
                    gELEMENT_DU_FICHIER(liste_des_valeurs,index)                                                                        \
                                        /* Acces a un element courant du fichier.                                                    */

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        R E C H E R C H E   D E S   D I V I S E U R S   P R E M I E R S   D ' U N   F I C H I E R   N U M E R I Q U E  :           */
/*                                                                                                                                   */
/*************************************************************************************************************************************/
BCommande(nombre_d_arguments,arguments)
/*-----------------------------------------------------------------------------------------------------------------------------------*/
     Bblock
     DEFV(Logical,INIT(compatibilite_20220528,COMPATIBILITE_20220528));
                                        /* Permet de faire des calculs compatibles a ceux faits anterieurement au 20220528151029...  */


#include  xrv/ARITHMET.22.I"
#include  xci/valeurs.03.I"

     DEFV(Int,INIT(editer_les_diviseurs_premiers,EDITER_LES_DIVISEURS_PREMIERS));
     DEFV(Int,INIT(editer_la_decomposition_en_facteurs_premiers,EDITER_LA_DECOMPOSITION_EN_FACTEURS_PREMIERS));
                                        /* Afin de controler l'edition des diviseurs premiers. L'edition explicite de la             */
                                        /* decomposition a ete introduite le 20220527180441...                                       */
     /*..............................................................................................................................*/
#include  xrv/champs_5.1A.I"
                                        /* Ceci fut introduit le 20070103174019...                                                   */

     GET_ARGUMENTS_(nombre_d_arguments
                   ,BLOC(GET_ARGUMENT_L("compatibilite_20220528=",compatibilite_20220528);

                         PROCESS_ARGUMENT_I("nombre_elements=""ne=",nombre_d_elements
                                           ,BLOC(VIDE;)
                                           ,BLOC(Bblock
                                                 PRINT_AVERTISSEMENT("'ne=' doit etre defini avant toute entree de fichiers");
                                                 Eblock
                                                 )
                                            );

                         PROCESS_ARGUMENTS_DE_DEFINITION_DES_FICHIERS_01;

                         PROKESF_ARGUMENT_FICHIER("fichier="
                                                 ,fichier_des_valeurs
                                                 ,liste_des_valeurs
                                                 ,VALEUR_IMPLICITE
                                                 ,lTRANSFORMAT_0d
                                                 ,iGENERATION_D_UN_FICHIER
                                                  );

                         PROCESS_ARGUMENTS_DE_PARAMETRAGE_DE_LA_GENERATION_DE_SUITE_DE_VALEURS_3;
                                        /* Cette procedure fut introduite le 20070103174019...                                       */

                         PROCESS_ARGUMENTS_DE_PARAMETRAGE_DE_LA_GENERATION_DE_SUITE_DE_VALEURS_1;
                                        /* Cette procedure fut introduite le 20061226192554...                                       */

                         GET_ARGUMENT_L("editer_diviseurs_premiers=""edp=",editer_les_diviseurs_premiers);
                         GET_ARGUMENT_L("editer_decomposition_facteurs_premiers=""edfp=",editer_la_decomposition_en_facteurs_premiers);
                                        /* Cette option fut introduite le 20220527180441...                                          */

                         PROCESS_ARGUMENTS_DE_PARAMETRAGE_DE_LA_GENERATION_DE_SUITE_DE_VALEURS_5;
                                        /* Cette procedure fut introduite le 20211005104154...                                       */
                         )
                    );

     Test(IFET(IL_NE_FAUT_PAS(editer_les_diviseurs_premiers)
              ,IL_FAUT(editer_la_decomposition_en_facteurs_premiers)
               )
          )
          Bblock
          PRINT_ATTENTION("la decomposition en facteurs premiers implique l'edition des diviseurs premiers");
          Eblock
     ATes
          Bblock
          Eblock
     ETes

     gOPERATION_SUR_LES_FICHIERS(BLOC(
                                      DEFV(Float,INIT(valeur_courante,ELEMENT_DU_FICHIER(index)));
                                        /* Recuperation de la valeur courante dans le fichier.                                       */

                                      Test(N_EST_PAS_ENTIER(valeur_courante))
                                           Bblock
                                           PRINT_ERREUR("une valeur n'est pas entiere");
                                           CAL1(Prer1("(il s'agit de %f)\n",valeur_courante));
                                           Eblock
                                      ATes
                                           Bblock
                                           Eblock
                                      ETes

                                      Repe(COND(IFET(IL_FAUT(editer_les_diviseurs_premiers)
                                                    ,IL_FAUT(editer_la_decomposition_en_facteurs_premiers)
                                                     )
                                               ,DEUX
                                               ,UN
                                                )
                                           )
                                           Bblock
                                           DEFV(Int,INIT(nombre_courant,UNDEF));
                                           DEFV(Int,INIT(nombre_courant_reduit,UNDEF));
                                           DEFV(Int,INIT(diviseur_courant,UNDEF));
                                           DEFV(Int,INIT(diviseur_SquareFree,UN));
                                           DEFV(Int,INIT(nombre_de_diviseurs_premiers,ZERO));
                                           DEFV(Int,INIT(dernier_diviseur,UNDEF));
                                           DEFV(Logical,INIT(c_est_le_premier_facteur,VRAI));
                                        /* Donnees utiles...                                                                         */

                                           EGAL(nombre_courant,INTE(valeur_courante));
                                           EGAL(nombre_courant_reduit,nombre_courant);

                                           Test(IFEQ(compteur_des_repetitions_du_Repe,PREMIERE_ITERATION_D_UN_Repe))
                                                Bblock
                                                CAL2(Prin1("NombreEntier=%d",nombre_courant));
                                        /* Edition du nombre entier courant a tester...                                              */

                                                Test(IFET(IL_FAUT(editer_les_diviseurs_premiers)
                                                         ,IL_NE_FAUT_PAS(editer_la_decomposition_en_facteurs_premiers)
                                                          )
                                                     )
                                                     Bblock
                                                     CAL2(Prin0(" "));
                                                     Eblock
                                                ATes
                                                     Bblock
                                                     Eblock
                                                ETes
                                                Eblock
                                           ATes
                                                Bblock
                                                Eblock
                                           ETes

                                           Test(IFOU(IL_FAUT(compatibilite_20220528)
                                                    ,IFET(IL_NE_FAUT_PAS(compatibilite_20220528)
                                                         ,IFGE(nombre_courant,PREMIER_DIVISEUR)
                                                          )
                                                     )
                                                )
                                                Bblock
                                                EGAL(dernier_diviseur,DIVI(nombre_courant,PREMIER_DIVISEUR));

                                                DoIn(diviseur_courant,PREMIER_DIVISEUR,dernier_diviseur,I)
                                                     Bblock
                                                     DEFV(Int,INIT(exposant,ZERO));

                                                     Tant(IZEQ(REST(nombre_courant_reduit,diviseur_courant)))
                                                          Bblock
                                                          EGAL(nombre_courant_reduit,DIVI(nombre_courant_reduit,diviseur_courant));
                                                          INCR(exposant,I);
                                                          INCR(nombre_de_diviseurs_premiers,I);
                                        /* Cas ou le nombre courant n'est pas premier...                                             */
                                                          Eblock
                                                     ETan

                                                     Test(IZGT(exposant))
                                                          Bblock
                                                          EGAL(diviseur_SquareFree,MUL2(diviseur_courant,diviseur_SquareFree));
                                                          Eblock
                                                     ATes
                                                          Bblock
                                                          Eblock
                                                     ETes

                                                     Test(IL_FAUT(editer_les_diviseurs_premiers))
                                                          Bblock
                                                          Test(IZGT(exposant))
                                                               Bblock
                                                               Test(IL_NE_FAUT_PAS(editer_la_decomposition_en_facteurs_premiers))
                                                                    Bblock
                                                                    CAL2(Prin2("DiviseurPremier=%d:%d ",diviseur_courant,exposant));
                                                                    Eblock
                                                               ATes
                                                                    Bblock
                                                                    Test(EST_VRAI(c_est_le_premier_facteur))
                                                                         Bblock
                                                                         CAL2(Prin0(" "));
                                                                         EGAL(c_est_le_premier_facteur,FAUX);
                                                                         Eblock
                                                                    ATes
                                                                         Bblock
                                                                         CAL2(Prin0("x"));
                                                                         Eblock
                                                                    ETes

                                                                    CAL2(Prin5("%d%c%c%s(%d)"
                                                                              ,diviseur_courant
                                                                              ,K_VERITABLE_ANTI_QUOTE
                                                                              ,K_VERITABLE_APOSTROPHE
                                                                              ,"MiseEnExposant"
                                                                              ,COND(IFEQ(compteur_des_repetitions_du_Repe
                                                                                        ,PREMIERE_ITERATION_D_UN_Repe
                                                                                         )
                                                                                   ,exposant
                                                                                   ,UN
                                                                                    )
                                                                               )
                                                                         );
                                        /* Edition introduite le 20220527180441. On notera que le format est celui utile pour les    */
                                        /* fichiers de '$xiM'...                                                                     */
                                                                    Eblock
                                                               ETes
                                                               Eblock
                                                          ATes
                                                               Bblock
                                                               Eblock
                                                          ETes
                                                          Eblock
                                                     ATes
                                                          Bblock
                                                          Eblock
                                                     ETes
                                                     Eblock
                                                EDoI

                                                Test(IZEQ(nombre_de_diviseurs_premiers))
                                                     Bblock
                                                     EGAL(diviseur_SquareFree,nombre_courant);
                                        /* Cas ou le nombre courant est premier...                                                   */
                                                     Eblock
                                                ATes
                                                     Bblock
                                                     Eblock
                                                ETes

                                                Test(I3OU(IFET(IFET(IL_FAUT(editer_les_diviseurs_premiers)
                                                                   ,IL_FAUT(editer_la_decomposition_en_facteurs_premiers)
                                                                    )
                                                              ,IFGT(compteur_des_repetitions_du_Repe,PREMIERE_ITERATION_D_UN_Repe)
                                                               )
                                                         ,IFET(IL_FAUT(editer_les_diviseurs_premiers)
                                                              ,IL_NE_FAUT_PAS(editer_la_decomposition_en_facteurs_premiers)
                                                               )
                                                         ,IL_NE_FAUT_PAS(editer_les_diviseurs_premiers)
                                                          )
                                                     )
                                                     Bblock
                                                     Test(IFOU(IFET(IL_FAUT(editer_les_diviseurs_premiers)
                                                                   ,IL_FAUT(editer_la_decomposition_en_facteurs_premiers)
                                                                    )
                                                              ,IL_NE_FAUT_PAS(editer_les_diviseurs_premiers)
                                                               )
                                                          )
                                                          Bblock
                                                          CAL2(Prin0(" "));
                                                          Eblock
                                                     ATes
                                                          Bblock
                                                          Eblock
                                                     ETes

                                                     Test(IZEQ(nombre_de_diviseurs_premiers))
                                                          Bblock
                                                          Test(IL_FAUT(editer_les_diviseurs_premiers))
                                                               Bblock
                                                               CAL2(Prin1("EstPremier=%d ",nombre_courant));
                                                               Eblock
                                                          ATes
                                                               Bblock
                                                               Eblock
                                                          ETes
                                                          Eblock
                                                     ATes
                                                          Bblock
                                                          Eblock
                                                     ETes

                                                     CAL2(Prin1("Puissance=%+.^^^"
                                                               ,DIVI(LOGX(FLOT(nombre_courant)),LOGX(FLOT(diviseur_SquareFree)))
                                                                )
                                                          );
                                        /* L'edition de la puissance a ete introduite le 20120926081220. Elle donne l'exposant       */
                                        /* auquel il faut elever le radical d'un nombre pour retrouver ce nombre :                   */
                                        /*                                                                                           */
                                        /*                                          Puissance                                        */
                                        /*                  nombre = Radical(nombre)                                                 */
                                        /*                                                                                           */

                                                     CAL2(Prin1(" Radical=%d",diviseur_SquareFree));
                                        /* Et enfin, edition de la valeur importante. Le diviseur "square free" est egal au produit  */
                                        /* des diviseurs premiers avec un exposant egal a 1 (meme si leur degre de multiplicite est  */
                                        /* superieur a 1)...                                                                         */
                                        /*                                                                                           */
                                        /* On notera que ce "DiviseurSquareFree" est aussi appele "Radical", d'ou le changement de   */
                                        /* nom le 20120926081220...                                                                  */
                                                     Eblock
                                                ATes
                                                     Bblock
                                                     Eblock
                                                ETes
                                                Eblock
                                           ATes
                                                Bblock
                                                PRINT_ATTENTION("un nombre n'est pas reconnu");
                                                CAL1(Prer1("(il s'agit de %d)\n",nombre_courant));
                                        /* Messages introduits le 20220528151029...                                                  */
                                                Eblock
                                           ETes
                                           Eblock
                                      ERep

                                      CAL2(Prin0("\n"));
                                      )
                                ,FLOT__UNDEF
                                ,NE_PAS_EDITER_LA_VALEUR_RESULTANTE_DANS_gOPERATION_SUR_LES_FICHIERS
                                ,nombre_d_exemplaires_du_resultat_de_l_operation_sur_les_valeurs_courantes
                                 );
                                        /* Reformatage eventuel des valeurs...                                                       */

     lGENERATION_D_UN_FICHIER(liste_des_valeurs,VALEUR_IMPLICITE);

     RETU_Commande;
     Eblock
ECommande



Copyright © Jean-François COLONNA, 2019-2024.
Copyright © CMAP (Centre de Mathématiques APpliquées) UMR CNRS 7641 / École polytechnique, Institut Polytechnique de Paris, 2019-2024.