Info2-Aufgabe2/matrix.h

41 lines
928 B
C

#ifndef MATRIX_H
#define MATRIX_H
#define UNDEFINED_MATRIX_VALUE 0
typedef float MatrixType;
// TODO Matrixtyp definieren
typedef struct {
unsigned int rows;
unsigned int cols;
MatrixType *buffer;
} Matrix;
Matrix createMatrix(unsigned int rows, unsigned int cols);
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);
#endif
/*
struct -> Matrix liegt im Speicher direkt hintereinander
Array:
000
111
222
333
Speicher -> [000111222333] (Könnte auch andere anzahl an reihen oder spalten haben in speicher nicht sichtabar)
rows und cols Anzahl der Reihen und Zeilen (fängt bei 1 an)
buffer zeigt auf den Wert im Speicher
*/