This commit is contained in:
Antoine Bartuccio 2017-01-02 01:52:05 +01:00
parent cc955328c6
commit af11bb9d09
2 changed files with 43 additions and 12 deletions

View File

@ -688,4 +688,4 @@ void createSquare(Matrix matrix){
setRowToTrue(matrix,matrix.rowCount*3/4); setRowToTrue(matrix,matrix.rowCount*3/4);
setColToTrue(matrix,matrix.colCount/4); setColToTrue(matrix,matrix.colCount/4);
setColToTrue(matrix,matrix.colCount*3/4); setColToTrue(matrix,matrix.colCount*3/4);
} }

View File

@ -19,6 +19,8 @@ We decided to create two different library. One for the graphical interface (whi
Every function and data type are described in the documentation given with the project. This documentation is generated with doxygen. Every function and data type are described in the documentation given with the project. This documentation is generated with doxygen.
\newpage
# Algorithmic # Algorithmic
The most interesting function are *getCellValue* and *setCellValue*. Those are the one we rely on the most. They are our way of dealing with our complex data structure allowing us to avoid to store false values. They are the functions that need the more computational power on the long run but are really useful due to their level of abstraction and their high level. The most interesting function are *getCellValue* and *setCellValue*. Those are the one we rely on the most. They are our way of dealing with our complex data structure allowing us to avoid to store false values. They are the functions that need the more computational power on the long run but are really useful due to their level of abstraction and their high level.
@ -255,17 +257,11 @@ END
Functions *andColSequenceOnMatrix* and *orColSequenceOnMatrix* are implemented with *colSequenceOnMatrix* and are really not interesting so we're gonna provide the algorithm of the last one : Functions *andColSequenceOnMatrix* and *orColSequenceOnMatrix* are implemented with *colSequenceOnMatrix* and are really not interesting so we're gonna provide the algorithm of the last one :
```C
```
This is the same thing for *andRowSequenceOnMatrix* and *orRowSequenceOnMatrix* :
```C ```C
colSequenceOnMatrix(m:Matrix, operator:(function(bool, bool):bool)): Matrix colSequenceOnMatrix(m:Matrix, operator:(function(bool, bool):bool)): Matrix
BEGIN BEGIN
a:integer a:bool
b:integer b:bool
i:integer i:integer
j:integer j:integer
newM:Matrix <- createMatrix() newM:Matrix <- createMatrix()
@ -275,10 +271,10 @@ BEGIN
colCount(newM) <- 0 colCount(newM) <- 0
colSequenceOnMatrix <- newM colSequenceOnMatrix <- newM
endif endif
colCount(newM) <- colCount(m) - 1 colCount(newM) <- value(colCount(m)) - 1
for i from 0 to colCount(m) - 2 do for i from 0 to value(colCount(m)) - 2 do
for j from 0 to rowCount(m) - 2 do for j from 0 to value(rowCount(m)) - 2 do
a <- getCellValue(m, i, j) a <- getCellValue(m, i, j)
b <- getCellValue(m, i + 1, j) b <- getCellValue(m, i + 1, j)
if operator(a, b) then if operator(a, b) then
@ -290,6 +286,38 @@ BEGIN
END END
``` ```
This is the same thing for *andRowSequenceOnMatrix* and *orRowSequenceOnMatrix* :
```C
rowSequenceOnMatrix(m:Matrix, operator:(function(bool, bool):bool)): Matrix
BEGIN
a:bool
b:bool
i:integer
j:integer
newM:Matrix <- createMatrix()
colCount(newM) <- value(colCount(m))
if value(rowCount(m)) <= 1 then
rowCount(newM) <- 0
rowSequenceOnMatrix <- newM
endif
rowCount(newM) <- value(rowCount(m)) - 1
for i from 0 to value(rowCount(m)) - 1 do
for j from 0 to value(colCount(m)) - 1 do
a <- getCellValue(m, i, j)
b <- getCellValue=(m, i, j + 1)
if operator(a, b) then
setCellValue(newM, i, j, true)
endif
endfor
endfor
rowSequenceOnMatrix <- newM
END
```
Here are the algorithm of the function *applyRules* and all the one related to it : Here are the algorithm of the function *applyRules* and all the one related to it :
```C ```C
@ -396,8 +424,11 @@ BEGIN
endfor endfor
getFromRules <- bools getFromRules <- bools
END
``` ```
\newpage
# Conclusion # Conclusion
As we said before, we decided to not store false values in our matrix. So, by default, all values are set to false and every time we created a new matrix, we only used setCellValue for true values. As we said before, we decided to not store false values in our matrix. So, by default, all values are set to false and every time we created a new matrix, we only used setCellValue for true values.