generated from freudenreichan/info2Praktikum-NeuronalesNetz
Merge branch 'main' of https://git.efi.th-nuernberg.de/gitea/bruennerda98937/info2NeuronalesNetzBruennnerKobNew
This commit is contained in:
commit
5ce0982e17
14
matrix.c
14
matrix.c
@ -76,7 +76,9 @@ void clearMatrix(Matrix *matrix)
|
||||
{
|
||||
for (int i = 0; i < matrix->rows; i++) {
|
||||
for (int j = 0; j < matrix->cols;j++) {
|
||||
matrix->buffer[i + matrix->rows * j] = UNDEFINED_MATRIX_VALUE;
|
||||
// Normally one would expect to work matrices like this, but it is supposed to be the other way around.
|
||||
// matrix->buffer[i + matrix->rows * j] = UNDEFINED_MATRIX_VALUE;
|
||||
matrix->buffer[j + matrix->cols * i] = UNDEFINED_MATRIX_VALUE;
|
||||
}
|
||||
}
|
||||
free(matrix->buffer);
|
||||
@ -88,7 +90,11 @@ void clearMatrix(Matrix *matrix)
|
||||
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
||||
{
|
||||
//checks, if the given incies are allowed
|
||||
if((rowIdx) < matrix.rows && (colIdx) < matrix.cols) matrix.buffer[rowIdx + matrix.rows*(colIdx)] = value;
|
||||
if((rowIdx) < matrix.rows && (colIdx) < matrix.cols) {
|
||||
// Normally one would expect to work matrices like this, but it is supposed to be the other way around.
|
||||
// matrix.buffer[rowIdx + matrix.rows*(colIdx)] = value;
|
||||
matrix.buffer[colIdx + matrix.cols * rowIdx] = value;
|
||||
}
|
||||
}
|
||||
|
||||
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
||||
@ -96,7 +102,9 @@ MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int co
|
||||
//checks, if the given indices are allowed
|
||||
if((rowIdx) < matrix.rows && (colIdx) < matrix.cols) {
|
||||
MatrixType returnVal;
|
||||
returnVal = matrix.buffer[rowIdx + matrix.rows*(colIdx)];
|
||||
// Normally one would expect to work matrices like this, but it is supposed to be the other way around.
|
||||
// returnVal = matrix.buffer[rowIdx + matrix.rows*(colIdx)];
|
||||
returnVal = matrix.buffer[colIdx + rowIdx * matrix.cols];
|
||||
return returnVal;
|
||||
}
|
||||
else return 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user