return in add und mul
This commit is contained in:
parent
b30c2a3808
commit
2dffac5f07
6
matrix.c
6
matrix.c
@ -72,6 +72,7 @@ Matrix add(const Matrix matrix1, const Matrix matrix2)
|
|||||||
setMatrixAt(sum, result_add, r, c); // evtl re
|
setMatrixAt(sum, result_add, r, c); // evtl re
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return result_add;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
||||||
@ -82,7 +83,7 @@ Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
|||||||
if (matrix1.cols != matrix2.rows)
|
if (matrix1.cols != matrix2.rows)
|
||||||
return createMatrix(0, 0);
|
return createMatrix(0, 0);
|
||||||
|
|
||||||
Matrix result = createMatrix(matrix1.rows, matrix2.cols); // ""
|
Matrix result_mul = createMatrix(matrix1.rows, matrix2.cols); // ""
|
||||||
|
|
||||||
for (int index = 0; index < matrix1.rows; index++)
|
for (int index = 0; index < matrix1.rows; index++)
|
||||||
{
|
{
|
||||||
@ -96,7 +97,8 @@ Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
|||||||
buffer_add += getMatrixAt(matrix1, index, skalar) * getMatrixAt(matrix2, skalar, shift);
|
buffer_add += getMatrixAt(matrix1, index, skalar) * getMatrixAt(matrix2, skalar, shift);
|
||||||
}
|
}
|
||||||
// matrix_mul[index][shift] = buffer_add;
|
// matrix_mul[index][shift] = buffer_add;
|
||||||
setMatrixAt(buffer_add, result, index, shift); // result als Pointer, also mit &result
|
setMatrixAt(buffer_add, result_mul, index, shift); // result als Pointer, also mit &result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return result_mul;
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user