forked from freudenreichan/info2Praktikum-NeuronalesNetz
matrix.c set und get fertig
This commit is contained in:
1 parent
37341ec9c3
commit
ddea2d5d72
1 file changed
+12
-1
+12
-1
@@ -42,11 +42,22 @@ void clearMatrix(Matrix *matrix)
|
||||
|
||||
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
||||
{
|
||||
|
||||
if(matrix.rows <= rowIdx || matrix.cols <= colIdx) {
|
||||
return;
|
||||
}
|
||||
unsigned int index = rowIdx * matrix.cols + colIdx;
|
||||
|
||||
matrix.buffer[index] = value;
|
||||
}
|
||||
|
||||
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
||||
{
|
||||
if(matrix.rows <= rowIdx || matrix.cols <= colIdx){
|
||||
return UNDEFINED_MATRIX_VALUE;
|
||||
}
|
||||
unsigned int index = rowIdx * matrix.cols + colIdx;
|
||||
|
||||
return matrix.buffer[index];
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user