generated from freudenreichan/info2Praktikum-NeuronalesNetz
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5bf5b8971c |
No files matched your search
+2
-5
@@ -1,8 +1,5 @@
|
|||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -g -Wall
|
CFLAGS = -g -Wall
|
||||||
mnist: main.o matrix.o neuralNetwork.o imageInput.o mnistVisualization.o ./windows/libmnist_complete.a ./windows/libraylib.a
|
|
||||||
gcc -o mnist main.o matrix.o neuralNetwork.o imageInput.o mnistVisualization.o ./windows/libmnist_complete.a ./windows/libraylib.a -lopengl32 -lgdi32 -lwinmm
|
|
||||||
|
|
||||||
|
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
include makefile_windows.variables
|
include makefile_windows.variables
|
||||||
@@ -21,8 +18,8 @@ unityfolder = ./unity
|
|||||||
# --------------------------
|
# --------------------------
|
||||||
# Initiales Programm bauen (zum ausprobieren)
|
# Initiales Programm bauen (zum ausprobieren)
|
||||||
# --------------------------
|
# --------------------------
|
||||||
mnist_initial: $(BINARIES)/libmnist_complete.a
|
mnist_initial: ./windows/libmnist_complete.a
|
||||||
$(CC) -o mnist $(BINARIES)/libmnist_complete.a $(BINARIES)/libraylib.a ${LDFLAGS}
|
$(CC) -o mnist ./windows/libmnist_complete.a ./windows/libraylib.a ${LDFLAGS}
|
||||||
|
|
||||||
# --------------------------
|
# --------------------------
|
||||||
# Selbst implementiertes Programm bauen
|
# Selbst implementiertes Programm bauen
|
||||||
|
|||||||
+4
-72
@@ -44,92 +44,24 @@ void clearMatrix(Matrix *matrix)
|
|||||||
matrix->cols = 0;
|
matrix->cols = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
||||||
{
|
{
|
||||||
if (matrix.buffer == NULL ||
|
|
||||||
rowIdx >= matrix.rows ||
|
|
||||||
colIdx >= matrix.cols) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
matrix.buffer[rowIdx * matrix.cols + colIdx] = value;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
||||||
{
|
{
|
||||||
if (matrix.buffer == NULL ||
|
|
||||||
rowIdx >= matrix.rows ||
|
|
||||||
colIdx >= matrix.cols) {
|
|
||||||
return UNDEFINED_MATRIX_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return matrix.buffer[rowIdx * matrix.cols + colIdx];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix add(const Matrix matrix1, const Matrix matrix2)
|
Matrix add(const Matrix matrix1, const Matrix matrix2)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (matrix1.rows != matrix2.rows ||
|
|
||||||
(matrix1.cols != matrix2.cols &&
|
|
||||||
matrix1.cols != 1 &&
|
|
||||||
matrix2.cols != 1)) {
|
|
||||||
return createMatrix(0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ungültige Eingabematrizen abfangen
|
|
||||||
if (matrix1.buffer == NULL || matrix2.buffer == NULL) {
|
|
||||||
return createMatrix(0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Größere Spaltenanzahl bestimmen
|
|
||||||
unsigned int cols = matrix1.cols > matrix2.cols
|
|
||||||
? matrix1.cols : matrix2.cols;
|
|
||||||
|
|
||||||
Matrix result = createMatrix(matrix1.rows, cols);
|
|
||||||
|
|
||||||
if (result.buffer == NULL) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < result.rows; i++) {
|
|
||||||
for (unsigned int j = 0; j < result.cols; j++) {
|
|
||||||
|
|
||||||
// Bei einer Spalte immer Spalte 0 verwenden
|
|
||||||
unsigned int j1 = matrix1.cols == 1 ? 0 : j;
|
|
||||||
unsigned int j2 = matrix2.cols == 1 ? 0 : j;
|
|
||||||
|
|
||||||
result.buffer[i * result.cols + j] =
|
|
||||||
matrix1.buffer[i * matrix1.cols + j1] +
|
|
||||||
matrix2.buffer[i * matrix2.cols + j2];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
||||||
{
|
{
|
||||||
if (matrix1.cols != matrix2.rows) {
|
|
||||||
return createMatrix(0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ergebnismatrix erstellen
|
|
||||||
Matrix result = createMatrix(matrix1.rows, matrix2.cols);
|
|
||||||
|
|
||||||
// Matrizen multiplizieren
|
|
||||||
for (unsigned int rowIdx = 0; rowIdx < matrix1.rows; rowIdx++) {
|
|
||||||
for (unsigned int colIdx = 0; colIdx < matrix2.cols; colIdx++) {
|
|
||||||
for (unsigned int k = 0; k < matrix1.cols; k++) {
|
|
||||||
result.buffer[rowIdx * result.cols + colIdx] +=
|
|
||||||
matrix1.buffer[rowIdx * matrix1.cols + k] *
|
|
||||||
matrix2.buffer[k * matrix2.cols + colIdx];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user