testing matrix.c

This commit is contained in:
Jonas Hofmann 2025-11-25 11:18:20 +01:00
parent 758dc03ab8
commit f149efb86a
2 changed files with 13 additions and 7 deletions

View File

@ -36,7 +36,7 @@ GrayScaleImageSeries *readImages(const char *path)
expectedHeader = checkHeaderString(headerString);
printf("llu %llu\n", series->count * numberOfBytesToRead * sizeof(GrayScalePixelType));
// printf("llu %llu\n", series->count * numberOfBytesToRead * sizeof(GrayScalePixelType));
series->images->buffer = calloc((series->count) * numberOfBytesToRead, sizeof(GrayScalePixelType));
series->labels = calloc((series->count), sizeof(&(series->labels)));

View File

@ -57,13 +57,15 @@ void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned
//printf("Ungueltige Indizes beim Setzen!\n");
return;
}
// printf("%d \n", rowIdx + matrix.cols * colIdx);
matrix.buffer[rowIdx + matrix.cols * colIdx] = value;
// printf("%d \n", rowIdx + matrix.rows * colIdx);
*(&matrix.buffer[0] + colIdx * matrix.rows + rowIdx) = value;
// printf("value %f\n", value);
}
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
{
float wert = 0;
if(matrix.buffer == NULL)
{
//printf("Fehler beim Lesen! Matrix nicht initialisiert");
@ -76,7 +78,11 @@ MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int co
return 0;
}
return matrix.buffer[rowIdx * matrix.cols + colIdx];
wert = matrix.buffer[rowIdx * matrix.cols + colIdx];
//printf("wert row %d col %d: %f\n", rowIdx, colIdx, *(&matrix.buffer[0] + colIdx * matrix.cols + rowIdx));
//printf("geholter wert = %f\n", wert);
return wert;
}
Matrix add(const Matrix matrix1, const Matrix matrix2)
@ -159,9 +165,9 @@ Matrix add(const Matrix matrix1, const Matrix matrix2)
}
else
{
//printf("Fehler bei Addition: Matrix Dimensionen stimmen nicht ueberein!\n");
Matrix empty = {0, 0, NULL};
return empty;
//printf("Fehler bei Addition: Matrix Dimensionen stimmen nicht ueberein!\n");
Matrix empty = {0, 0, NULL};
return empty;
}
}