Compare commits

...

2 Commits
main ... main

Author SHA1 Message Date
5f2056acb4 create fert 2025-11-11 11:16:37 +01:00
538a9d6687 test 2025-11-11 10:42:30 +01:00
2 changed files with 40 additions and 3 deletions

View File

@ -1,17 +1,47 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "matrix.h" #include "matrix.h"
#include <stdio.h>
// TODO Matrix-Funktionen implementieren // TODO Matrix-Funktionen implementieren ... ok
Matrix createMatrix(unsigned int rows, unsigned int cols) Matrix createMatrix(unsigned int rows, unsigned int cols)
{ {
Matrix matrix;
if (rows == 0 || cols == 0)
{
matrix.rows = 0;
matrix.cols =0;
matrix.data = NULL;
return matrix;
}
matrix.rows = rows;
matrix.cols = cols;
matrix.data = (MatrixTyype *)malloc(rows * cols * sizeof(MatrixType));
if (matrix.data == NULL)
{
matrix.rows = 0;
matrix.cols = 0;
return matrix;
}
for (int i = 0; i<rows; i++)
{
for (int j = 0; j<cols; j++)
{
matrix.data[i * matrix.cols +j] = UNDEFINED_MATRIX_VALUE;
}
}
return matrix;
} }
void clearMatrix(Matrix *matrix) 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)

View File

@ -7,6 +7,13 @@ typedef float MatrixType;
// TODO Matrixtyp definieren // TODO Matrixtyp definieren
typedef struct Matrix
{
unsigend int rows;
unsigned int cols;
Matrixtype *data;
#define buffer data
} Matrix;
Matrix createMatrix(unsigned int rows, unsigned int cols); Matrix createMatrix(unsigned int rows, unsigned int cols);
void clearMatrix(Matrix *matrix); void clearMatrix(Matrix *matrix);