#!/bin/csh

#######################################################################################################################################
#                                                                                                                                     #
#         C O N V E R S I O N   D ' U N   P O L Y N O M E   A   C O E F F I C I E N T S   E N T I E R S                               #
#         E N   U N   R A T I O N N E L   I R R E D U C T I B L E  :                                                                  #
#                                                                                                                                     #
#                                                                                                                                     #
#         Utilisation :                                                                                                               #
#                                                                                                                                     #
#                   $xcg/PolynomeRationnel.01$vv$Z          <ListeCoefficients>                                                       #
#                                                                                                                                     #
#                                                                                                                                     #
#         Nota :                                                                                                                      #
#                                                                                                                                     #
#                     Voir 'v $xcg/RationnelPolynome.01$vv$Z'                                                                         #
#                   pour effectuer la conversion inverse...                                                                           #
#                                                                                                                                     #
#                                                                                                                                     #
#         Author of '$xcg/PolynomeRationnel.01$vv$Z' :                                                                                #
#                                                                                                                                     #
#                     Jean-Francois Colonna (LACTAMME, 20200604095705).                                                               #
#                                                                                                                                     #
#######################################################################################################################################

set       ListeCoefficients=($1)

set       ListeCoefficients=`echo "$ListeCoefficients" | $R "," "$K_BLANC"`

set       Numerateur=1
set       Denominateur=1

set       NoMbRe=100
                                        # Valeur arbitraire...                                                                        #
set       LNombresPremiers=`$xci/valeurs_Goldbach$X p=1 d=$NoMbRe editer_nombres_premiers=VRAI calculer_decompositions=FAUX`
                                        # Liste des premiers nombres premiers...                                                      #

set       InDiCe=$#ListeCoefficients

set       Polynome="$K_VIDE"

foreach   Coefficient ($ListeCoefficients)
          set       CoefficientNS=`echo "$Coefficient" | $SE -e "s/^+//"`
          set       VCoefficient=`calculINS $CoefficientNS`

          if        ("$CoefficientNS" == "$VCoefficient") then
          else
                    EROR      "Le coefficient (=$Coefficient) doit etre entier."
          endif

          set       CoefficientNS=$VCoefficient

          set       NombrePremier=$LNombresPremiers[$InDiCe]

          if        ($CoefficientNS == 0) then
          else
                    @         Exposant = $InDiCe - 1
                    set       Polynome="$Polynome""$Coefficient""*""(X^$Exposant)"

                    if        ($CoefficientNS < 0) then
                              set       Denominateur=`calculINS $Denominateur*pow($NombrePremier,-($CoefficientNS))`
                    else
                              if        ($CoefficientNS > 0) then
                                        set       Numerateur=`calculINS $Numerateur*pow($NombrePremier,$CoefficientNS)`
                              else
                              endif
                    endif
          endif

          @         InDiCe = $InDiCe - 1
end

echo      "$Polynome"                                                                                                             |     \
$SE       -e "s/\(+(\)+/\1/g"                                                                                                           \
          -e "s/+\((\)\(-\)/\2\1/g"                                                                                                     \
          -e"s/^\((\)\(.\)/\2\1/g"                                                                                                      \
          -e "s/\((\)\([$Alphabet_0_9]*\*\)/\2\1/g"                                                                                     \
          -e "s/\([-+]\)1\*/\1/g"                                                                                                       \
          -e "s/^1\*//"                                                                                                                 \
          -e 's/+$//'                                                                                                                   \
          -e "s/(X\^0)/1/g"                                                                                                             \
          -e "s/\([^$Alphabet_0_9][$Alphabet_0_9]*\)\*1"'$/\1/'                                                                         \
          -e 's+$'"+ ==> R=$Numerateur/$Denominateur+"



Copyright © Jean-François Colonna, 2020-2021.
Copyright © CMAP (Centre de Mathématiques APpliquées) UMR CNRS 7641 / Ecole Polytechnique, 2020-2021.