Finished createMatrix and solved unit Test 2

This commit is contained in:
Jonas Stamm 2025-11-03 14:58:06 +01:00
parent 35cc6f2c7b
commit 772968dfef

View File

@ -1,4 +1,5 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "matrix.h"
@ -6,11 +7,20 @@
Matrix createMatrix(unsigned int rows, unsigned int cols)
{
Matrix matrix;
matrix.rows = rows;
matrix.cols = cols;
matrix.buffer = (float*) calloc(rows * cols, sizeof(float));
return matrix;
if (rows != 0 && cols != 0){
Matrix matrix;
matrix.rows = rows;
matrix.cols = cols;
matrix.buffer = (float*) calloc(rows * cols, sizeof(float)); //belegt den speicherplatz mit calloc
return matrix;
}else{
printf("Nullgroesse der Matrix!!!\n");
Matrix matrix;
matrix.rows = 0;
matrix.cols = 0;
matrix.buffer = NULL;
return matrix;
}
}
void clearMatrix(Matrix *matrix)