diff --git a/LibAutomaton/CellElement.h b/LibAutomaton/CellElement.h index 1a886bd..c354609 100644 --- a/LibAutomaton/CellElement.h +++ b/LibAutomaton/CellElement.h @@ -15,7 +15,7 @@ typedef enum Bool{ /*---cellElement--- -*Pointer on a cell of the matrix +*A cell of the matrix * *@colIndex : index (int) of the column of this cell *@rowIndex : index (int) of the row of this cell diff --git a/LibAutomaton/Makefile b/LibAutomaton/Makefile index 7921ba1..3778091 100644 --- a/LibAutomaton/Makefile +++ b/LibAutomaton/Makefile @@ -7,7 +7,7 @@ INCLUDEDIR=-I/usr/include -I. #Library variables LIBTARGET=libAutomaton.so -LIBSOURCE=list CellElement +LIBSOURCE=list CellElement matrix LIBSOURCECFILE=$(LIBSOURCE:=.c) LIBSOURCEOFILE=$(LIBSOURCE:=.o) diff --git a/LibAutomaton/Matrix.h b/LibAutomaton/Matrix.h new file mode 100644 index 0000000..afe6c13 --- /dev/null +++ b/LibAutomaton/Matrix.h @@ -0,0 +1,41 @@ +#ifndef MTRXGAUD_H +#define MTRXGAUD_H + +#include +#include + +/*---Matrix--- +*Abstract type that describe a boolean matrix +* +*@colCount : the number of columns of the matrix +*@rowIndex : the number of rows of the matrix +* +*@rows : pointer on the first row that contains a true value +*@cols : pointer on the first col that contains a true value +* +*/ +typedef struct Matrix { + + int colCount; + int rowCount; + + List *cols; + List *rows; + +}Matrix; + + +/*---applyRules--- +*A function tha allows you to apply some rules n times on the matrix and returns it +* +*@matrix : A matrix on whitch you would apply the rules +* +*@Rules : Integer describing the rules +* +*@N : number of time the rules will be applied +* +*/ +Matrix applyRules (Matrix matrix,int Rules, int N); + +#endif + diff --git a/LibAutomaton/matrix.c b/LibAutomaton/matrix.c new file mode 100644 index 0000000..c6264cc --- /dev/null +++ b/LibAutomaton/matrix.c @@ -0,0 +1,22 @@ +#include +#include +#include + +Matrix applyRules (Matrix matrix,int Rules, int N){ + int pow = 2; + int i = 0; + if (Rules <= 0){ + return matrix; + } else { + while (Rules%pow == 0 ){ + pow*=2; + } + for (i=0;i #include -#include -#include +#include int main(int argc, char **argv){ - + Matrix matrix; + int Rule = 170; + int N = 1; + applyRules (matrix,Rule,N); +/* + Matrix matrix; cellElement * tree = NULL; + List * cols = NULL; + List * rows = NULL; + + cols = CreateList(); + rows = CreateList(); + tree = CreateCellElem(); SetPositionIndex(tree,1,1); @@ -33,7 +43,7 @@ int main(int argc, char **argv){ removeNextCol(tree); recursivePrint(tree); - +*/ return 0; }