Compare commits

..

2 Commits

Author SHA1 Message Date
2142433257 Merge remote-tracking branch 'origin/main'
# Conflicts:
#	matrix.c
2025-11-10 15:26:23 +01:00
2dbcc110fc Addition funktioniert 2025-11-10 15:23:28 +01:00

View File

@ -50,10 +50,40 @@ MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int co
Matrix add(const Matrix matrix1, const Matrix matrix2) Matrix add(const Matrix matrix1, const Matrix matrix2)
{ {
//Überprüfen, ob die Matrizen die gleichen Dimensionen haben
//wenn nicht muss die matrix "rows/cols=0 und buffer = NULL" leer zurückgegeben werden
if (matrix1.rows != matrix2.rows || matrix1.cols != matrix2.cols)
{
Matrix result;
result.rows = 0;
result.cols = 0;
result.buffer = NULL;
return result;
}
else
{
//Matrix result ist die neue Matrix für das Ergebnis
Matrix result;
result.rows = matrix1.rows;
result.cols = matrix1.cols;
//Addition der beiden Matrizen
for (int i = 0; i < result.rows * result.cols; i++)
{
result.buffer[i] = matrix1.buffer[i] + matrix2.buffer[i];
}
return result;
}
} }
Matrix multiply(const Matrix matrix1, const Matrix matrix2) Matrix multiply(const Matrix matrix1, const Matrix matrix2)
{ {
} }