/*************************************************************************************************************************************/
/* */
/* P R O B L E M E D E L I N E A R I T E D A N S L ' I N T E R P O L A T I O N " E N T I E R E " : */
/* */
/* */
/* Author of '$xtc/interpolation.01$c' : */
/* */
/* Jean-Francois COLONNA (LACTAMME, 20180624083241). */
/* */
/*************************************************************************************************************************************/
#include <stdio.h>
extern double floor();
#define NEUT(x) \
(x)
#define NEGA(x) \
(-(x))
#define ADD2(x,y) \
((x)+(y))
#define FLOT(x) \
((double)(x))
#define ENTIER_FLOTTANT(x) \
AINT_a_peu_pres(x,epsilon_de_conversion_entier)
#define AINT_a_peu_pres(x,epsilon) \
AINT((x+epsilon))
#define AINT(x) \
FLOT(floor((double)x))
#define DIS2(x,a,b) \
((x)*(a+b))
#define BAR2(point1,point2,lambda) \
ADD2(DIS2(point1,NEUT(1),NEGA(lambda)) \
,DIS2(point2,NEUT(lambda),NEGA(0)) \
)
#define BARY(origine,extremite,lambda) \
BAR2(origine,extremite,lambda)
/* Afin de definir 'BARY(...)' pour definir 'v $xiii/aleat.2$vv$DEF INTERPOLATION_LINEAIRE' */
/* qui elle-meme permet de definir 'v $xci/valeurs.02$I iINTERPOLATION_LINEAIRE'. */
main()
{
int np,npA=0,npB=22;
/* Il y a donc probleme avec 'npB=22' mais pas pour beaucoup d'autres valeurs et par */
/* exemple 'npB=23'... */
#define vnpA \
FLOT(npA)
#define vnpB \
FLOT(npB)
double epsilon_de_conversion_entier=0;
/* Le probleme disparait a partir de 'epsilon=0.0000000000000009' (comme evidemment dans */
/* 'v $xci/valeurs_inte$K epsilon='...). */
for (np=npA ; np<=npB ; np++)
{
double lambda=(np-vnpA)/(vnpB-vnpA);
double valeur_courante_interpolee=BARY(vnpA,vnpB,lambda);
/* Ceci est "inspire" de 'v $xci/valeurs_inte$K iINTERPOLATION_LINEAIRE'... */
printf("np=%d valeur_courante_interpolee=%.17g (int)valeur_courante_interpolee=%.17g\n"
,np
,valeur_courante_interpolee
,ENTIER_FLOTTANT(valeur_courante_interpolee)
);
/* Voir le probleme decrit dans 'v $xiirv/.PUZZ.11.1.$U 20180623120530' ou encore dans */
/* 'v $xci/valeurs_inte$K 20180623121923'... */
}
}