generated from freudenreichan/info2Praktikum-NeuronalesNetz
Matrix multiply fertig
This commit is contained in:
parent
7f797957aa
commit
07911fdf76
26
matrix.c
26
matrix.c
@ -93,5 +93,29 @@ Matrix add(const Matrix matrix1, const Matrix matrix2)
|
||||
|
||||
Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
||||
{
|
||||
return matrix1;
|
||||
if (matrix1.cols != matrix2.rows) {
|
||||
Matrix invalid = {0,0, NULL};
|
||||
return invalid;
|
||||
}
|
||||
|
||||
Matrix result = createMatrix(matrix1.rows, matrix2.cols);
|
||||
if (result.buffer == NULL)
|
||||
return result;
|
||||
|
||||
|
||||
for (unsigned int i = 0; i < matrix1.rows; i++){
|
||||
for (unsigned int j = 0; j < matrix2.cols; j++){
|
||||
*(result.buffer + (i * result.cols + j)) = 0;
|
||||
|
||||
for (unsigned int k = 0; k < matrix1.cols; k++){
|
||||
*(result.buffer + (i * result.cols + j)) += *(matrix1.buffer + (i * matrix1.cols + k)) * *(matrix2.buffer + (k * matrix2.cols + j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//Für imageInput.c
|
||||
//size_t fread(void *buffer, size_t elementSize, size_t count, FILE *FILE_HEADER_STRING)
|
||||
//elementSize = width * height;
|
||||
Loading…
x
Reference in New Issue
Block a user