Start to manage matrices - GianlucaMancusi/matrix_computation GitHub Wiki
With that kind of Matrix structure I will work?
struct matrix
The struct matrix is a truly lightweight design that allows you to manage matrices in the easiest and fastest way. It's composed by 3 data:
struct matrix {
size_t rows; //how many rows have this matrix?
size_t cols; //how many cols have this matrix?
double* data;//pointer to data with all matrix information. I recommend using double *elementAt(struct matrix *matr, size_t rowIndex, size_t colIndex); to access it!
};
How to create a new matrix
With this library create a matrix is easy and performing.
This is the function that lets you create a matrix with undefined values:
struct matrix *creatematr(size_t rows, size_t cols)
This function returns a type matrix structure
This is the function that lets you create an empty array filled with zeros:
struct matrix *createemptymatr(size_t rows, size_t cols)
This function returns a type matrix structure
How to access to a matrix
With this library access to a matrix is easy and performing.
This feature allows you to access the r-th row item and the c-th col item of a 'matr' matrix:
double * elementAt(struct matrix * matr, size_t rowIndex, size_t colIndex)
This function returns the value of the matrix at r-th row and c-th col
Destroy a matrix
It's important to destroy the allocated matrix.
Simply, this function clean the data and structure:
void destroymatr(struct matrix* matr)