forked from freudenreichan/info2Praktikum-NeuronalesNetz
46 lines
1.1 KiB
C
46 lines
1.1 KiB
C
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include "matrix.h"
|
|
|
|
// TODO Matrix-Funktionen implementieren
|
|
|
|
Matrix createMatrix(unsigned int rows, unsigned int cols)
|
|
{
|
|
Matrix m;
|
|
m.rows = rows;
|
|
m.cols = cols;
|
|
m.data = (MatrixType*) calloc(rows * cols, sizeof(MatrixType)); // calloc, statt malloc benutzt, um direkt alle Werte mit 0 zu initialisieren
|
|
return m;
|
|
}
|
|
|
|
void clearMatrix(Matrix *matrix)
|
|
{
|
|
if(matrix == NULL){ // falls clearMatrix(NULL) aufgerufen wird, sonst würde es abstürzen, wenn mann direkt free(matrix->data) schreibt
|
|
return;
|
|
}
|
|
free(matrix->data); // matrix->data = (*matrix).data
|
|
matrix->data = NULL; // falls clearMatrix doppelt aufgerufen wird
|
|
matrix->rows = 0; // Matrix wird als komplett leer markiert
|
|
matrix->cols = 0;
|
|
|
|
}
|
|
|
|
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
|
{
|
|
|
|
}
|
|
|
|
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
|
{
|
|
|
|
}
|
|
|
|
Matrix add(const Matrix matrix1, const Matrix matrix2)
|
|
{
|
|
|
|
}
|
|
|
|
Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
|
{
|
|
|
|
} |