An open API service indexing awesome lists of open source software.

https://github.com/alessandroconti11/matrix_library

Library that contains all useful functions for handling matrices and their operations.
https://github.com/alessandroconti11/matrix_library

c cofactor determinant inverse-matrix matrix matrix-operation matrix-types minor pivot rank row-echelon-matrix transpose-matrix

Last synced: 4 months ago
JSON representation

Library that contains all useful functions for handling matrices and their operations.

Awesome Lists containing this project

README

          

# Matrix_Library

Author: Alessandro Conti - [AlessandroConti11](https://github.com/AlessandroConti11)

License: [MIT license](LICENSE).

Tags: `#C`, `#cofactor`, `#determinant`, `#inverse_matrix`, `#matrix`, `#matrix_operation`, `#matrix_type`, `#minor`, `#pivot`, `#rank`, `#row_echelon_matrix`, `#transpose_matrix`.

## Specification

The project aims to create a library that contains all useful functions for handling matrices and their operations.




*For all functions that require a result: you must provide the requested data structure (you can also use the one present as input).*

| **Operation** | **Function** | **Description** | **Order of the Matrices** | **Example of Mathematical Representation** |
|----------------------------------------------------|-------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| create a matrix | __matrix *createMatrix(int n, int m);__ | create an empty matrix | $`\begin{align} &{[A]}:\;n\;x\;m \end{align}`$ | $`\begin{align} &{[A]}=\begin{bmatrix} a_{(0;0)} & a_{(0;1)} & a_{(0;2)} & \cdots & a_{(0;m-1)} \\\ a_{(1;0)} & a_{(1;1)} & a_{(1;2)} & \cdots & a_{(1;m-1)} \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ a_{(n-1;0)} & a_{(n-1;1)} & a_{(n-1;2)} & \cdots & a_{(n-1;m-1)} \end{bmatrix} \end{align}`$ |
| create identity matrix | __matrix *createIdentityMatrix(int n);__ | create an identity matrix | $`\begin{align} &{[Id]}:\;n\;x\;n \end{align}`$ | $`\begin{align} &{[Id]}=\begin{bmatrix} 1 & 0 & 0 & \cdots & 0 \\\ 0 & 1 & 0 & \cdots & 0 \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ 0 & 0 & 0 & \cdots & 1 \end{bmatrix} \end{align}`$ |
| create a null matrix | __matrix *createNullMatrix(int n, int m);__ | create a null matrix | $`\begin{align} &{[0]}:\;n\;x\;m \end{align}`$ | $`\begin{align} &{[0]}=\begin{bmatrix} 0 & 0 & 0 & \cdots & 0 \\\ 0 & 0 & 0 & \cdots & 0 \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ 0 & 0 & 0 & \cdots & 0 \end{bmatrix} \end{align}`$ |
| initialize a matrix | __void initializeMatrix(matrix *a, ...);__ | initialize an empty matrix by filling it by rows | $`\begin{align} &{[A]}:\;n\;x\;m \end{align}`$ | |
| copy a matrix | __void copyMatrix(matrix *a, matrix *b);__ | copy a matrix to another | $`\begin{align} &{{[A]}:\;n\;x\;m} \\ &{{[B]}:\;p\;x\;q} \end{align}`$ | |
| delete a matrix | __void deleteMatrix(matrix *a);__ | delete a given matrix | $`\begin{align} &{[A]}:\;n\;x\;m \end{align}`$ | |
| print a matrix | __void printMatrix(matrix *a);__ | print a given matrix | $`\begin{align} &{[A]}:\;n\;x\;m \end{align}`$ | |
| check if a matrix is an identity matrix | __int isIdentityMatrix(matrix *a);__ | check whether the matrix only elements on the main diagonal equal 1 and the others equal | $`\begin{align} &{[Id]}:\;n\;x\;n \end{align}`$ | $`\begin{align} &{[Id]}=\begin{bmatrix} 1 & 0 & 0 & \cdots & 0 \\\ 0 & 1 & 0 & \cdots & 0 \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ 0 & 0 & 0 & \cdots & 1 \end{bmatrix} \end{align}`$ |
| check if a matrix is a null matrix | __int isNullMatrix(matrix *a);__ | check whether the all matrix elements are equal to 0 | $`\begin{align} &{[0]}:\;n\;x\;m \end{align}`$ | $`\begin{align} &{[0]}=\begin{bmatrix} 0 & 0 & 0 & \cdots & 0 \\\ 0 & 0 & 0 & \cdots & 0 \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ 0 & 0 & 0 & \cdots & 0 \end{bmatrix} \end{align}`$ |
| check if a matrix is a diagonal matrix | __int isDiagonalMatrix(matrix *a);__ | check whether the matrix has all elements not on the main diagonal equal to 0 | $`\begin{align} &{[D]}:\;n\;x\;n \end{align}`$ | $`\begin{align} &{[D]}=\begin{bmatrix} a_{(0;0)} & 0 & 0 & \cdots & 0 \\\ 0 & a_{(1;1)} & 0 & \cdots & 0 \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ 0 & 0 & 0 & \cdots & a_{(n-1;n-1)} \end{bmatrix} \end{align}`$ |
| check if a matrix is anti-diagonal matrix | __int isAntidiagonalMatrix(matrix *a);__ | check whether the matrix has all elements not on the secondary diagonal equal to 0 | $`\begin{align} &{[AD]}:\;n\;x\;n \end{align}`$ | $`\begin{align} &{[AD]}=\begin{bmatrix} 0 & \cdots & 0 & 0 & a_{(0;n-1)} \\\ 0 & \cdots & 0 & a_{(0;n-2)} & 0 \\\ \vdots & \ddots & \vdots & \vdots & \vdots \\\ a_{(n-1;0)} & \cdots & 0 & 0 & 0 \end{bmatrix} \end{align}`$ |
| check if a matrix is an upper diagonal matrix | __int isUpperDiagonalMatrix(matrix *a);__ | check whether the matrix has all elements below the main diagonal equal to 0 | $`\begin{align} &{[UD]}:\;n\;x\;n \end{align}`$ | $`\begin{align} &{[UD]}=\begin{bmatrix} a_{(0;0)} & a_{(0;1)} & a_{(0;1)} & \cdots & a_{(0;n-1)} \\\ 0 & a_{(1;1)} & a_{(1;2)} & \cdots & a_{(1;n-1)} \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ 0 & 0 & 0 & \cdots & a_{(n-1;n-1)} \end{bmatrix} \end{align}`$ |
| check if a matrix is a lower diagonal matrix | __int isLowerDiagonalMatrix(matrix *a);__ | check whether the matrix has all elements above the main diagonal equal to 0 | $`\begin{align} &{[LD]}:\;n\;x\;n \end{align}`$ | $`\begin{align} &{[LD]}=\begin{bmatrix} a_{(0;0)} & 0 & 0 & \cdots & 0 \\\ a_{(1;0)} & a_{(1;1)} & 0 & \cdots & 0 \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ a_{(n-1;0)} & a_{(n-1;1)} & a_{(n-1;2)} & \cdots & a_{(n-1;n-1)}) \end{bmatrix} \end{align}`$ |
| check if a matrix is a symmetric matrix | __int isSymmetricMatrix(matrix *a);__ | check whether the matrix has all the element (i, j) equal to the element (j, i) | $`\begin{align} &{[S]}:\;n\;x\;n \end{align}`$ | $`\begin{align} &{[S]}=\begin{bmatrix} a_{(0;0)} & a_{(0;1)} & a_{(0;2)} & \cdots & a_{(0;n-1)} \\\ a_{(0;1)} & a_{(1;1)} & a_{(1;2)} & \cdots & a_{(1;n-1)} \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ a_{(0;n-1)} & a_{(1;n-1)} & a_{(2;n-1)} & \cdots & a_{(n-1;n-1)} \end{bmatrix} \end{align}`$ |
| check if a matrix is an anti-symmetric matrix | __int isAntisymmetricMatrix(matrix *a);__ | check whether the matrix has the elements (i, j) opposite to those (j, i) | $`\begin{align} &{[AS]}:\;n\;x\;n \end{align}`$ | $`\begin{align} &{[AS]}=\begin{bmatrix} a_{(0;0)} & a_{(0;1)} & a_{(0;2)} & \cdots & a_{(0;n-1)} \\\ -a_{(0;1)} & a_{(1;1)} & a_{(1;2)} & \cdots & a_{(1;n-1)} \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ -a_{(0;n-1)} & -a_{(1;n-1)} & -a_{(2;n-1)} & \cdots & a_{(n-1;n-1)} \end{bmatrix} \end{align}`$ |
| check if a matrix is invertible | __int isInvertibleMatrix(matrix *a);__ | check whether the determinant is different from 0 | $`\begin{align} &{[A]}:\;n\;x\;n \end{align}`$ | |
| check if a matrix is a row-echelon matrix | __int isRowEchelonMatrix(matrix *a);__ | check whether the first nonzero element of each row is further to the right than the first nonzero element of the previous row. | $`\begin{align} &{[RE]}:\;n\;x\;m \end{align}`$ | $`\begin{align} &{[RE]}=\begin{bmatrix} a_{(0;0)} & a_{(0;1)} & a_{(0;2)} & \cdots & a_{(0;m-1)} \\\ 0 & 0 & a_{(1;2)} & \cdots & a_{(1;m-1)} \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ 0 & 0 & 0 & \cdots & a_{(n-1;m-1)} \end{bmatrix} \end{align}`$ |
| check if a matrix is an Hankel matrix | __int isHankelMatrix(matrix *a);__ | check whether the matrix has all the element (i, j) equal to the element (i-1, j+1) | $`\begin{align} &{[H]}:\;n\;x\;n \end{align}`$ | $`\begin{align} &{[H]}=\begin{bmatrix} a_0 & a_1 & a_2 & \cdots & a_{n-1} \\\ a_1 & a_2 & a_3 & \cdots & a_n \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ a_{n-1} & a_n & a_{n+1} & \cdots & a_{n+n-2} \end{bmatrix} \end{align}`$ |
| check if a matrix is a Toeplitz matrix | __int isToeplitzMatrix(matrix *a);__ | check whether the matrix has all the element (i, j) equal to the element (i-1, j-1) | $`\begin{align} &{[T]}:\;n\;x\;n \end{align}`$ | $`\begin{align} &{[T]}=\begin{bmatrix} a_0 & a_{-1} & a_{-2} & \cdots & a_{-n} \\\ a_1 & a_0 & a_{-1} & \cdots & a_{-n+1} \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ a_{n-2} & a_{n-3} & a_{n-4} & \cdots & a_0 \end{bmatrix} \end{align}`$ |
| transpose a matrix | __void transposingMatrix(matrix *a, matrix *trans);__ | the transposed matrix is given by the elements (j, i) | $`\begin{align} &{[A]}:\;n\;x\;m \\ &{[A]^T}:\;m\;x\;n \end{align}`$ | $`\begin{align} &{[A]}^T=\begin{bmatrix} a_{(0;0)} & a_{(1;0)} & a_{(2;0)} & \cdots & a_{(n-1;0)} \\\ a_{(0;1)} & a_{(1;1)} & a_{(2;1)} & \cdots & a_{(n-1;1)} \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ a_{(0;m-1)} & a_{(1;m-1)} & a_{(2;m-1)} & \cdots & a_{(n-1;m-1)} \end{bmatrix} \end{align}`$ |
| invert a matrix | __void inverseMatrix(matrix *a, matrix *inv);__ | inverse the matrix using the method of cofactors | $`\begin{align} &{[A]}:\;n\;x\;n \\ &{[A]^{-1}}:\;n\;x\;n \end{align}`$ | $`\begin{align} &{[A]}^{-1}={\frac{1}{det(A)}}{\begin{bmatrix} Cof(0;0) & Cof(0;1) & Cof(0;2) & \cdots & Cof(0;n-1) \\\ Cof(1;0) & Cof(1;1) & Cof(1;2) & \cdots & Cof(1;n-1) \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ Cof(n-1;0) & Cof(n-1;1) & Cof(n-1;2) & \cdots & Cof(n-1;n-1) \end{bmatrix}}^T \end{align}`$ |
| transform a matrix to a row-echelon matrix | __void rowEchelonMatrix(matrix *a, matrix *step);__ | transform the matrix using the Gaussian elimination method | $`\begin{align} &{[A]}:\;n\;x\;m \\ &{[A_{RE}]}:\;n\;x\;m \end{align}`$ | $`\begin{align} &{[A_{RE}]}=\begin{bmatrix} {a'}_{(0;0)} & {a'}_{(0;1)} & {a'}_{(0;2)} & \cdots & {a'}_{(0;m-1)} \\\ 0 & 0 & {a'}_{(1;2)} & \cdots & {a'}_{(1;m-1)} \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ 0 & 0 & 0 & \cdots & {a'}_{(n-1;m-1)} \end{bmatrix} \end{align}`$ |
| compute the absolute matrix | __void absMatrix(matrix *a, matrix *abs);__ | compute the absolute value for each matrix element | $`\begin{align} &{[A]}:\;n\;x\;m \\ &{[A_{ABS}]}:\;n\;x\;m \end{align}`$ | $`\begin{align} &{[A_{ABS}]}=\begin{bmatrix} \left\lvert a_{(0;0)} \right\rvert & \left\lvert a_{(0;1)} \right\rvert & \left\lvert a_{(0;2)} \right\rvert & \cdots & \left\lvert a_{(0;m-1)} \right\rvert \\\ \left\lvert a_{(1;0)} \right\rvert & \left\lvert a_{(1;1)} \right\rvert & \left\lvert a_{(1;2)} \right\rvert & \cdots & \left\lvert a_{(1;m-1)} \right\rvert \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ \left\lvert a_{(n-1;0)} \right\rvert & \left\lvert a_{(n-1;1)} \right\rvert & \left\lvert a_{(n-1;2)} \right\rvert & \cdots & \left\lvert a_{(n-1;m-1)} \right\rvert \end{bmatrix} \end{align}`$ |
| compute the minor of a matrix | __double minor(matrix *a, int row, int column);__ | compute the minor (row, column)-th, the determinant of the matrix without the row and the column specified | $`\begin{align} &{[A]}:\;n\;x\;n \end{align}`$ | $`\begin{align} &{Min_{(0;0)}}={Det \left(\begin{bmatrix} a_{(1;1)} & a_{(1;2)} & a_{(1;3)} & \cdots & a_{(1;n-1)} \\\ a_{(2;1)} & a_{(2;1)} & a_{(2;3)} & \cdots & a_{(2;n-1)} \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ a_{(n-1;1)} & a_{(n-1;2)} & a_{(n-1;3)} & \cdots & a_{(n-1;n-1)} \end{bmatrix}\right)} \end{align}`$ |
| compute the cofactor of a matrix | __double cofactor(matrix *a, int row, int column);__ | compute the cofactor (row, column)-th, the (-1)^(row+column) determinant of the matrix without the row and the column specified | $`\begin{align} &{[A]}:\;n\;x\;n \end{align}`$ | $`\begin{align} &{Cof_{(i;j)}}={(-1)}^{(i+j)} \cdot \left\lvert Min_{(i;j)} \right\rvert \end{align}`$ |
| compute the determinant of a matrix | __double determinantMatrix(matrix *a);__ | compute the determinant of the matrix | $`\begin{align} &{[A]}:\;n\;x\;n \end{align}`$ | $`\begin{align}Det([A])=\sum_{j=0}^{n-1}{\left(a_{(i;j)} \cdot Cof_{(i;j)}\right)} \end{align}`$ |
| compute the rank of a matrix | __int rankMatrix(matrix *a);__ | compute the rank of the matrix using the minor method | $`\begin{align} &{[A]}:\;n\;x\;m \end{align}`$ | $`\begin{align}\begin{cases} &{matrix\;order, \quad if\;Det([A])\neq 0} \\ \; \\ &{order\;of\;the\;maximum\;possible\;non\;zero\;minor\;of\;the\;matrix, \quad if\;Det([A])=0} \end{cases} \end{align}`$ |
| compute the sum between two matrices | __void sumMatrix(matrix *a, matrix *b, matrix *res);__ | compute the sum between two given matrices | $`\begin{align} &{[A]}:\;n\;x\;m \\ &{[B]}:\;n\;x\;m \\ &{[A+B]}:\;n\;x\;m \end{align}`$ | $`\begin{align} &{[A+B]}=\begin{bmatrix} {a_{(0;0)}+b_{(0;0)}} & {a_{(0;1)}+b_{(0;1)}} & {a_{(0;2)}+b_{(0;2)}} & \cdots & {a_{(0;m-1)}+b_{(0;m-1)}} \\\ {a_{(1;0)}+b_{(1;0)}} & {a_{(1;1)}+b_{(1;1)}} & {a_{(1;2)}+b_{(1;2)}} & \cdots & {a_{(1;m-1)}+b_{(1;m-1)}} \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ {a_{(n-1;0)}+b_{(n-1;0)}} & {a_{(n-1;1)}+b_{(n-1;1)}} & {a_{(n-1;2)}+b_{(n-1;2)}} & \cdots & {a_{(n-1;m-1)}+b_{(n-1;m-1)}} \end{bmatrix} \end{align}`$ |
| compute the difference between two matrices | __void subMatrix(matrix *a, matrix *b, matrix *res);__ | compute the difference between two given matrices | $`\begin{align} &{[A]}:\;n\;x\;m \\ &{[B]}:\;n\;x\;m \\ &{[A-B]}:\;n\;x\;m \end{align}`$ | $`\begin{align} &{[A-B]}=\begin{bmatrix} {a_{(0;0)}-b_{(0;0)}} & {a_{(0;1)}-b_{(0;1)}} & {a_{(0;2)}-b_{(0;2)}} & \cdots & {a_{(0;m-1)}-b_{(0;m-1)}} \\\ {a_{(1;0)}-b_{(1;0)}} & {a_{(1;1)}-b_{(1;1)}} & {a_{(1;2)}-b_{(1;2)}} & \cdots & {a_{(1;m-1)}-b_{(1;m-1)}} \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ {a_{(n-1;0)}-b_{(n-1;0)}} & {a_{(n-1;1)}-b_{(n-1;1)}} & {a_{(n-1;2)}-b_{(n-1;2)}} & \cdots & {a_{(n-1;m-1)}-b_{(n-1;m-1)}} \end{bmatrix} \end{align}`$ |
| compute the scalar product of a matrix | __void scalarProductMatrix(double scalar, matrix *a, matrix *res);__ | compute the scalar product of the matrix | $`\begin{align} &{[A]}:\;n\;x\;m \\ &{[k \cdot A]}:\;n\;x\;m \end{align}`$ | $`\begin{align} &{[k \cdot A]}=\begin{bmatrix} {k \cdot a_{(0;0)}} & {k \cdot a_{(0;1)}} & {k \cdot a_{(0;2)}} & \cdots & {k \cdot a_{(0;m-1)}} \\\ {k \cdot a_{(1;0)}} & {k \cdot a_{(1;1)}} & {k \cdot a_{(1;2)}} & \cdots & {k \cdot a_{(1;m-1)}} \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ {k \cdot a_{(n-1;0)}} & {k \cdot a_{(n-1;1)}} & {k \cdot a_{(n-1;2)}} & \cdots & {k \cdot a_{(n-1;m-1)}} \end{bmatrix} \end{align}`$ |
| compute the product between two matrices | __void productMatrix(matrix *a, matrix *b, matrix *res);__ | compute the product between two given matrices | $`\begin{align} &{[A]}:\;n\;x\;p \\ &{[B]}:\;p\;x\;m \\ &{[A \cdot B]}:\;n\;x\;m \end{align}`$ | $`\begin{align} &{[A \cdot B]}=\begin{bmatrix} {\sum_{k=1}^n{a_{(0;k)} \cdot b_{(k;0)}}} & {\sum_{k=1}^n{a_{(0;k)} \cdot b_{(k;1)}}} & {\sum_{k=1}^n{a_{(0;k)} \cdot b_{(k;2)}}} & \cdots & {\sum_{k=1}^n{a_{(0;k)} \cdot b_{(k;m-1)}}} \\\ {\sum_{k=1}^n{a_{(1;k)} \cdot b_{(k;0)}}} & {\sum_{k=1}^n{a_{(1;k)} \cdot b_{(k;1)}}} & {\sum_{k=1}^n{a_{(1;k)} \cdot b_{(k;2)}}} & \cdots & {\sum_{k=1}^n{a_{(1;k)} \cdot b_{(k;m-1)}}} \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ {\sum_{k=1}^n{a_{(n-1;k)} \cdot b_{(k;0)}}} & {\sum_{k=1}^n{a_{(n-1;k)} \cdot b_{(k;1)}}} & {\sum_{k=1}^n{a_{(n-1;k)} \cdot b_{(k;2)}}} & \cdots & {\sum_{k=1}^n{a_{(n-1;k)} \cdot b_{(k;m-1)}}} \end{bmatrix} \end{align}`$ |
| compute the power elevation of a matrix | __void powerMatrix(matrix *a, int k, matrix *res);__ | compute the power elevation of the matrix | $`\begin{align} &{[A]}:\;n\;x\;n \\ &{[A]^k}:\;n\;x\;n \end{align}`$ | $`\begin{align} &{[A]^k}=\prod^k{\begin{bmatrix} a_{(0;0)} & a_{(0;1)} & a_{(0;2)} & \cdots & a_{(0;n-1)} \\\ a_{(1;0)} & a_{(1;1)} & a_{(1;2)} & \cdots & a_{(1;n-1)} \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ a_{(n-1;0)} & a_{(n-1;1)} & a_{(n-1;2)} & \cdots & a_{(n-1;n-1)} \end{bmatrix}} \end{align}`$ |
| compute the direct sum between two matrices | __void directSumMatrix(matrix *a, matrix *b, matrix *res);__ | compute the direct sum between two matrices, the first matrix is placed in the upper-left corner and the second matrix in the bottom-right corner | $`\begin{align} &{[A]}:\;n\;x\;m \\ &{[B]}:\;p\;x\;q \\ &{[A \oplus B]}:\;(n+p)\;x\;(m+q) \end{align}`$ | $`\begin{align} &{[A \oplus B]}=\begin{bmatrix} [A] & [0] \\\ [0] & [B] \end{bmatrix} \end{align}`$ |
| compute the Kronecker product between two matrices | __void kroneckerProductMatrix(matrix *a, matrix *b, matrix *res);__ | compute the Kronecker product between two matrices | $`\begin{align} &{[A]}:\;n\;x\;m \\ &{[B]}:\;p\;x\;q \\ &{[A \otimes B]}:\;(n \cdot p)\;x\;(m \cdot q) \end{align}`$ | $`\begin{align} &{[A \otimes B]}=\begin{bmatrix} {a_{(0;0)} \cdot [B]} & {a_{(0;1)} \cdot [B]} & {a_{(0;2)} \cdot [B]} & \cdots & {a_{(0;m-1)} \cdot [B]} \\\ {a_{(1;0)} \cdot [B]} & {a_{(1;1)} \cdot [B]} & {a_{(1;2)} \cdot [B]} & \cdots & {a_{(1;m-1)} \cdot [B]} \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ {a_{(n-1;0)} \cdot [B]} & {a_{(n-1;1)} \cdot [B]} & {a_{(n-1;2)} \cdot [B]} & \cdots & {a_{(n-1;m-1)} \cdot [B]} \end{bmatrix} \end{align}`$ |
| swap two rows of a matrix | __void swapRowMatrix(matrix *a, int row1, int row2, matrix *swap);__ | swap two rows of given matrix | $`\begin{align} &{[A]}:\;n\;x\;m \\ &{[SR_{(i;j)}]}:\;n\;x\;m \end{align}`$ | $`\begin{align} &{[SR_{(0;n)}]}=\begin{bmatrix} a_{(n-1;0)} & a_{(n-1;1)} & a_{(n-1;2)} & \cdots & a_{(n-1;m-1)} \\\ a_{(1;0)} & a_{(1;1)} & a_{(1;2)} & \cdots & a_{(1;m-1)} \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ a_{(0;0)} & a_{(0;1)} & a_{(0;2)} & \cdots & a_{(0;m-1)} \end{bmatrix} \end{align}`$ |
| swap two column of a matrix | __void swapColumnMatrix(matrix *a, int col1, int col2, matrix *swap);__ | swap two column of given matrix | $`\begin{align} &{[A]}:\;n\;x\;m \\ &{[SC_{(i;j)}]}:\;n\;x\;m \end{align}`$ | $`\begin{align} &{[SC_{(0;n)}]}=\begin{bmatrix} a_{(0;n-1)} & a_{(0;1)} & a_{(0;2)} & \cdots & a_{(0;0)} \\\ a_{(1;n-1)} & a_{(1;1)} & a_{(1;2)} & \cdots & a_{(1;0)} \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ a_{(n-1;n-1)} & a_{(n-1;1)} & a_{(n-1;2)} & \cdots & a_{(n-1;0)} \end{bmatrix} \end{align}`$ |
| find the maximum value in a matrix | __double findMaxMatrix(matrix *a, int *rowPos, int *colPos);__ | find the maximum value in the matrix and return its position | $`\begin{align} &{[A]}:\;n\;x\;m \end{align}`$ | |
| find the minimum value in a matrix | __double findMinMatrix(matrix *a, int *rowPos, int *colPos);__ | find the minimum value in the matrix and return its position | $`\begin{align} &{[A]}:\;n\;x\;m \end{align}`$ | |
| find the elements on the diagonal of a matrix | __double *diagonalMatrix(matrix *a, int *numberOfElements);__ | find the elements on the diagonal of the matrix | $`\begin{align} &{[A]}:\;n\;x\;m \end{align}`$ | $`\begin{align}\overrightarrow{Diagonal}=\begin{bmatrix} a_{(0;0)} & a_{(1;1)} & \cdots & a_{(n-1;n-1)} \end{bmatrix} \end{align}`$ |
| find the pivot in a matrix | __double *pivot(matrix *a, int *pivotsNumber);__ | find the pivots in the matrix transforming it in a row-echelon matrix | $`\begin{align} &{[A]}:\;n\;x\;m \end{align}`$ | |
| decompose a matrix using Lower-Upper decomposition | __void luDecomposition(matrix *a, matrix *l, matrix *u);__ | decompose a matrix using Lower-Upper decomposition, the matrix is decomposed in a lower triangular matrix and an upper triangular matrix | $`\begin{align} &{[A]}:\;n\;x\;n \\ &{[L]}:\;n\;x\;n \\ &{[U]}:\;n\;x\;n \end{align}`$ | $`\begin{align} &{[A]=[L] \cdot [U]} \\ &{\begin{cases} &{{[L]}={\begin{bmatrix} 1 & 0 & 0 & \cdots & 0 \\\ l_{(1;0)} & 1 & 0 & \cdots & 0 \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ l_{(n-1;0)} & l_{(n-1;1)} & l_{(n-1;2)} & \cdots & l_{(n-1;n-1)} \end{bmatrix}}} \\ \; \\ &{{[U]}={\begin{bmatrix} u_{(0;0)} & u_{(0;1)} & u_{(0;2)} & \cdots & u_{(0;n-1)} \\\ 0 & u_{(1;1)} & u_{(1;2)} & \cdots & u_{1;n-1} \\\ \vdots & \vdots & \vdots & \ddots & \vdots \\\ 0 & 0 & 0 & \cdots & u_{(n-1;n-1)} \end{bmatrix}}} \end{cases}} \end{align}`$ |

## How to run

0. install gcc
```bash
sudo apt-get install gcc
```
1. compile the project
```bash
gcc -Wall -Werror -O2 -g3 main.c -o EXECUTABLE
```
2. run the project
```bash
./EXECUTABLE
```


The Makefile in the repository can also be used to compile the code.
- this option allows you to compile with the following tags: *-Wall -Werror -O2 -g3*
```bash
make compile
```
- if you want to specify different tags, you can set them
```bash
make compile CFLAGS=YOUR_FLAGS
```
- if you want to use Address SANitizer
```bash
make asan
```
- if you want to delete some file - default is the executable file
```bash
make clean
```

## Contribute

- If you find a security vulnerability, do NOT open an issue. Email [Alessandro Conti](mailto:ale.conti.1101@gmail.com) instead.
- If you find a bug or error or want to add some other function that is not implemented yet
1. **FORK** the repo
2. **CLONE** the project to your own machine
3. **COMMIT** to your own branch
4. **PUSH** your work back up to your fork
5. submit a **PULL REQUEST** so that I can review your changes
> NOTE: Be sure to merge the latest from "upstream" before making a pull request!

### Code Style

Each new function must be documented using the following style:
- *Short function description*: A brief description explaining what the function does.
- *@details*: A detailed section describing how the function works, explaining the algorithms and logic used.
- *@warning*: A section listing all the assumptions made by the function, such as the preconditions that the parameters must fulfil.
- *Blank line*: Add a blank line to separate the documentation sections.
- *@param*: A list of the parameters required by the function, each accompanied by a brief description of its role and type.
- *@return*: A description of what the function returns, including the data type.

Within the function, *each variable* must be commented out to explain its purpose.
In general, any additional comments that might improve understanding of the code are welcome. 😃