Compare commits

..

No commits in common. "Krisp2" and "main" have entirely different histories.
Krisp2 ... main

5 changed files with 35 additions and 59 deletions

View File

@ -1,3 +0,0 @@
{
"makefile.configureOnOpen": false
}

View File

@ -1,2 +0,0 @@
# Projekt 2 für Informatik 2 Praktikum

View File

@ -57,11 +57,10 @@ imageInputTests: imageInput.o imageInputTests.c $(unityfolder)/unity.c
# --------------------------
# Clean
# --------------------------
#clean:
#ifeq ($(OS),Windows_NT)
# del /f *.o *.exe
#else
# rm -f *.o mnist runMatrixTests runNeuralNetworkTests runImageInputTests
#endif
clean:
rm -f *.o *.exe
ifeq ($(OS),Windows_NT)
del /f *.o *.exe
else
rm -f *.o mnist runMatrixTests runNeuralNetworkTests runImageInputTests
endif

View File

@ -1,47 +1,35 @@
#include "matrix.h"
#include <stdlib.h>
#include <string.h>
#include "matrix.h"
// TODO Matrix-Funktionen implementieren
/*typedef struct {
unsigned int rows; //Zeilen
unsigned int cols; //Spalten
MatrixType *buffer; //Zeiger auf Speicherbereich Reihen*Spalten
} Matrix;*/
Matrix createMatrix(unsigned int rows, unsigned int cols) {
MatrixType *buffer =
malloc(rows * cols * sizeof(MatrixType)); // Speicher reservieren, malloc
// liefert Zeiger auf Speicher
Matrix newMatrix = {rows, cols, buffer}; // neue Matrix nach struct
return newMatrix;
}
void clearMatrix(Matrix *matrix) {
matrix->buffer = UNDEFINED_MATRIX_VALUE;
matrix->rows = UNDEFINED_MATRIX_VALUE;
matrix->cols = UNDEFINED_MATRIX_VALUE;
free((*matrix).buffer); // Speicher freigeben
}
void setMatrixAt(MatrixType value, Matrix matrix,
unsigned int rowIdx, // Kopie der Matrix wird übergeben
unsigned int colIdx) {
matrix.buffer[rowIdx * matrix.cols + colIdx] =
value; // rowIdx * matrix.cols -> Beginn der Zeile colIdx ->Spalte
// innerhalb der Zeile
}
MatrixType getMatrixAt(const Matrix matrix,
unsigned int rowIdx, // Kopie der Matrix wird übergeben
unsigned int colIdx) {
if (rowIdx >= matrix.rows ||
colIdx >= matrix.cols) { // Speichergröße nicht überschreiten
return 0;
}
Matrix createMatrix(unsigned int rows, unsigned int cols)
{
MatrixType value = matrix.buffer[rowIdx * matrix.cols + colIdx];
}
void clearMatrix(Matrix *matrix)
{
return value;
}
Matrix add(const Matrix matrix1, const Matrix matrix2) {
// broadcasting
return matrix1;
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
{
}
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
{
}
Matrix add(const Matrix matrix1, const Matrix matrix2)
{
}
Matrix multiply(const Matrix matrix1, const Matrix matrix2)
{
}
Matrix multiply(const Matrix matrix1, const Matrix matrix2) { return matrix1; }

View File

@ -6,20 +6,14 @@
typedef float MatrixType;
// TODO Matrixtyp definieren
typedef struct {
unsigned int rows;
unsigned int cols;
MatrixType *buffer;
} Matrix;
Matrix createMatrix(unsigned int rows, unsigned int cols);
void clearMatrix(Matrix *matrix);
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx,
unsigned int colIdx);
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx,
unsigned int colIdx);
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx);
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int colIdx);
Matrix add(const Matrix matrix1, const Matrix matrix2);
Matrix multiply(const Matrix matrix1, const Matrix matrix2);
#endif