From 0ef7a0b50931528fa891f9b86256606b526199f7 Mon Sep 17 00:00:00 2001 From: Naej Date: Mon, 26 Dec 2016 20:13:35 +0100 Subject: [PATCH] =?UTF-8?q?ajout=C3=A9=20le=20sum?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LibAutomaton/matrix.c | 28 ++++++++++++++++++++++++++-- LibAutomaton/matrix.h | 1 + 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/LibAutomaton/matrix.c b/LibAutomaton/matrix.c index dad465a..1a5e554 100644 --- a/LibAutomaton/matrix.c +++ b/LibAutomaton/matrix.c @@ -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