Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c49920613 | ||
| 28944bd871 | |||
| 29b2966c63 | |||
| 41c164d3b2 | |||
| b4bc2fae8a |
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"makefile.configureOnOpen": false
|
||||||
|
}
|
||||||
13
makefile
13
makefile
@ -57,10 +57,11 @@ imageInputTests: imageInput.o imageInputTests.c $(unityfolder)/unity.c
|
|||||||
# --------------------------
|
# --------------------------
|
||||||
# Clean
|
# Clean
|
||||||
# --------------------------
|
# --------------------------
|
||||||
|
#clean:
|
||||||
|
#ifeq ($(OS),Windows_NT)
|
||||||
|
# del /f *.o *.exe
|
||||||
|
#else
|
||||||
|
# rm -f *.o mnist runMatrixTests runNeuralNetworkTests runImageInputTests
|
||||||
|
#endif
|
||||||
clean:
|
clean:
|
||||||
ifeq ($(OS),Windows_NT)
|
rm -f *.o *.exe
|
||||||
del /f *.o *.exe
|
|
||||||
else
|
|
||||||
rm -f *.o mnist runMatrixTests runNeuralNetworkTests runImageInputTests
|
|
||||||
endif
|
|
||||||
|
|
||||||
57
matrix.c
57
matrix.c
@ -1,35 +1,38 @@
|
|||||||
|
#include "matrix.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "matrix.h"
|
|
||||||
|
|
||||||
// TODO Matrix-Funktionen implementieren
|
// TODO Matrix-Funktionen implementieren
|
||||||
|
/*typedef struct {
|
||||||
Matrix createMatrix(unsigned int rows, unsigned int cols)
|
unsigned int rows; //Zeilen
|
||||||
{
|
unsigned int cols; //Spalten
|
||||||
|
MatrixType *data; //Zeiger auf Speicherbereich Reihen*Spalten
|
||||||
|
} Matrix;*/
|
||||||
|
Matrix createMatrix(unsigned int rows, unsigned int cols) {
|
||||||
|
MatrixType *data =
|
||||||
|
malloc(rows * cols * sizeof(MatrixType)); // Speicher reservieren, malloc
|
||||||
|
// liefert Zeiger auf Speicher
|
||||||
|
Matrix newMatrix = {rows, cols, data}; // neue Matrix nach struct
|
||||||
|
return newMatrix;
|
||||||
}
|
}
|
||||||
|
void clearMatrix(Matrix *matrix) {
|
||||||
void clearMatrix(Matrix *matrix)
|
matrix->data = UNDEFINED_MATRIX_VALUE;
|
||||||
{
|
matrix->rows = UNDEFINED_MATRIX_VALUE;
|
||||||
|
matrix->cols = UNDEFINED_MATRIX_VALUE;
|
||||||
|
free((*matrix).data); // Speicher freigeben
|
||||||
}
|
}
|
||||||
|
void setMatrixAt(MatrixType value, Matrix matrix,
|
||||||
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
unsigned int rowIdx, // Kopie der Matrix wird übergeben
|
||||||
{
|
unsigned int colIdx) {
|
||||||
|
matrix.data[rowIdx * matrix.cols + colIdx] =
|
||||||
|
value; // rowIdx * matrix.cols -> Beginn der Zeile colIdx ->Spalte
|
||||||
|
// innerhalb der Zeile
|
||||||
}
|
}
|
||||||
|
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx,
|
||||||
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
unsigned int colIdx) {
|
||||||
{
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Matrix add(const Matrix matrix1, const Matrix matrix2) {
|
||||||
Matrix add(const Matrix matrix1, const Matrix matrix2)
|
// broadcasting
|
||||||
{
|
return matrix1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Matrix multiply(const Matrix matrix1, const Matrix matrix2) { return matrix1; }
|
||||||
Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
12
matrix.h
12
matrix.h
@ -6,14 +6,20 @@
|
|||||||
typedef float MatrixType;
|
typedef float MatrixType;
|
||||||
|
|
||||||
// TODO Matrixtyp definieren
|
// TODO Matrixtyp definieren
|
||||||
|
typedef struct {
|
||||||
|
unsigned int rows;
|
||||||
|
unsigned int cols;
|
||||||
|
MatrixType *data;
|
||||||
|
|
||||||
|
} Matrix;
|
||||||
|
|
||||||
Matrix createMatrix(unsigned int rows, unsigned int cols);
|
Matrix createMatrix(unsigned int rows, unsigned int cols);
|
||||||
void clearMatrix(Matrix *matrix);
|
void clearMatrix(Matrix *matrix);
|
||||||
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx);
|
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx,
|
||||||
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int colIdx);
|
unsigned int colIdx);
|
||||||
|
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx,
|
||||||
|
unsigned int colIdx);
|
||||||
Matrix add(const Matrix matrix1, const Matrix matrix2);
|
Matrix add(const Matrix matrix1, const Matrix matrix2);
|
||||||
Matrix multiply(const Matrix matrix1, const Matrix matrix2);
|
Matrix multiply(const Matrix matrix1, const Matrix matrix2);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user