From 281adf9893c545e32d576fb7ac626b8b1b0eac18 Mon Sep 17 00:00:00 2001 From: Naej Date: Thu, 29 Dec 2016 15:25:02 +0100 Subject: [PATCH] =?UTF-8?q?fait=20les=20fx=20de=20merde=20demand=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LibMatrix/matrix.c | 119 +++++++++++++++++++++++++++++++++++++++++++-- LibMatrix/matrix.h | 18 +++++++ 2 files changed, 133 insertions(+), 4 deletions(-) diff --git a/LibMatrix/matrix.c b/LibMatrix/matrix.c index 873117f..cea56e1 100644 --- a/LibMatrix/matrix.c +++ b/LibMatrix/matrix.c @@ -621,10 +621,121 @@ bool * GetFromRules(Matrix m, int ColPos, int RowPos, int n, int rules[]){ } +Matrix applyRules (Matrix matrix,int Rules, int N){ + int RulesMatrix[9]; + int i = 0; + int power = 2; + int sum = 0; + int j = 0; + Matrix tempMatrix; + + if (Rules <= 0 || N < 1){ + return matrix; + } + + tempMatrix = CreateMatrix(); + + while(power<=512){ + + RulesMatrix[i] = Rules%power - sum; + sum = Rules%power; + + if (RulesMatrix[i]!=0){ + i++; + } + + power*=2; + } + + /* test code : print decomposition */ + /*for (j=0;jsize == 0 || matrix.rows->size == 0){ + return true; + } + return false; +} + +bool isMatrixSquare(Matrix matrix){ + if (matrix.colCount == matrix.rowCount){ + return true; + } + return false; +} + +bool isColumnEmpty(Matrix matrix,int nb){ + ListElement * Col = NULL; + + if (matrix.colCount < 1 || matrix.rowCount < 1){ + return true; + } + if (matrix.cols->size == 0 || matrix.rows->size == 0){ + return true; + } + + Col = GetElementPos(matrix.cols,nb); + if (Col == NULL || Col->data == NULL){ + return true; + } + + return false; +} + +bool isRowEmpty(Matrix matrix,int nb){ + ListElement * Row = NULL; + + if (matrix.colCount < 1 || matrix.rowCount < 1){ + return true; + } + if (matrix.cols->size == 0 || matrix.rows->size == 0){ + return true; + } + Row = GetElementPos(matrix.rows,nb); + if (Row == NULL || Row->data == NULL){ + return true; + } + + return false; +} + +bool equalsMatrix(Matrix m1, Matrix m2){ + int i = 0; + int j = 0; + + if (m1.colCount == m2.colCount && m1.rowCount == m2.rowCount){ + for (i=0;i