generated from freudenreichan/info2Praktikum-NeuronalesNetz
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6a813a635 | ||
|
|
82d72c5e90 | ||
|
|
0a549b7e0d | ||
|
|
c99db0f96c |
No files matched your search
@@ -49,6 +49,7 @@ GrayScaleImageSeries *readImages(const char *path)
|
|||||||
for(int i = (series->images->width * series->images->height) - 1; i <= 0; i--)
|
for(int i = (series->images->width * series->images->height) - 1; i <= 0; i--)
|
||||||
{
|
{
|
||||||
fread(&(series->images->buffer[i]), sizeof(GrayScalePixelType), 1, file);
|
fread(&(series->images->buffer[i]), sizeof(GrayScalePixelType), 1, file);
|
||||||
|
fread(&(series->labels[i]), sizeof(unsigned char), 1, file);
|
||||||
}
|
}
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return series;
|
return series;
|
||||||
|
|||||||
@@ -108,11 +108,17 @@ Matrix add(const Matrix matrix1, const Matrix matrix2)
|
|||||||
Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
||||||
{
|
{
|
||||||
Matrix result;
|
Matrix result;
|
||||||
|
result.rows = 0;
|
||||||
|
result.cols = 0;
|
||||||
|
result.buffer = NULL;
|
||||||
|
|
||||||
|
if (matrix1.cols != matrix2.rows) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
result.rows = matrix1.rows;
|
result.rows = matrix1.rows;
|
||||||
result.cols = matrix2.cols;
|
result.cols = matrix2.cols;
|
||||||
|
|
||||||
if (matrix1.rows == matrix2.cols) {
|
|
||||||
|
|
||||||
result.buffer = malloc(result.rows * result.cols * sizeof(MatrixType));
|
result.buffer = malloc(result.rows * result.cols * sizeof(MatrixType));
|
||||||
|
|
||||||
for(int i = 0; i < result.rows; i++) {
|
for(int i = 0; i < result.rows; i++) {
|
||||||
@@ -121,11 +127,8 @@ Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
|||||||
for(int k = 0; k < matrix1.cols; k++) {
|
for(int k = 0; k < matrix1.cols; k++) {
|
||||||
value += matrix1.buffer[i * matrix1.cols + k] * matrix2.buffer[k * matrix2.cols + j];
|
value += matrix1.buffer[i * matrix1.cols + k] * matrix2.buffer[k * matrix2.cols + j];
|
||||||
}
|
}
|
||||||
result.buffer[i * matrix1.cols + j] = value;
|
result.buffer[i * result.cols + j] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
printf("Die angegebenen Matrizen haben keine passenden Dimensionen für die Multiplikation");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user