Finished createMatrix and solved unit Test 2
This commit is contained in:
parent
35cc6f2c7b
commit
772968dfef
12
matrix.c
12
matrix.c
@ -1,4 +1,5 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "matrix.h"
|
#include "matrix.h"
|
||||||
|
|
||||||
@ -6,11 +7,20 @@
|
|||||||
|
|
||||||
Matrix createMatrix(unsigned int rows, unsigned int cols)
|
Matrix createMatrix(unsigned int rows, unsigned int cols)
|
||||||
{
|
{
|
||||||
|
if (rows != 0 && cols != 0){
|
||||||
Matrix matrix;
|
Matrix matrix;
|
||||||
matrix.rows = rows;
|
matrix.rows = rows;
|
||||||
matrix.cols = cols;
|
matrix.cols = cols;
|
||||||
matrix.buffer = (float*) calloc(rows * cols, sizeof(float));
|
matrix.buffer = (float*) calloc(rows * cols, sizeof(float)); //belegt den speicherplatz mit calloc
|
||||||
return matrix;
|
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)
|
void clearMatrix(Matrix *matrix)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user