forked from freudenreichan/info2Praktikum-NeuronalesNetz
47 lines
1.2 KiB
C
47 lines
1.2 KiB
C
#include "matrix.h"
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
// TODO Matrix-Funktionen implementieren
|
|
|
|
/*typedef struct {
|
|
|
|
unsigned int rows;
|
|
unsigned int cols;
|
|
MatrixType *data; //Zeiger auf Speicherbereich Reihen*Spalten
|
|
|
|
} Matrix;*/
|
|
|
|
Matrix createMatrix(unsigned int rows, unsigned int cols) {
|
|
MatrixType *data =
|
|
malloc(rows * cols * sizeof(MatrixType)); // Speicher reservieren, malloc
|
|
// liefert Zeiger auf Speicher
|
|
Matrix newMatrix = {rows, cols, data}; // neue Matric nach struct
|
|
return newMatrix;
|
|
}
|
|
|
|
void clearMatrix(Matrix *matrix) {
|
|
|
|
matrix->data = UNDEFINED_MATRIX_VALUE;
|
|
matrix->rows = UNDEFINED_MATRIX_VALUE;
|
|
matrix->cols = UNDEFINED_MATRIX_VALUE;
|
|
|
|
free((*matrix).data); //Speicher freigeben
|
|
|
|
}
|
|
|
|
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx,
|
|
unsigned int colIdx) {
|
|
|
|
float *rowPtr[matrix->rows] = (*matrix).data
|
|
|
|
}
|
|
|
|
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx,
|
|
unsigned int colIdx) {}
|
|
|
|
Matrix add(const Matrix matrix1, const Matrix matrix2) {
|
|
// broadcasting
|
|
}
|
|
|
|
Matrix multiply(const Matrix matrix1, const Matrix matrix2) {} |