generated from freudenreichan/info2Praktikum-NeuronalesNetz
Finished Set and Get Functions
This commit is contained in:
parent
b9b4d926f5
commit
9eba090e45
19
matrix.c
19
matrix.c
@ -23,15 +23,26 @@ void clearMatrix(Matrix *matrix)
|
||||
|
||||
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
||||
{
|
||||
matrix = {rowIdx, colIdx, value}; //Writes Value of value variable in the selected place in Matrix
|
||||
printf("Test: Value at %d, %d : %d\n", rowIdx, colIdx, matrix.buffer[rowIdx][colIdx]);
|
||||
if (rowIdx >= matrix.rows || colIdx >= matrix.cols){
|
||||
printf("Index out of bounds\n"); //Error Message because Index Input exceeds Matrix
|
||||
}
|
||||
else{
|
||||
matrix.buffer[rowIdx * matrix.cols + colIdx] = value; //Writes Value of value variable in the selected place in Matrix
|
||||
}
|
||||
}
|
||||
|
||||
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
||||
{
|
||||
value = matrix.buffer[rowIdx][colIdx]; //Stores value of selected place in Matrix in value variable
|
||||
return value;
|
||||
if (rowIdx >= matrix.rows || colIdx >= matrix.cols){
|
||||
printf("Index out of bounds\n");
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
|
||||
MatrixType value = matrix.buffer[rowIdx * matrix.cols + colIdx]; //Stores value of selected place of Matrix in value variable
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
Matrix add(const Matrix matrix1, const Matrix matrix2)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user