2 Commits
Author SHA1 Message Date
Max-R fb72278d55 Merge branch 'main' into RMax 2025-11-25 11:12:36 +01:00
Max-R 4a1b6cbb40 Fehler 0 Matrix bei add abfangen 2025-11-25 10:13:01 +01:00
+58
View File
@@ -90,6 +90,7 @@ Matrix add(const Matrix matrix1, const Matrix matrix2) {
// Matrix
if (rowsEqual == 1 && colsEqual == 1) {
Matrix result = createMatrix(matrix1.rows, matrix1.cols);
<<<<<<< HEAD
if (result.buffer == NULL){
return (Matrix){0,0,NULL};
}
@@ -97,6 +98,15 @@ Matrix add(const Matrix matrix1, const Matrix matrix2) {
for (int j= 0; j< cols1; j++){
int valueM1= getMatrixAt(matrix1, i, j);
int valueM2= getMatrixAt(matrix2, i, j);
=======
if (result.buffer == NULL) {
return (Matrix){0, 0, NULL};
}
for (int i = 0; i < rows1; i++) {
for (int j = 0; j < cols1; j++) {
int valueM1 = getMatrixAt(matrix1, i, j);
int valueM2 = getMatrixAt(matrix2, i, j);
>>>>>>> main
int sum = valueM1 + valueM2;
setMatrixAt(sum, result, i, j);
}
@@ -107,6 +117,7 @@ Matrix add(const Matrix matrix1, const Matrix matrix2) {
Matrix newMatrix = broadcastingCols(matrix1, cols2);
// add
Matrix result = createMatrix(newMatrix.rows, newMatrix.cols);
<<<<<<< HEAD
if (result.buffer == NULL){
return (Matrix){0,0,NULL};
}
@@ -116,6 +127,17 @@ Matrix add(const Matrix matrix1, const Matrix matrix2) {
int valueM2= getMatrixAt(matrix2, i, j);
int sum = valueM1 + valueM2;
setMatrixAt(sum, result, i, j);
=======
if (result.buffer == NULL) {
return (Matrix){0, 0, NULL};
>>>>>>> main
}
for (int i = 0; i < rows1; i++) {
for (int j = 0; j < cols2; j++) {
int valueM1 = getMatrixAt(newMatrix, i, j);
int valueM2 = getMatrixAt(matrix2, i, j);
int sum = valueM1 + valueM2;
setMatrixAt(sum, result, i, j);
}
}
return result;
@@ -123,6 +145,7 @@ Matrix add(const Matrix matrix1, const Matrix matrix2) {
Matrix newMatrix2 = broadcastingCols(matrix2, cols1);
// add
Matrix result = createMatrix(newMatrix2.rows, newMatrix2.cols);
<<<<<<< HEAD
if (result.buffer == NULL){
return (Matrix){0,0,NULL};
}
@@ -132,6 +155,17 @@ Matrix add(const Matrix matrix1, const Matrix matrix2) {
int valueM2= getMatrixAt(newMatrix2, i, j);
int sum = valueM1 + valueM2;
setMatrixAt(sum, result, i, j);
=======
if (result.buffer == NULL) {
return (Matrix){0, 0, NULL};
>>>>>>> main
}
for (int i = 0; i < rows1; i++) {
for (int j = 0; j < cols1; j++) {
int valueM1 = getMatrixAt(matrix1, i, j);
int valueM2 = getMatrixAt(newMatrix2, i, j);
int sum = valueM1 + valueM2;
setMatrixAt(sum, result, i, j);
}
}
return result;
@@ -143,6 +177,7 @@ Matrix add(const Matrix matrix1, const Matrix matrix2) {
Matrix newMatrix = broadcastingRows(matrix1, rows2);
// add
Matrix result = createMatrix(newMatrix.rows, newMatrix.cols);
<<<<<<< HEAD
if (result.buffer == NULL){
return (Matrix){0,0,NULL};
}
@@ -152,6 +187,17 @@ Matrix add(const Matrix matrix1, const Matrix matrix2) {
int valueM2= getMatrixAt(matrix2, i, j);
int sum = valueM1 + valueM2;
setMatrixAt(sum, result, i, j);
=======
if (result.buffer == NULL) {
return (Matrix){0, 0, NULL};
>>>>>>> main
}
for (int i = 0; i < rows2; i++) {
for (int j = 0; j < cols1; j++) {
int valueM1 = getMatrixAt(newMatrix, i, j);
int valueM2 = getMatrixAt(matrix2, i, j);
int sum = valueM1 + valueM2;
setMatrixAt(sum, result, i, j);
}
}
return result;
@@ -159,6 +205,7 @@ Matrix add(const Matrix matrix1, const Matrix matrix2) {
Matrix newMatrix2 = broadcastingRows(matrix2, rows1);
// add
Matrix result = createMatrix(newMatrix2.rows, newMatrix2.cols);
<<<<<<< HEAD
if (result.buffer == NULL){
return (Matrix){0,0,NULL};
}
@@ -168,6 +215,17 @@ Matrix add(const Matrix matrix1, const Matrix matrix2) {
int valueM2= getMatrixAt(newMatrix2, i, j);
int sum = valueM1 + valueM2;
setMatrixAt(sum, result, i, j);
=======
if (result.buffer == NULL) {
return (Matrix){0, 0, NULL};
>>>>>>> main
}
for (int i = 0; i < rows1; i++) {
for (int j = 0; j < cols1; j++) {
int valueM1 = getMatrixAt(matrix1, i, j);
int valueM2 = getMatrixAt(newMatrix2, i, j);
int sum = valueM1 + valueM2;
setMatrixAt(sum, result, i, j);
}
}
return result;