generated from freudenreichan/info2Praktikum-NeuronalesNetz
Compare commits
7
Commits
set_matrix
...
a1c582fcff
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1c582fcff | ||
|
|
6885e104eb | ||
|
|
d15f3d1b9c | ||
|
|
84fb7219fb | ||
|
|
e2dbb0952f | ||
|
|
3a72794684 | ||
|
|
f0bc0ce06a |
@@ -6,12 +6,34 @@
|
|||||||
|
|
||||||
Matrix createMatrix(unsigned int rows, unsigned int cols)
|
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)
|
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)
|
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
||||||
|
|||||||
Reference in new issue
Block a user