generated from freudenreichan/info2Praktikum-NeuronalesNetz
Finished Set and Get Functions
This commit is contained in:
parent
b9b4d926f5
commit
9eba090e45
17
matrix.c
17
matrix.c
@ -23,15 +23,26 @@ void clearMatrix(Matrix *matrix)
|
|||||||
|
|
||||||
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
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
|
if (rowIdx >= matrix.rows || colIdx >= matrix.cols){
|
||||||
printf("Test: Value at %d, %d : %d\n", rowIdx, colIdx, matrix.buffer[rowIdx][colIdx]);
|
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)
|
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
|
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;
|
return value;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Matrix add(const Matrix matrix1, const Matrix matrix2)
|
Matrix add(const Matrix matrix1, const Matrix matrix2)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user