forked from freudenreichan/info2Praktikum-NeuronalesNetz
matrix in matrix.h definiert und create und clearMatrix geschrieben
This commit is contained in:
parent
84ef6ad220
commit
2897a9f2a4
19
matrix.c
19
matrix.c
@ -3,15 +3,26 @@
|
|||||||
#include "matrix.h"
|
#include "matrix.h"
|
||||||
|
|
||||||
// TODO Matrix-Funktionen implementieren
|
// TODO Matrix-Funktionen implementieren
|
||||||
|
// Matrix erstellen
|
||||||
Matrix createMatrix(unsigned int rows, unsigned int cols)
|
Matrix createMatrix(unsigned int rows, unsigned int cols)
|
||||||
{
|
{
|
||||||
|
Matrix matrix;
|
||||||
}
|
matrix.rows = rows;
|
||||||
|
matrix.cols = cols;
|
||||||
|
// Speicher allokieren
|
||||||
|
matrix.data = (double *)calloc(rows * cols, sizeof(double));
|
||||||
|
|
||||||
|
return matrix;
|
||||||
|
}
|
||||||
|
// Matrix Speicher freigeben
|
||||||
void clearMatrix(Matrix *matrix)
|
void clearMatrix(Matrix *matrix)
|
||||||
{
|
{
|
||||||
|
if (matrix != NULL && matrix->data != NULL) {
|
||||||
|
free(matrix->data);
|
||||||
|
matrix->data = NULL;
|
||||||
|
matrix->rows = 0;
|
||||||
|
matrix->cols = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
||||||
|
|||||||
7
matrix.h
7
matrix.h
@ -6,6 +6,13 @@
|
|||||||
typedef float MatrixType;
|
typedef float MatrixType;
|
||||||
|
|
||||||
// TODO Matrixtyp definieren
|
// TODO Matrixtyp definieren
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int rows;
|
||||||
|
int cols;
|
||||||
|
int *data;
|
||||||
|
|
||||||
|
} Matrix;
|
||||||
|
|
||||||
|
|
||||||
Matrix createMatrix(unsigned int rows, unsigned int cols);
|
Matrix createMatrix(unsigned int rows, unsigned int cols);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user