generated from freudenreichan/info2Praktikum-NeuronalesNetz
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1c582fcff | ||
|
|
6c0dd3f87f | ||
|
|
6885e104eb | ||
|
|
d15f3d1b9c | ||
|
|
84fb7219fb | ||
|
|
e2dbb0952f | ||
|
|
3a72794684 | ||
|
|
f0bc0ce06a |
@@ -6,17 +6,40 @@
|
||||
|
||||
Matrix createMatrix(unsigned int rows, unsigned int cols)
|
||||
{
|
||||
Matrix m;
|
||||
m.rows = rows;
|
||||
m.cols = cols;
|
||||
m.data = NULL;
|
||||
|
||||
if(rows == 0 || cols == 0)
|
||||
{
|
||||
printf("Error");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
m.data = calloc(rows * cols, sizeof(MatrixType));
|
||||
if (m.data == NULL)
|
||||
{
|
||||
printf("Error");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
void clearMatrix(Matrix *matrix)
|
||||
{
|
||||
free(matrix->data);
|
||||
|
||||
matrix->rows = 0;
|
||||
matrix->cols = 0;
|
||||
matrix->data = NULL;
|
||||
}
|
||||
|
||||
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
||||
{
|
||||
|
||||
matrix.data[(rowIdx * matrix.cols) + colIdx] = value; //wir setzen den data-Wert an der Stelle (rowIdx*Spalten + colIdx) auf den Wert von value
|
||||
}
|
||||
|
||||
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
||||
|
||||
Reference in new issue
Block a user