diff options
Diffstat (limited to 'AutoImages/src')
-rw-r--r-- | AutoImages/src/Matrix.h | 10 | ||||
-rw-r--r-- | AutoImages/src/main.c | 10 |
2 files changed, 16 insertions, 4 deletions
diff --git a/AutoImages/src/Matrix.h b/AutoImages/src/Matrix.h index d471811..41abced 100644 --- a/AutoImages/src/Matrix.h +++ b/AutoImages/src/Matrix.h @@ -18,6 +18,16 @@ matrix* matrix_alloc(int size1, int size2) return m; } +matrix* cpy_matrix(matrix* m) +{ + matrix* cpy = matrix_alloc(m->size1, m->size2); + int i, j; + for (i = 0; i < m->size1; i++) + for (j = 0; j < m->size2; j++) + cpy->array[i][j] = m->array[i][j]; + return cpy; +} + matrix* sin_matrix(matrix* m) { int i, j; diff --git a/AutoImages/src/main.c b/AutoImages/src/main.c index f4212c2..5ec4cf6 100644 --- a/AutoImages/src/main.c +++ b/AutoImages/src/main.c @@ -14,7 +14,7 @@ #include "Random.h" -#define FUNCTION_LENGTH 40 +#define FUNCTION_LENGTH 20 @@ -133,9 +133,9 @@ matrix* evalFunction(char* function, int width, int height) } if (strEquals(token, "x")) - push(stack, x); + push(stack, cpy_matrix(x)); else if (strEquals(token, "y")) - push(stack, y); + push(stack, cpy_matrix(y)); else if (strEquals(token, "sin")) push(stack, sin_matrix(pop(stack))); else if (strEquals(token, "cos")) @@ -211,7 +211,9 @@ matrix* evalFunction(char* function, int width, int height) token = strtok(NULL, " "); } - + + printf("This should be 77: %d\n", x->array[77][21]); + printf("This should be 27: %d\n", y->array[77][27]); return pop(stack); } |