diff --git a/LibMatrix/matrix.c b/LibMatrix/matrix.c index 873117f..ec902a9 100644 --- a/LibMatrix/matrix.c +++ b/LibMatrix/matrix.c @@ -35,10 +35,7 @@ Matrix applyRules (Matrix matrix,int Rules, int N){ tempMatrix2 = matrixFromRules(tempMatrix1,i, RulesMatrix); freeMatrix(tempMatrix1); - tempMatrix1.colCount = tempMatrix2.colCount; - tempMatrix1.rowCount = tempMatrix2.rowCount; - tempMatrix1.cols = tempMatrix2.cols; - tempMatrix1.rows = tempMatrix2.rows; + tempMatrix1 = tempMatrix2; } return tempMatrix1; @@ -621,10 +618,81 @@ bool * GetFromRules(Matrix m, int ColPos, int RowPos, int n, int rules[]){ } +bool isMatrixEmpty(Matrix matrix){ + if (matrix.colCount < 1 || matrix.rowCount < 1){ + return true; + } + if (matrix.cols->size == 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