1
0
mirror of https://gitlab.com/klmp200/LO27.git synced 2024-11-22 21:53:19 +00:00

Merge branch 'NaejBranch' into 'master'

Naej branch

See merge request !13
This commit is contained in:
Antoine Bartuccio 2016-12-27 21:29:42 +00:00
commit ca80078eb7
3 changed files with 44 additions and 11 deletions

View File

@ -84,7 +84,7 @@ bool CreateMatrixElem(Matrix matrix, int ColPos, int RowPos){
} else if (Col->data->rowIndex > RowPos){ } else if (Col->data->rowIndex > RowPos){
elem->nextRow = Col->data; elem->nextRow = Col->data;
Col->data = elem; Col->data = elem;
} else { } else {NMWZxm5uQt
tmp = Col->data; tmp = Col->data;
while (tmp->nextRow != NULL && tmp->nextRow->rowIndex < RowPos){ while (tmp->nextRow != NULL && tmp->nextRow->rowIndex < RowPos){
tmp=tmp->nextRow; tmp=tmp->nextRow;
@ -296,23 +296,50 @@ bool RecursiveFreeCol(Matrix matrix, cellElement * elem){
Matrix freeMatrix(Matrix matrix){ Matrix freeMatrix(Matrix matrix){
ListElement * current = NULL; int i = 0;
int j = 0;
printf("\n---FREE MATRIX---\n");
for (i=0;i<matrix.rowCount;i++){
for (j=0;j<matrix.colCount;j++){
SetCellValue(matrix,j,i,false);
matrix.colCount = 0;
matrix.rowCount = 0;
/*il faut free les cellElements car FreeList ne peut pas le faire*/
if (matrix.cols != NULL){
current= matrix.cols->head;
while (current != NULL){
RecursiveFreeCol(matrix,current->data);
current = current->next;
} }
} }
printf("---END OF MATRIX---\n\n");
FreeList(matrix.cols); FreeList(matrix.cols);
FreeList(matrix.rows); FreeList(matrix.rows);
return matrix; return matrix;
} }
Matrix sumMatrix(Matrix matrix1,Matrix matrix2){
Matrix SumMatrix = CreateMatrix();
int i =0;
int j = 0;
if (matrix1.colCount == matrix2.colCount && matrix1.rowCount == matrix2.rowCount){
SumMatrix = SetMatrixDim(SumMatrix,matrix2.colCount,matrix1.rowCount);
for (i=0;i<SumMatrix.colCount;i++){
for (j=0;j<SumMatrix.rowCount;j++){
SetCellValue(SumMatrix,i,j,GetCellValue(matrix1,i,j)+GetCellValue(matrix2,i,j));
}
}
}else{
printf("\n- error : Matrices haven't the same size -\n");
SumMatrix.colCount = -1;
SumMatrix.rowCount = -1;
}
return SumMatrix;
}
Matrix colSequenceOnMatrix(Matrix m, bool (operator)(bool, bool)){ Matrix colSequenceOnMatrix(Matrix m, bool (operator)(bool, bool)){
bool a; bool a;
@ -448,7 +475,8 @@ void FreeBooleanMatrix(BooleanMatrix matrix){
} }
/* todos : /* todos :
*finir le freeMatrix *mulMatrix
*
*chasser les bugs *chasser les bugs
*ecrire doc *ecrire doc
*faire un print + opti pour que sli l'adapte avec sdl *faire un print + opti pour que sli l'adapte avec sdl

View File

@ -230,6 +230,8 @@ Matrix andRowSequenceOnMatrix(Matrix m);
* @return matrix the copmuted matrix * @return matrix the copmuted matrix
*/ */
Matrix orRowSequenceOnMatrix(Matrix m); Matrix orRowSequenceOnMatrix(Matrix m);
Matrix sumMatrix(Matrix matrix1,Matrix matrix2);
#endif #endif

3
main.c
View File

@ -43,6 +43,9 @@ int main(int argc, char **argv){
freeMatrix(m2); freeMatrix(m2);
m2 = rowSequenceOnMatrix(matrix, AND); m2 = rowSequenceOnMatrix(matrix, AND);
BasicPrintMatrix(m2); BasicPrintMatrix(m2);
/*sumMatrix(matrix,m2);*/
freeMatrix(m2); freeMatrix(m2);
freeMatrix(matrix); freeMatrix(matrix);