Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84fb7219fb |
@@ -6,30 +6,16 @@
|
|||||||
|
|
||||||
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