mirror of
https://gitlab.com/klmp200/LO27.git
synced 2024-11-05 06:38:03 +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.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){
|
||||
@ -310,9 +310,33 @@ Matrix freeMatrix(Matrix 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 :
|
||||
*finir le freeMatrix
|
||||
*mulMatrix
|
||||
*
|
||||
*chasser les bugs
|
||||
*ecrire doc
|
||||
*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 sumMatrix(Matrix matrix1,Matrix matrix2);
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user