forked from freudenreichan/info2Praktikum-NeuronalesNetz
debugged
This commit is contained in:
parent
7837be1c3e
commit
06109225f8
33
.vscode/launch.json
vendored
Normal file
33
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "(gdb) Launch",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/mnist.exe",
|
||||
"args": ["mnist_test.info2","mnist_model.info2"],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${fileDirname}",
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"miDebuggerPath": "C:\\msys64\\ucrt64\\bin\\gdb.exe",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
},
|
||||
{
|
||||
"description": "Set Disassembly Flavor to Intel",
|
||||
"text": "-gdb-set disassembly-flavor intel",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
22
matrix.c
22
matrix.c
@ -10,7 +10,7 @@ Matrix createMatrix(unsigned int rows, unsigned int cols)
|
||||
|
||||
if (rows > 0 && cols > 0)
|
||||
{
|
||||
m.buffer = malloc(rows * cols * sizeof(int));
|
||||
m.buffer = malloc(rows * cols * sizeof(MatrixType));
|
||||
m.rows = rows;
|
||||
m.cols = cols;
|
||||
}
|
||||
@ -65,23 +65,11 @@ Matrix add(const Matrix matrix1, const Matrix matrix2)
|
||||
return result;
|
||||
}
|
||||
|
||||
result.rows = matrix1.rows;
|
||||
result.cols = matrix1.cols;
|
||||
result.buffer = malloc(result.rows * result.cols * sizeof(MatrixType));
|
||||
|
||||
// wenn buffer nicht allokiert werden kann dann zurücksetzen und abbrechen
|
||||
if (result.buffer == NULL)
|
||||
{
|
||||
result.rows = result.cols = 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
if (matrix1.cols == 1 && matrix1.rows == matrix2.rows) // Broadcasting
|
||||
{
|
||||
result.rows = matrix2.rows;
|
||||
result.cols = matrix2.cols;
|
||||
|
||||
result = createMatrix(matrix2.rows, matrix2.cols);
|
||||
|
||||
for (unsigned int i = 0; i < matrix1.rows; i++)
|
||||
{
|
||||
for (unsigned int j = 0; j < result.cols; j++)
|
||||
@ -95,8 +83,7 @@ Matrix add(const Matrix matrix1, const Matrix matrix2)
|
||||
|
||||
else if (matrix2.cols == 1 && matrix1.rows == matrix2.rows)
|
||||
{
|
||||
result.rows = matrix1.rows;
|
||||
result.cols = matrix1.cols;
|
||||
result = createMatrix(matrix1.rows, matrix1.cols);
|
||||
|
||||
for (unsigned int i = 0; i < matrix2.rows; i++)
|
||||
{
|
||||
@ -109,6 +96,7 @@ Matrix add(const Matrix matrix1, const Matrix matrix2)
|
||||
|
||||
else
|
||||
{
|
||||
result = createMatrix(matrix1.rows, matrix1.cols);
|
||||
// Elementweise Addition
|
||||
for (unsigned int i = 0; i < result.rows; i++)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user