A C library for matrix operations, including basic, advanced, and utility functions.
- Matrix: Represents a matrix with rows, columns, and float data.
- MatrixRegistry: Manages matrix memory for release.
Matrix create_matrix(int rows, int cols, float val): Creates an initialized matrix.void free_registry(): Frees memory of all matrices.
ErrorCode sum(Matrix a, Matrix b, Matrix r): Adds matrices.ErrorCode multiply(Matrix a, Matrix b, Matrix r): Matrix multiplication.ErrorCode transpose(Matrix a, Matrix r): Transposition.- Scalar operations:
sum_number,multiply_number, etc.
void show(Matrix a): Prints the matrix.ErrorCode copy_matrix(Matrix* a, Matrix* r): Copies matrices.void fill(Matrix a, float n): Fills with constant value.
ErrorCode determinant(Matrix a, Matrix r, float* det): Computes determinant.ErrorCode inverse(Matrix a, Matrix r): Computes inverse.ErrorCode decomp_PLU(Matrix a, Matrix L, Matrix U, Matrix P): PLU decomposition.ErrorCode solve_PLU(const Matrix a, const Matrix L, const Matrix U, const Matrix P, const Matrix b, Matrix x): Solves linear systems.
Use the Makefile:
makeThis compiles the library and the matrix_app executable.
Include the headers in your code:
#include "matrix.h"
#include "operations_basic.h"
// and other headers like operations_utils.h, operations.h
int main() {
Matrix a = create_matrix(2, 2, 1.0);
show(a);
free_registry();
return 0;
}Error codes are defined in errores.h. Check the return of functions that return ErrorCode.
- Standard C (stdlib, stdio, etc.).
- For randomness: uses
srandandrand.
Add functions in the corresponding files and update headers with Doxygen documentation.