generated from freudenreichan/info2Praktikum-NeuronalesNetz
create matrix erstellt
This commit is contained in:
1 parent
1e9579db2b
commit
1417c4f421
1 file changed
+22
-1
+22
-1
@@ -1,10 +1,31 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "matrix.h"
|
#include "matrix.h"
|
||||||
|
|
||||||
|
|
||||||
Matrix createMatrix(unsigned int rows, unsigned int cols){
|
Matrix createMatrix(unsigned int rows, unsigned int cols){
|
||||||
|
/*
|
||||||
|
unsigned int memory_depth = 0;
|
||||||
|
memory_depth = rows * cols; //Meine Speichertiefe ist die Anzahl meiner Spalten mal die Reihen
|
||||||
|
|
||||||
|
unsigned int memory_reservation = 0;
|
||||||
|
memory_reservation = memory_depth * sizeof(MatrixType); //Nimmt die Speichertiefe mal die größe der einzelnen Speicherinhalte (float)
|
||||||
|
|
||||||
|
Matrix.space = malloc(memory_reservation); //Reserviert den Speicher und gibt den Zeiger auf die erste Speicheradresse dem zeiger space
|
||||||
|
*/
|
||||||
|
Matrix matrix; //Matrix ist der Datentyp (im struct bestimmt). wir brauchen hier aber eine lokale variable (!NIX GLOBAL!) daher ist matrix eine Variable vom Typ Matrix.
|
||||||
|
|
||||||
|
matrix.rows = rows;
|
||||||
|
matrix.cols = cols;
|
||||||
|
matrix.space = malloc(rows * cols * sizeof(MatrixType));
|
||||||
|
|
||||||
|
if (matrix.space == NULL) {
|
||||||
|
fprintf(stderr, "Error, matrix could not be created...\n");
|
||||||
|
matrix.rows = 0;
|
||||||
|
matrix.cols = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return matrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user