multiply, besteht MatrixTests
This commit is contained in:
parent
4e2ee7078a
commit
b187a13b17
26
matrix.c
26
matrix.c
@ -162,9 +162,27 @@ Matrix add(const Matrix matrix1, const Matrix matrix2) {
|
|||||||
Matrix errorMatrix = {0, 0, NULL};
|
Matrix errorMatrix = {0, 0, NULL};
|
||||||
return errorMatrix;
|
return errorMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
Matrix multiply(const Matrix matrix1, const Matrix matrix2) { return matrix1; }
|
Matrix multiply(const Matrix matrix1, const Matrix matrix2) {
|
||||||
|
//Spalten1 müssen gleich zeilen2 sein! dann multiplizieren
|
||||||
|
if (matrix1.cols == matrix2.rows){
|
||||||
|
Matrix multMatrix = createMatrix(matrix1.rows,matrix2.cols);
|
||||||
|
for (int r=0; r< matrix1.rows; r++){
|
||||||
|
for (int c=0; c< matrix2.cols; c++){
|
||||||
|
MatrixType sum = 0.0;
|
||||||
|
for (int k=0; k< matrix1.cols; k++){
|
||||||
|
sum+= matrix1.buffer[r*matrix1.cols+k]*matrix2.buffer[k*matrix2.cols+c];
|
||||||
|
}
|
||||||
|
multMatrix.buffer[r*multMatrix.cols+c] = sum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return multMatrix;
|
||||||
|
}
|
||||||
|
//sonst fehler
|
||||||
|
else{
|
||||||
|
Matrix errorMatrix = {0, 0, NULL};
|
||||||
|
return errorMatrix;
|
||||||
|
}
|
||||||
|
//return matrix1;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user