1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| //la fonction chargée de la décomposition de la matrice
int* decomposition(int N,int **matrice)
{
int found,I,J,i=0;
int *Tab;
int k=0;
Tab = (int*)malloc( sizeof(int*)*(N));
for(J=0;J<N;J++){
for(I=0;I<N;I++){
if(matrice[I][J] ==0)
found=0;
else
found =1;
}
if(found == 0){
matrice= suppElem( matrice, N, J );
Tab[i]=J;
i++;
}
else
J++;
}
return Tab;
}
//la fonction chargée de la suppression de la colonne avec la ligne correspondante
int** suppElem( int** matrice, int N, int elem_a_sup ){
int i, j, l = 0,c = 0;
int **Mat1=NULL,**Mat2=NULL;
Mat1 = (int**) malloc( sizeof(int*) * (N-1) );
if( Mat1 != NULL )
for( i=0; i<(N-1); i++ )
Mat1[i] = (int*) malloc( sizeof(int) * (N-1) );
Mat2 = (int**) malloc( sizeof(int*) * (N-1) );
if( Mat2 != NULL )
for( i=0; i<(N-1); i++ )
Mat2[i] = (int*) malloc( sizeof(int) * (N-1) );
for( j=0; j<N; j++ ){
if( j != elem_a_sup ) {
for( i=0; i<N; i++ )
{
Mat1[l][c] = matrice[i][j];
l++;
}
c++;
l=0;}
}
for( i=0; i<N; i++ ){
if( i != elem_a_sup )
for( j=0; j<N; j++ )
{
Mat2[l][c] = matrice[i][j];
c++;
}
l++;
c=0;
}
for( i=0; i<N; i++ )
free( Mat1[i] );
free( Mat1 );
return Mat2;
} |
Partager