mirror of
https://gitlab.com/klmp200/LO27.git
synced 2024-11-23 02:33:19 +00:00
ajouté le sum
This commit is contained in:
parent
b063bc42c0
commit
0ef7a0b509
@ -297,7 +297,7 @@ Matrix freeMatrix(Matrix matrix){
|
|||||||
|
|
||||||
matrix.colCount = 0;
|
matrix.colCount = 0;
|
||||||
matrix.rowCount = 0;
|
matrix.rowCount = 0;
|
||||||
/*il faut free les cellElements car FreeList ne peut pas le faire*/
|
|
||||||
if (matrix.cols != NULL){
|
if (matrix.cols != NULL){
|
||||||
current= matrix.cols->head;
|
current= matrix.cols->head;
|
||||||
while (current != NULL){
|
while (current != NULL){
|
||||||
@ -310,9 +310,33 @@ Matrix freeMatrix(Matrix matrix){
|
|||||||
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* 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
|
||||||
|
@ -131,6 +131,7 @@ bool RecursiveFreeCol(Matrix matrix, cellElement * elem);
|
|||||||
|
|
||||||
Matrix freeMatrix(Matrix matrix);
|
Matrix freeMatrix(Matrix matrix);
|
||||||
|
|
||||||
|
Matrix sumMatrix(Matrix matrix1,Matrix matrix2);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user