Bonjour,
s'il vous plait je suis debutant en programmation et j'ai fait un programme en C sous l'IDE codeblocks, qui utilise les elements d'une matrice pour faire un calcule d'un algorithme d'inference.
Enfait le problem c'est que je veut pas que la saisie des elements de la matrice soit manuelle pour cela j'ai une interface graphique qui a eté faite par une autre personne et je veut placer ma matrice dans un fichier texte et charger le fichier a partir de l'interface graphique que je doit modifier sont code car elle a eté faite par une autre personne.
Voila le lien pour voir l'interface graphique: http://dl.dropbox.com/u/6986026/interface_JIN.rar
et voila mon programme en codeblocks qui fonctionne tres bien
/**************************************************************/
/***************** Analyse d'impacts ****************/
/**************************************************************/
#include <stdio.h>
#include <math.h>
#define MAXSIZE 8// taille des tableaux
/****************************************************/
/************* Prototypes des fonctions *************/
/****************************************************/
void create_matrix(float *, int, int);
void display_matrix(float *, int, int);
int compute(float *, float *, int dim);
/****************************************************/
/************* Fonction Principale **************/
/****************************************************/
int main (int argc, const char * argv[]) {
int dim;
int toto;
float e[MAXSIZE * MAXSIZE];
float c[MAXSIZE];
printf ("\nQuelle est la dimention de la matrice? (Max %d) \t",MAXSIZE);
scanf ("%d",&dim);
printf ("\n le nombre d'iteration est %d\n", compute(e,c,dim));
scanf("%d", &toto);
getchar();
return 0;
}
/****************************************************/
/************* Fonction Secondaires **************/
/****************************************************/
/*******************************************************************/
/****** Fonction pour créer une matrice [taille_1 x taille_2] ******/
/*******************************************************************/
void create_matrix(float *tableau, int taille_1, int taille_2 )
{
int i_t1, i_t2;
for ( i_t1= 0; i_t1 < taille_1; i_t1++)
{
printf ("Line %d:\t",i_t1);
for ( i_t2 = 0; i_t2 < taille_2; i_t2++)
scanf ("%f",&tableau[((i_t1 * taille_1) + i_t2)]);
printf ("\n");
}
}
/*******************************************************************/
/****** Fonction pour afficher une matrice [taille_1 x taille_2] ***/
/*******************************************************************/
void display_matrix(float *tableau, int taille_1, int taille_2 )
{
int i_t1, i_t2;
for (i_t1 = 0; i_t1 < taille_1; i_t1++)
{
for ( i_t2 = 0; i_t2 < taille_2; i_t2++)
printf ("%f\t", tableau[((i_t1 * taille_1) + i_t2)]);
}
printf ("\n");
}
/*******************************************************************/
/***** Fonction pour calculer et rechercher le point d'équilibre ***/
/*******************************************************************/
int compute(float *e, float *c, int dim)
{
int vecteur_egaux, k;
float r[MAXSIZE];
float a[MAXSIZE];
float b[MAXSIZE];
int i=0;
int j=0;
int nb_iteration;
nb_iteration=0;
vecteur_egaux = 0;
k=0;
printf ("\n\n\n\t******* CREATION DE LA MATRICE E *******\n");
printf ("\n*******Saisie de la matrice E*******\n\n");
create_matrix(e, dim, dim);
printf ("\n\t******* CREATION DU VECTEUR C *******\n");
printf ("\n*******Saisie de la matrice C*******\n\n");
create_matrix(c, 1, dim);
printf("saisir la valeur du gain:\n");
scanf("%d",&k);
for (i = 0; i < dim; i++)
{
a[i]=c[i];
}
while (!vecteur_egaux)
{
for (i = 0; i < dim; i++)
{
b[i]=c[i];
}
for (i = 0; i < dim; i++)
{
r[i] = 0;
for (j = 0; j < dim; j++)
{
r[i] += c[j] * e[i + (j * dim)];
}
}
vecteur_egaux = 1;
for (i = 0; i < dim; i++)
{
c[i]=((1) / (1+ (expf ( -k*r[i] ) )))+ a[i];
/*c[i]=((expf (2 * r[i]) - 1) / (expf (2 * r[i]) + 1))+ a[i];*/
}
for (i = 0; i < dim; i++)
{
if (c[i] != b[i])
{
vecteur_egaux = 0;
}
}
printf ("\n");
nb_iteration++;
printf ("\n*******VECTEUR C:\n");
display_matrix(c, 1,dim);
printf ("\n*******VECTEUR R:\n");
display_matrix(r, 1,dim);
}
printf ("\n\n\n\t\t*******RESULTAT*******\n\n\n");
return nb_iteration;
}
/****************** The end *********************************/