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