generated from freudenreichan/info2Praktikum-NeuronalesNetz
71 lines
1.3 KiB
C
71 lines
1.3 KiB
C
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include "matrix.h"
|
|
|
|
// TODO Matrix-Funktionen implementieren
|
|
|
|
typedef struct Matrix {
|
|
unsigned int xElement;
|
|
unsigned int yElement;
|
|
int ** data;
|
|
} Matrix;
|
|
|
|
Matrix createMatrix(unsigned int rows, unsigned int cols)
|
|
{
|
|
Matrix m;
|
|
m.xElement = rows;
|
|
m.yElement = cols;
|
|
m.data = NULL;
|
|
|
|
if(rows == 0 || cols == 0){
|
|
m.xElement = m.yElement = 0;
|
|
return m;
|
|
}
|
|
|
|
m.data = malloc(rows * sizeof *m.data);
|
|
|
|
if(!m.data){
|
|
m.xElement = m.yElement = 0;
|
|
return m;
|
|
}
|
|
for(unsigned int i = 0; i < rows; i++){
|
|
m.data[i] = malloc(cols * sizeof *m.data[i]);
|
|
|
|
if(!m.data[i]){
|
|
for(unsigned int j = 0; j < i; j++){
|
|
free(m.data[j]);
|
|
}
|
|
free(m.data);
|
|
m.data = NULL;
|
|
m.xElement = m.yElement = 0;
|
|
return m;
|
|
}
|
|
|
|
}
|
|
return m;
|
|
}
|
|
|
|
void clearMatrix(Matrix *matrix)
|
|
{
|
|
|
|
}
|
|
|
|
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
|
{
|
|
|
|
}
|
|
|
|
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
|
{
|
|
|
|
}
|
|
|
|
Matrix add(const Matrix matrix1, const Matrix matrix2)
|
|
{
|
|
|
|
}
|
|
|
|
Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
|
{
|
|
|
|
} |