| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Author: Alessandro Conti - AlessandroConti11
License: MIT license.
Tags: #C, #cofactor, #determinant, #inverse_matrix, #matrix, #matrix_operation, #matrix_type, #minor, #pivot, #rank, #row_echelon_matrix, #transpose_matrix.
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}$ |
sudo apt-get install gcc gcc -Wall -Werror -O2 -g3 main.c -o EXECUTABLE ./EXECUTABLEThe Makefile in the repository can also be used to compile the code.
make compilemake compile CFLAGS=YOUR_FLAGSmake asanmake cleanNOTE: Be sure to merge the latest from "upstream" before making a pull request!
Each new function must be documented using the following style:
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. 😃
| Back | FazBrowse Home | New Git URL |