generated from freudenreichan/info2Praktikum-NeuronalesNetz
55 lines
1.3 KiB
C
55 lines
1.3 KiB
C
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include "matrix.h"
|
|
|
|
// TODO Matrix-Funktionen implementieren
|
|
|
|
Matrix createMatrix(unsigned int rows, unsigned int cols)
|
|
{
|
|
Matrix matrix = {NULL,rows,cols};
|
|
if(rows != 0 && cols != 0){
|
|
matrix.buffer = calloc(rows * cols, sizeof(MatrixType));
|
|
if(matrix.buffer == NULL){
|
|
matrix.rows = 0;
|
|
matrix.cols = 0; // alternativ Programm beenden mit exit -> so einfach dimensionslos
|
|
}
|
|
}else{
|
|
matrix.rows = 0;
|
|
matrix.cols = 0;
|
|
}
|
|
|
|
return matrix;
|
|
}
|
|
|
|
void clearMatrix(Matrix *matrix)
|
|
{
|
|
free(matrix->buffer);
|
|
matrix->buffer = NULL;
|
|
matrix->rows = 0;
|
|
matrix->cols = 0;
|
|
}
|
|
|
|
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
|
{
|
|
if(matrix.rows > rowIdx && matrix.cols > colIdx){
|
|
matrix.buffer[colIdx + rowIdx * matrix.cols] = value;
|
|
}
|
|
}
|
|
|
|
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
|
{
|
|
MatrixType testHelp = 0;
|
|
return testHelp;
|
|
}
|
|
|
|
Matrix add(const Matrix matrix1, const Matrix matrix2)
|
|
{
|
|
Matrix testHelp = {NULL, 0,0};
|
|
return testHelp;
|
|
}
|
|
|
|
Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
|
{
|
|
Matrix testHelp = {NULL, 0,0};
|
|
return testHelp;
|
|
} |