Multiplikation versucht
Prüfung passt fürs erste Multiplikation an sich safe falsch aber is ne erste Überlegung
This commit is contained in:
parent
2396b5867b
commit
396ad0c4ca
31
matrix.c
31
matrix.c
@ -68,6 +68,7 @@ Matrix add(const Matrix matrix1, const Matrix matrix2)
|
|||||||
Matrix result;
|
Matrix result;
|
||||||
result.rows = matrix1.rows;
|
result.rows = matrix1.rows;
|
||||||
result.cols = matrix1.cols;
|
result.cols = matrix1.cols;
|
||||||
|
//TODO: Chat sagt hier noch buffer calloc rein
|
||||||
|
|
||||||
|
|
||||||
//Addition der beiden Matrizen
|
//Addition der beiden Matrizen
|
||||||
@ -85,5 +86,35 @@ Matrix add(const Matrix matrix1, const Matrix matrix2)
|
|||||||
|
|
||||||
Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
||||||
{
|
{
|
||||||
|
//Spalten matrix 1 muss mit Reihen Matrix 2 übereinstimmen
|
||||||
|
if (matrix1.cols != matrix2.rows)
|
||||||
|
{
|
||||||
|
Matrix result;
|
||||||
|
result.rows = 0;
|
||||||
|
result.cols = 0;
|
||||||
|
result.buffer = NULL;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Matrix result;
|
||||||
|
result.rows = matrix1.rows;
|
||||||
|
result.cols = matrix2.cols;
|
||||||
|
//TODO: Chat sagt hier noch buffer calloc rein
|
||||||
|
|
||||||
|
//Multipliaktion der beiden Matrizen
|
||||||
|
for(int i = 0; ... ; i++)
|
||||||
|
{
|
||||||
|
result.buffer[i] = matrix1.buffer[i] * matrix2.buffer[i];
|
||||||
|
for(int j = 1; ... ; j++)
|
||||||
|
{
|
||||||
|
result.buffer[i] += matrix1.buffer[j] * matrix2.buffer[i*j]
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//FIXME: hier steht glaube viel bullshit lol
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user