Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int GaussSeidel(int dimension, double** Matrice_A2, double* Matrice_B)
- {
- int i, k, condition = 0, cdt_roulement = 3;
- double crit_arret = 0,001, sommeA, sommeB, norme1, norme2;
- double** MatriceX = NULL;
- MatriceX = (double**) malloc (sizeof(double*)*3);
- for (i=0; i<n; i++)
- {
- MatriceX[i]=(double*) malloc (sizeof(double)*3);
- }
- for( k = 0; k<dimension; k++)
- MatriceX[k][1] = 1; // Cette boucle nous permet d'initialiser le premier tour du vecteur x(i)[0]
- do
- {
- for(k=0; k<dimension; k++)
- MatriceX[k][0] = MatriceX[k][1]; // Le vecteur 0 est changé de plus en plus précis à chaque fois que le critere n'est pas atteint.
- for(k = 1; k<3; k++)
- {
- for(i = 1; i<dimension; i++)
- {
- sommeA = 0;
- sommeB = 0;
- for(j = 0; j< i-1; j++)
- sommeA = sommeA + Matrice_A[i][j]*MatriceX[j][k];
- for(j = i; j<dimension; j++)
- sommeB = somme B + Matrice_A[i][j]*MatriceX[j][k];
- MatriceX[i][k+1] = (Matrice_B[i] - sommeA - sommeB)/Matrice_A2[i][i];
- }
- }
- norme1 = 0;
- norme2 = 0;
- for(i = 0; i<n; i++)
- {
- norme1 = norme1 + fabs(MatriceX[i][1]);
- norme2 = norme2 + fabs(MatriceX[i][2]);
- }
- if(fabs(norme1 - norme2) < crit_arret)
- {
- condition = 1;
- }
- }while(condition != 1);
- return true;
- }
Add Comment
Please, Sign In to add comment