Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c0dd3f87f |
@@ -6,25 +6,7 @@
|
||||
|
||||
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)
|
||||
@@ -35,6 +17,7 @@ void clearMatrix(Matrix *matrix)
|
||||
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