/*************************************************************************************************************************************/ /* */ /* A I D E A U P R O D U I T N O N T H E O R I Q U E D E D E U X Q U A T E R N I O N S : */ /* */ /* */ /* ATTENTION : */ /* */ /* Je note le 20100109100731 que cela ne marche */ /* pas tres bien car, en effet, dans le cas ou */ /* 'racine_a' est un angle, elle est "modulo" dans */ /* [0,2.pi] ce que ne prennent pas en compte les */ /* formules utilisees ! */ /* */ /* */ /* Author of '$xcg/EquaPnThQ.01$K' : */ /* */ /* Jean-Francois COLONNA (LACTAMME, 20100104142932). */ /* */ /*************************************************************************************************************************************/ /*===================================================================================================================================*/ /*************************************************************************************************************************************/ /* */ /* 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 #include maths_compl_fonct_COMMON_EXT /*===================================================================================================================================*/ /*************************************************************************************************************************************/ /* */ /* P A R A M E T R E S : */ /* */ /*************************************************************************************************************************************/ #define NOMBRE_A \ FU #define NOMBRE_B \ FZERO /* Les deux nombres flottants qui parametrent l'equation. */ #define PUISSANCE \ FQUATRE \ /* Le degre du polynome... */ #define PRECISION \ gEPSILON \ /* Precision de la resolution (passee de 'mgEPSILON' a 'gEPSILON' le 20100106120626, ce */ \ /* est plus en accord avec la definition du type 'Float'...). */ #define INITIALISER_AUTOMATIQUEMENT_L_ELEMENT_NEUTRE \ VRAI #define ELEMENT_NEUTRE_PONDERATION_THETA_ \ FU #define ELEMENT_NEUTRE_PONDERATION_PHI__ \ FZERO #define ELEMENT_NEUTRE_PONDERATION_ALPHA \ FZERO #define EDITER_L_ELEMENT_NEUTRE \ FAUX #define ELEMENT_NEUTRE \ FZERO /* Element neutre 'I' donnant la valeur de 'E(t,0)' dans 'v $ximcd/operator$FON E.t.0.'. */ /* Ceci fut introduit le 20100108084058 et le 20100108145137, l'initialisation automatique */ /* de l'element neutre est passee de 'FAUX' a 'VRAI' (c'est plus logique...). */ #define PONDERATION_RACINE_a \ FU #define PONDERATION_RACINE_b \ FZERO /* Ponderation des resultats... */ #define RACINE_a \ FQUATRE #define RACINE_b \ FLOT__UNDEF /* Valeurs initiales des racines pour la methode iterative. */ #include xcg/ARIT.01.I" #include xci/valeurs.01.I" /*===================================================================================================================================*/ /*************************************************************************************************************************************/ /* */ /* M A C R O S U T I L E S : */ /* */ /*************************************************************************************************************************************/ #include xci/valeurs.02.I" #include xcg/EquaPnThQ.01.I" /*===================================================================================================================================*/ /*************************************************************************************************************************************/ /* */ /* A I D E A U P R O D U I T N O N T H E O R I Q U E D E D E U X Q U A T E R N I O N S : */ /* */ /*************************************************************************************************************************************/ BCommande(nombre_d_arguments,arguments) /*-----------------------------------------------------------------------------------------------------------------------------------*/ Bblock DEFV(Float,INIT(nombre_A,NOMBRE_A)); DEFV(Float,INIT(d_nombre_A,d_FVARIABLES_DE_DERIVATION)); DEFV(Float,INIT(nombre_B,NOMBRE_B)); DEFV(Float,INIT(d_nombre_B,d_FVARIABLES_DE_DERIVATION)); /* Les deux nombres flottants qui parametrent l'equation. */ DEFV(Float,INIT(puissance,PUISSANCE)); DEFV(Float,INIT(d_puissance,d_FVARIABLES_DE_DERIVATION)); /* Le degre du polynome... */ /* */ /* Le 20100104161602, j'ai compris pourquoi il fut impossible d'ecrire : */ /* */ /* DEFV(Float,INIT(exposant,EXPOSANT)); */ /* DEFV(Float,INIT(d_exposant,d_FVARIABLES_DE_DERIVATION)); */ /* */ /* ce qui provoquait le message : */ /* */ /* ...error: invalid suffix "xposant" on integer constant */ /* */ /* dans '$Cc'. Cela venait de 'v $xccp/derive_const$sed d_...0.9.e...0.g' qui donc */ /* remplacait 'd_e' (de "d_exposant") par '0'. */ DEFV(Float,INIT(precision,PRECISION)); /* Precision de la resolution... */ DEFV(Logical,INIT(initialiser_automatiquement_l_element_neutre,INITIALISER_AUTOMATIQUEMENT_L_ELEMENT_NEUTRE)); DEFV(Float,INIT(element_neutre_ponderation_theta_,ELEMENT_NEUTRE_PONDERATION_THETA_)); DEFV(Float,INIT(element_neutre_ponderation_phi__,ELEMENT_NEUTRE_PONDERATION_PHI__)); DEFV(Float,INIT(element_neutre_ponderation_alpha,ELEMENT_NEUTRE_PONDERATION_ALPHA)); DEFV(Logical,INIT(editer_l_element_neutre,EDITER_L_ELEMENT_NEUTRE)); DEFV(Float,INIT(element_neutre,ELEMENT_NEUTRE)); /* Element neutre 'I' donnant la valeur de 'E(t,0)' dans 'v $ximcd/operator$FON E.t.0.'. */ /* Ceci fut introduit le 20100108084058... */ DEFV(Float,INIT(racine_a,RACINE_a)); DEFV(Float,INIT(d_racine_a,d_FVARIABLES_DE_DERIVATION)); DEFV(Float,INIT(racine_b,RACINE_b)); DEFV(Float,INIT(d_racine_b,d_FVARIABLES_DE_DERIVATION)); /* Racines de l'equation ('v $ximcd/operator$FON 20100104120855'). */ DEFV(Float,INIT(ponderation_racine_a,PONDERATION_RACINE_a)); DEFV(Float,INIT(ponderation_racine_b,PONDERATION_RACINE_b)); /* Afin de selection la racine a editer ('a' ou 'b') lors de l'edition finale... */ #include xci/valeurs.03.I" /*..............................................................................................................................*/ GET_ARGUMENTS_(nombre_d_arguments ,BLOC(GET_ARGUMENT_F("nombre_A=""nA=",nombre_A); GET_ARGUMENT_F("nombre_B=""nB=",nombre_B); GET_ARGUMENT_F("puissance=""degre=""exposant=""n=",puissance); GET_ARGUMENT_F("precision=""p=",precision); GET_ARGUMENT_L("element_neutre_automatique=""automatique=""ena=" ,initialiser_automatiquement_l_element_neutre ); GET_ARGUMENT_N("element_neutre_force=""force=""enf=" ,initialiser_automatiquement_l_element_neutre ); GET_ARGUMENT_F("element_neutre_theta=""Ptheta=",element_neutre_ponderation_theta_); GET_ARGUMENT_F("element_neutre_phi=""Pphi=",element_neutre_ponderation_phi__); GET_ARGUMENT_F("element_neutre_alpha=""Palpha=",element_neutre_ponderation_alpha); GET_ARGUMENT_L("editer_element_neutre=""een=",editer_l_element_neutre); /* Arguments introduits le 20100108094847... */ GET_ARGUMENT_F("element_neutre=""neutre=""en=",element_neutre); /* Argument introduit le 20100108084058... */ GET_ARGUMENT_F("racine_a=""ra=",racine_a); /* La valeur ainsi introduite pour 'racine_a' sert de valeur initiale pour la methode */ /* iterative de Newton... */ /* */ /* Le 20100106122346, je supprime : */ /* */ /* GET_ARGUMENT_F("racine_b=""rb=",racine_b); */ /* */ /* qui ne sert a rien (contrairement a 'racine_a' d'apres le commentaire ci-dessus...). */ GET_ARGUMENT_F("ponderation_racine_a=""pra=",ponderation_racine_a); GET_ARGUMENT_F("ponderation_racine_b=""prb=",ponderation_racine_b); PROCESS_ARGUMENTS_DE_PARAMETRAGE_DE_LA_GENERATION_DE_SUITE_DE_VALEURS_1; PROCESS_ARGUMENTS_DE_PARAMETRAGE_DE_LA_GENERATION_DE_SUITE_DE_VALEURS_2; ) ); Test(IL_FAUT(initialiser_automatiquement_l_element_neutre)) Bblock EGAL(element_neutre ,LIZ3(element_neutre_ponderation_theta_,HCargumentT_2PI(HC_____quaternion_p1__0__0__0) ,element_neutre_ponderation_phi__,HCargumentP_2PI(HC_____quaternion_p1__0__0__0) ,element_neutre_ponderation_alpha,HCargumentA_2PI(HC_____quaternion_p1__0__0__0) ) ); /* Introduit le 20100108094847 pour plus de souplesse... */ Eblock ATes Bblock Eblock ETes Test(IL_FAUT(editer_l_element_neutre)) Bblock CAL2(Prin1("ElementNeutre=%+.^^^\n",element_neutre)); /* Introduit le 20100108094847 pour plus de souplesse... */ Eblock ATes Bblock Eblock ETes begin_nouveau_block Bblock DEFV(Logical,INIT(iterer,VRAI)); /* Afin d'iterer... */ DEFV(Float,INIT(Xn_1,racine_a)); DEFV(Float,INIT(d_Xn_1,d_FVARIABLES_DE_DERIVATION)); DEFV(Float,INIT(Xn,FLOT__UNDEF)); DEFV(Float,INIT(d_Xn,d_FVARIABLES_DE_DERIVATION)); /* Variables intermediaires et leurs derivees... */ Tant(IL_FAUT(iterer)) Bblock Test(I3ET(IZGT(Xn_1) ,IFNE(Xn_1,FU) ,IFGT(puissance,FDEUX) ) ) Bblock EGAL(Xn,SOUS(Xn_1,DIVI(EQUATION(Xn_1),d#EQUATION(Xn_1)))); /* Resolution a l'aide de la methode de Newton ('v $ximcf/iterations$FON Newton') : */ /* */ /* EQUATION(X ) */ /* n-1 */ /* X = X - ----------------- */ /* n n-1 dEQUATION(X ) */ /* n-1 */ /* */ /* ou 'dEQUATION(...)' symbolise la derivee de 'EQUATION(...)' par rapport a 'X'... */ Test(IFLE(SOUA(Xn,Xn_1),precision)) Bblock EGAL(iterer,FAUX); /* Lorsque la precision est suffisante, on arrete... */ Eblock ATes Bblock EGAL(Xn_1,Xn); /* Et on itere... */ Eblock ETes Eblock ATes Bblock PRINT_ERREUR("des conditions d'impossibilite de resolution sont rencontrees"); CAL1(Prer1("(ra=%g (doit etre strictement positif et different de 1))\n",Xn_1)); CAL1(Prer1("(puissance=%g (doit etre strictement superieur a 2))\n",puissance)); EGAL(iterer,FAUX); /* Et il faut evidemment s'arreter... */ Eblock ETes Eblock ETan EGAL(racine_a,Xn); EGAL(racine_b,DIVZ(SOUS(nombre_B,MUL2(PUIX(racine_a,puissance),element_neutre)),POLYNOME(racine_a))); /* Calcul des racines 'a' et 'b'... */ Eblock end_nouveau_block EDITION_DE_LA_VALEUR_DE_L_OPERATEUR(LIZ2(ponderation_racine_a,racine_a,ponderation_racine_b,racine_b)); /* Edition des racines {a,b} du systeme d'equation... */ RETU_Commande; Eblock ECommande