Finished Set and Get Functions

This commit is contained in:
Niko Rost 2025-11-14 16:43:17 +01:00
parent b9b4d926f5
commit 9eba090e45

View File

@ -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
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)
{