mirror of
				https://gitlab.com/klmp200/LO27.git
				synced 2025-10-30 04:43:52 +00:00 
			
		
		
		
	Commencé matrices, l'exe ne veut plus se lancer pour des questions de build
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
| @@ -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) | ||||
|  | ||||
|   | ||||
							
								
								
									
										41
									
								
								LibAutomaton/Matrix.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								LibAutomaton/Matrix.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,41 @@ | ||||
| #ifndef MTRXGAUD_H | ||||
| #define MTRXGAUD_H | ||||
|  | ||||
| #include <CellElement.h> | ||||
| #include <list.h> | ||||
|  | ||||
| /*---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 | ||||
|   | ||||
							
								
								
									
										22
									
								
								LibAutomaton/matrix.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								LibAutomaton/matrix.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | ||||
| #include <stdio.h> | ||||
| #include <stdlib.h> | ||||
| #include <Matrix.h>  | ||||
|  | ||||
| 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<N;i++){ | ||||
| 			printf("Apply rule %d \n",Rules%pow);  | ||||
| 			/*Replace it by the implementation of the rules*/ | ||||
| 		}  | ||||
| 		 | ||||
| 		applyRules(matrix,Rules - Rules%pow,N); | ||||
| 	} | ||||
| 	return matrix; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user