From 2ce9336727d8b08cb69cfbce3fda9d8d1909303e Mon Sep 17 00:00:00 2001 From: Ghost_Element Date: Tue, 19 Sep 2023 10:21:42 +0200 Subject: [PATCH 1/2] img print --- image.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/image.c b/image.c index db0c0fe..fcc6495 100644 --- a/image.c +++ b/image.c @@ -1,5 +1,7 @@ #pragma once +#include + #include "image.h" #include "matrix.h" @@ -8,4 +10,10 @@ typedef struct { int image_label; } Image; - +void img_print (Img* img){ + //print the image + matrix_print(img->pixel_values); + //print the number of the image + printf("%d", img->image_label); +} +void img_free (Img* img) From 88edbd4aba4405b0e9e6663ee61e34156a1242f0 Mon Sep 17 00:00:00 2001 From: Jakob Stornig Date: Tue, 19 Sep 2023 10:24:07 +0200 Subject: [PATCH 2/2] fixed .idea folder --- CMakeLists.txt | 2 +- main.c | 6 ++++-- matrix.c | 8 ++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 763bfbe..5038efd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,4 +3,4 @@ project(c_net C) set(CMAKE_C_STANDARD 11) -add_executable(c_net main.c) +add_executable(c_net main.c matrix.c) diff --git a/main.c b/main.c index 3ce2eda..5fdc7bf 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,7 @@ #include +#include "matrix.h" +#include + int main() { - printf("Hello World"); - return 0; + } \ No newline at end of file diff --git a/matrix.c b/matrix.c index cc76636..012dc1f 100644 --- a/matrix.c +++ b/matrix.c @@ -49,7 +49,7 @@ void matrix_free(Matrix* matrix) { void matrix_print(Matrix *matrix) { // print the dimensions of the matrix - printf("Rows: %d, Columns: %d", matrix->rows, matrix->columns); + printf("Rows: %d, Columns: %d\n", matrix->rows, matrix->columns); // loop through all values and format them into the correct matrix representation for (int i = 0; i < matrix->rows; i++) { @@ -92,12 +92,12 @@ Matrix* multiply(Matrix* matrix1, Matrix* matrix2) { exit(1); } - // crate result matrix + // create result matrix Matrix* result_matrix = matrix_create(matrix1->rows, matrix1->columns); // multiply the values and save them into the result matrix for (int i = 0; i < matrix1->rows; i++) { - for (int j = 0; j < ; j++) { + for (int j = 0; j < matrix1->columns; j++) { result_matrix->numbers[i][j] = matrix1->numbers[i][j] * matrix2->numbers[i][j]; } } @@ -170,7 +170,7 @@ Matrix* dot(Matrix* matrix1, Matrix* matrix2) { // sum up the products and save them into the result matrix result_matrix->numbers[i][j] = 0; for (int k = 0; k < matrix2->rows; k++) { - result_matrix->numbers[i][j] += matrix1[i][k] * matrix2[k][j]; + result_matrix->numbers[i][j] += matrix1->numbers[i][k] * matrix2->numbers[k][j]; } } }