{"id":26414909,"url":"https://github.com/alessandroconti11/matrix_library","last_synced_at":"2025-06-22T19:05:49.263Z","repository":{"id":250541558,"uuid":"824266741","full_name":"AlessandroConti11/Matrix_Library","owner":"AlessandroConti11","description":"Library that contains all useful functions for handling matrices and their operations. ","archived":false,"fork":false,"pushed_at":"2024-09-02T07:49:44.000Z","size":135,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T00:11:25.320Z","etag":null,"topics":["c","cofactor","determinant","inverse-matrix","matrix","matrix-operation","matrix-types","minor","pivot","rank","row-echelon-matrix","transpose-matrix"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlessandroConti11.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-04T18:11:14.000Z","updated_at":"2025-02-17T15:53:18.000Z","dependencies_parsed_at":"2024-08-08T15:18:23.294Z","dependency_job_id":"e7f729e7-d0cb-4e0c-9294-45cff52e7dbb","html_url":"https://github.com/AlessandroConti11/Matrix_Library","commit_stats":null,"previous_names":["alessandroconti11/matrix_library"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/AlessandroConti11/Matrix_Library","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlessandroConti11%2FMatrix_Library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlessandroConti11%2FMatrix_Library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlessandroConti11%2FMatrix_Library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlessandroConti11%2FMatrix_Library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlessandroConti11","download_url":"https://codeload.github.com/AlessandroConti11/Matrix_Library/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlessandroConti11%2FMatrix_Library/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261348267,"owners_count":23145304,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","cofactor","determinant","inverse-matrix","matrix","matrix-operation","matrix-types","minor","pivot","rank","row-echelon-matrix","transpose-matrix"],"created_at":"2025-03-18T00:11:04.484Z","updated_at":"2025-06-22T19:05:44.249Z","avatar_url":"https://github.com/AlessandroConti11.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Matrix_Library\n\n\nAuthor: Alessandro Conti - [AlessandroConti11](https://github.com/AlessandroConti11)\n\nLicense: [MIT license](LICENSE).\n\n\nTags: `#C`, `#cofactor`, `#determinant`, `#inverse_matrix`, `#matrix`, `#matrix_operation`, `#matrix_type`, `#minor`, `#pivot`, `#rank`, `#row_echelon_matrix`, `#transpose_matrix`.\n\n\n## Specification\n\nThe project aims to create a library that contains all useful functions for handling matrices and their operations.\n\u003cbr\u003e\n\u003cbr\u003e\n*For all functions that require a result: you must provide the requested data structure (you can also use the one present as input).*\n\n| **Operation**                                      | **Function**                                                            | **Description**                                                                                                                                   | **Order of the Matrices**                                                                                | **Example of Mathematical Representation**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |\n|----------------------------------------------------|-------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| create a matrix                                    | __matrix *createMatrix(int n, int m);__                                 | create an empty matrix                                                                                                                            | $`\\begin{align} \u0026{[A]}:\\;n\\;x\\;m \\end{align}`$                                                           | $`\\begin{align} \u0026{[A]}=\\begin{bmatrix} a_{(0;0)} \u0026 a_{(0;1)} \u0026 a_{(0;2)} \u0026 \\cdots \u0026 a_{(0;m-1)} \\\\\\ a_{(1;0)} \u0026 a_{(1;1)} \u0026 a_{(1;2)} \u0026 \\cdots \u0026 a_{(1;m-1)} \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ a_{(n-1;0)} \u0026 a_{(n-1;1)} \u0026 a_{(n-1;2)} \u0026 \\cdots \u0026 a_{(n-1;m-1)}  \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                                         |\n| create identity matrix                             | __matrix *createIdentityMatrix(int n);__                                | create an identity matrix                                                                                                                         | $`\\begin{align} \u0026{[Id]}:\\;n\\;x\\;n \\end{align}`$                                                          | $`\\begin{align} \u0026{[Id]}=\\begin{bmatrix} 1 \u0026 0 \u0026 0 \u0026 \\cdots \u0026 0 \\\\\\ 0 \u0026 1 \u0026 0 \u0026 \\cdots \u0026 0 \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ 0 \u0026 0 \u0026 0 \u0026 \\cdots \u0026 1  \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |\n| create a null matrix                               | __matrix *createNullMatrix(int n, int m);__                             | create a null matrix                                                                                                                              | $`\\begin{align} \u0026{[0]}:\\;n\\;x\\;m \\end{align}`$                                                           | $`\\begin{align} \u0026{[0]}=\\begin{bmatrix} 0 \u0026 0 \u0026 0 \u0026 \\cdots \u0026 0 \\\\\\ 0 \u0026 0 \u0026 0 \u0026 \\cdots \u0026 0 \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ 0 \u0026 0 \u0026 0 \u0026 \\cdots \u0026 0  \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |\n| initialize a matrix                                | __void initializeMatrix(matrix *a, ...);__                              | initialize an empty matrix by filling it by rows                                                                                                  | $`\\begin{align} \u0026{[A]}:\\;n\\;x\\;m \\end{align}`$                                                           |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |\n| copy a matrix                                      | __void copyMatrix(matrix *a, matrix *b);__                              | copy a matrix to another                                                                                                                          | $`\\begin{align} \u0026{{[A]}:\\;n\\;x\\;m} \\\\ \u0026{{[B]}:\\;p\\;x\\;q} \\end{align}`$                                   |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |\n| delete a matrix                                    | __void deleteMatrix(matrix *a);__                                       | delete a given matrix                                                                                                                             | $`\\begin{align} \u0026{[A]}:\\;n\\;x\\;m \\end{align}`$                                                           |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |\n| print a matrix                                     | __void printMatrix(matrix *a);__                                        | print a given matrix                                                                                                                              | $`\\begin{align} \u0026{[A]}:\\;n\\;x\\;m \\end{align}`$                                                           |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |\n| 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} \u0026{[Id]}:\\;n\\;x\\;n \\end{align}`$                                                          | $`\\begin{align} \u0026{[Id]}=\\begin{bmatrix} 1 \u0026 0 \u0026 0 \u0026 \\cdots \u0026 0 \\\\\\ 0 \u0026 1 \u0026 0 \u0026 \\cdots \u0026 0 \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ 0 \u0026 0 \u0026 0 \u0026 \\cdots \u0026 1  \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |\n| check if a matrix is a null matrix                 | __int isNullMatrix(matrix *a);__                                        | check whether the all matrix elements are equal to 0                                                                                              | $`\\begin{align} \u0026{[0]}:\\;n\\;x\\;m \\end{align}`$                                                           | $`\\begin{align} \u0026{[0]}=\\begin{bmatrix} 0 \u0026 0 \u0026 0 \u0026 \\cdots \u0026 0 \\\\\\ 0 \u0026 0 \u0026 0 \u0026 \\cdots \u0026 0 \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ 0 \u0026 0 \u0026 0 \u0026 \\cdots \u0026 0  \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |\n| 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} \u0026{[D]}:\\;n\\;x\\;n \\end{align}`$                                                           | $`\\begin{align} \u0026{[D]}=\\begin{bmatrix} a_{(0;0)} \u0026 0 \u0026 0 \u0026 \\cdots \u0026 0 \\\\\\ 0 \u0026 a_{(1;1)} \u0026 0 \u0026 \\cdots \u0026 0 \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ 0 \u0026 0 \u0026 0 \u0026 \\cdots \u0026 a_{(n-1;n-1)}  \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n| 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} \u0026{[AD]}:\\;n\\;x\\;n \\end{align}`$                                                          | $`\\begin{align} \u0026{[AD]}=\\begin{bmatrix} 0 \u0026 \\cdots \u0026 0 \u0026 0 \u0026 a_{(0;n-1)} \\\\\\ 0 \u0026 \\cdots \u0026 0 \u0026 a_{(0;n-2)} \u0026 0 \\\\\\ \\vdots \u0026 \\ddots \u0026 \\vdots \u0026 \\vdots \u0026 \\vdots \\\\\\ a_{(n-1;0)} \u0026 \\cdots \u0026 0 \u0026 0 \u0026 0  \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |\n| 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} \u0026{[UD]}:\\;n\\;x\\;n \\end{align}`$                                                          | $`\\begin{align} \u0026{[UD]}=\\begin{bmatrix} a_{(0;0)} \u0026 a_{(0;1)} \u0026 a_{(0;1)} \u0026 \\cdots \u0026 a_{(0;n-1)} \\\\\\ 0 \u0026 a_{(1;1)} \u0026 a_{(1;2)} \u0026 \\cdots \u0026 a_{(1;n-1)} \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ 0 \u0026 0 \u0026 0 \u0026 \\cdots \u0026 a_{(n-1;n-1)}  \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                                                                              |\n| 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} \u0026{[LD]}:\\;n\\;x\\;n \\end{align}`$                                                          | $`\\begin{align} \u0026{[LD]}=\\begin{bmatrix} a_{(0;0)} \u0026 0 \u0026 0 \u0026 \\cdots \u0026 0 \\\\\\ a_{(1;0)} \u0026 a_{(1;1)} \u0026 0 \u0026 \\cdots \u0026 0 \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ a_{(n-1;0)} \u0026 a_{(n-1;1)} \u0026 a_{(n-1;2)} \u0026 \\cdots \u0026 a_{(n-1;n-1)})  \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                                                                                   |\n| 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} \u0026{[S]}:\\;n\\;x\\;n \\end{align}`$                                                           | $`\\begin{align} \u0026{[S]}=\\begin{bmatrix} a_{(0;0)} \u0026 a_{(0;1)} \u0026 a_{(0;2)} \u0026 \\cdots \u0026 a_{(0;n-1)} \\\\\\ a_{(0;1)} \u0026 a_{(1;1)} \u0026 a_{(1;2)} \u0026 \\cdots \u0026 a_{(1;n-1)} \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ a_{(0;n-1)} \u0026 a_{(1;n-1)} \u0026 a_{(2;n-1)} \u0026 \\cdots \u0026 a_{(n-1;n-1)}  \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                                         |\n| 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} \u0026{[AS]}:\\;n\\;x\\;n \\end{align}`$                                                          | $`\\begin{align} \u0026{[AS]}=\\begin{bmatrix} a_{(0;0)} \u0026 a_{(0;1)} \u0026 a_{(0;2)} \u0026 \\cdots \u0026 a_{(0;n-1)} \\\\\\ -a_{(0;1)} \u0026 a_{(1;1)} \u0026 a_{(1;2)} \u0026 \\cdots \u0026 a_{(1;n-1)} \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ -a_{(0;n-1)} \u0026 -a_{(1;n-1)} \u0026 -a_{(2;n-1)} \u0026 \\cdots \u0026 a_{(n-1;n-1)}  \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                                    |\n| check if a matrix is invertible                    | __int isInvertibleMatrix(matrix *a);__                                  | check whether the determinant is different from 0                                                                                                 | $`\\begin{align} \u0026{[A]}:\\;n\\;x\\;n \\end{align}`$                                                           |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |\n| 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} \u0026{[RE]}:\\;n\\;x\\;m \\end{align}`$                                                          | $`\\begin{align} \u0026{[RE]}=\\begin{bmatrix} a_{(0;0)} \u0026 a_{(0;1)} \u0026 a_{(0;2)} \u0026 \\cdots \u0026 a_{(0;m-1)} \\\\\\ 0 \u0026 0 \u0026 a_{(1;2)} \u0026 \\cdots \u0026 a_{(1;m-1)} \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ 0 \u0026 0 \u0026 0 \u0026 \\cdots \u0026 a_{(n-1;m-1)}  \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                                                                                      |\n| 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} \u0026{[H]}:\\;n\\;x\\;n \\end{align}`$                                                           | $`\\begin{align} \u0026{[H]}=\\begin{bmatrix} a_0 \u0026 a_1 \u0026 a_2 \u0026 \\cdots \u0026 a_{n-1} \\\\\\ a_1 \u0026 a_2 \u0026 a_3 \u0026 \\cdots \u0026 a_n \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ a_{n-1} \u0026 a_n \u0026 a_{n+1} \u0026 \\cdots \u0026 a_{n+n-2}  \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |\n| 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} \u0026{[T]}:\\;n\\;x\\;n \\end{align}`$                                                           | $`\\begin{align} \u0026{[T]}=\\begin{bmatrix} a_0 \u0026 a_{-1} \u0026 a_{-2} \u0026 \\cdots \u0026 a_{-n} \\\\\\ a_1 \u0026 a_0 \u0026 a_{-1} \u0026 \\cdots \u0026 a_{-n+1} \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ a_{n-2} \u0026 a_{n-3} \u0026 a_{n-4} \u0026 \\cdots \u0026 a_0  \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |\n| transpose a matrix                                 | __void transposingMatrix(matrix *a, matrix *trans);__                   | the transposed matrix is given by the elements (j, i)                                                                                             | $`\\begin{align} \u0026{[A]}:\\;n\\;x\\;m \\\\ \u0026{[A]^T}:\\;m\\;x\\;n \\end{align}`$                                     | $`\\begin{align} \u0026{[A]}^T=\\begin{bmatrix} a_{(0;0)} \u0026 a_{(1;0)} \u0026 a_{(2;0)} \u0026 \\cdots \u0026 a_{(n-1;0)} \\\\\\ a_{(0;1)} \u0026 a_{(1;1)} \u0026 a_{(2;1)} \u0026 \\cdots \u0026 a_{(n-1;1)} \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ a_{(0;m-1)} \u0026 a_{(1;m-1)} \u0026 a_{(2;m-1)} \u0026 \\cdots \u0026 a_{(n-1;m-1)}  \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                                       |\n| invert a matrix                                    | __void inverseMatrix(matrix *a, matrix *inv);__                         | inverse the matrix using the method of cofactors                                                                                                  | $`\\begin{align} \u0026{[A]}:\\;n\\;x\\;n \\\\ \u0026{[A]^{-1}}:\\;n\\;x\\;n \\end{align}`$                                  | $`\\begin{align} \u0026{[A]}^{-1}={\\frac{1}{det(A)}}{\\begin{bmatrix} Cof(0;0) \u0026 Cof(0;1) \u0026 Cof(0;2) \u0026 \\cdots \u0026 Cof(0;n-1) \\\\\\ Cof(1;0) \u0026 Cof(1;1) \u0026 Cof(1;2) \u0026 \\cdots \u0026 Cof(1;n-1) \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ Cof(n-1;0) \u0026 Cof(n-1;1) \u0026 Cof(n-1;2) \u0026 \\cdots \u0026 Cof(n-1;n-1)  \\end{bmatrix}}^T \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                          |\n| transform a matrix to a row-echelon matrix         | __void rowEchelonMatrix(matrix *a, matrix *step);__                     | transform the matrix using the Gaussian elimination method                                                                                        | $`\\begin{align} \u0026{[A]}:\\;n\\;x\\;m \\\\ \u0026{[A_{RE}]}:\\;n\\;x\\;m \\end{align}`$                                  | $`\\begin{align} \u0026{[A_{RE}]}=\\begin{bmatrix} {a'}_{(0;0)} \u0026 {a'}_{(0;1)} \u0026 {a'}_{(0;2)} \u0026 \\cdots \u0026 {a'}_{(0;m-1)} \\\\\\ 0 \u0026 0 \u0026 {a'}_{(1;2)} \u0026 \\cdots \u0026 {a'}_{(1;m-1)} \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ 0 \u0026 0 \u0026 0 \u0026 \\cdots \u0026 {a'}_{(n-1;m-1)}  \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                                                             |\n| compute the absolute matrix                        | __void absMatrix(matrix *a, matrix *abs);__                             | compute the absolute value for each matrix element                                                                                                | $`\\begin{align} \u0026{[A]}:\\;n\\;x\\;m \\\\ \u0026{[A_{ABS}]}:\\;n\\;x\\;m \\end{align}`$                                 | $`\\begin{align} \u0026{[A_{ABS}]}=\\begin{bmatrix} \\left\\lvert a_{(0;0)} \\right\\rvert \u0026 \\left\\lvert a_{(0;1)} \\right\\rvert \u0026 \\left\\lvert a_{(0;2)} \\right\\rvert \u0026 \\cdots \u0026 \\left\\lvert a_{(0;m-1)} \\right\\rvert \\\\\\ \\left\\lvert a_{(1;0)} \\right\\rvert \u0026 \\left\\lvert a_{(1;1)} \\right\\rvert \u0026 \\left\\lvert a_{(1;2)} \\right\\rvert \u0026 \\cdots \u0026 \\left\\lvert a_{(1;m-1)} \\right\\rvert \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ \\left\\lvert a_{(n-1;0)} \\right\\rvert \u0026 \\left\\lvert a_{(n-1;1)} \\right\\rvert \u0026 \\left\\lvert a_{(n-1;2)} \\right\\rvert \u0026 \\cdots \u0026 \\left\\lvert a_{(n-1;m-1)} \\right\\rvert  \\end{bmatrix} \\end{align}`$                                                                                       |\n| 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} \u0026{[A]}:\\;n\\;x\\;n \\end{align}`$                                                           | $`\\begin{align} \u0026{Min_{(0;0)}}={Det \\left(\\begin{bmatrix} a_{(1;1)} \u0026 a_{(1;2)} \u0026 a_{(1;3)} \u0026 \\cdots \u0026 a_{(1;n-1)} \\\\\\ a_{(2;1)} \u0026 a_{(2;1)} \u0026 a_{(2;3)} \u0026 \\cdots \u0026 a_{(2;n-1)} \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ a_{(n-1;1)} \u0026 a_{(n-1;2)} \u0026 a_{(n-1;3)} \u0026 \\cdots \u0026 a_{(n-1;n-1)}  \\end{bmatrix}\\right)} \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                              |\n| 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} \u0026{[A]}:\\;n\\;x\\;n \\end{align}`$                                                           | $`\\begin{align} \u0026{Cof_{(i;j)}}={(-1)}^{(i+j)} \\cdot \\left\\lvert Min_{(i;j)} \\right\\rvert \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |\n| compute the determinant of a matrix                | __double determinantMatrix(matrix *a);__                                | compute the determinant of the matrix                                                                                                             | $`\\begin{align} \u0026{[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}`$                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |\n| compute the rank of a matrix                       | __int rankMatrix(matrix *a);__                                          | compute the rank of the matrix using the minor method                                                                                             | $`\\begin{align} \u0026{[A]}:\\;n\\;x\\;m \\end{align}`$                                                           | $`\\begin{align}\\begin{cases} \u0026{matrix\\;order, \\quad if\\;Det([A])\\neq 0} \\\\ \\; \\\\ \u0026{order\\;of\\;the\\;maximum\\;possible\\;non\\;zero\\;minor\\;of\\;the\\;matrix, \\quad if\\;Det([A])=0} \\end{cases} \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |\n| compute the sum between two matrices               | __void sumMatrix(matrix *a, matrix *b, matrix *res);__                  | compute the sum between two given matrices                                                                                                        | $`\\begin{align} \u0026{[A]}:\\;n\\;x\\;m \\\\ \u0026{[B]}:\\;n\\;x\\;m \\\\ \u0026{[A+B]}:\\;n\\;x\\;m \\end{align}`$                 | $`\\begin{align} \u0026{[A+B]}=\\begin{bmatrix} {a_{(0;0)}+b_{(0;0)}} \u0026 {a_{(0;1)}+b_{(0;1)}} \u0026 {a_{(0;2)}+b_{(0;2)}} \u0026 \\cdots \u0026 {a_{(0;m-1)}+b_{(0;m-1)}} \\\\\\ {a_{(1;0)}+b_{(1;0)}} \u0026 {a_{(1;1)}+b_{(1;1)}} \u0026 {a_{(1;2)}+b_{(1;2)}} \u0026 \\cdots \u0026 {a_{(1;m-1)}+b_{(1;m-1)}} \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ {a_{(n-1;0)}+b_{(n-1;0)}} \u0026 {a_{(n-1;1)}+b_{(n-1;1)}} \u0026 {a_{(n-1;2)}+b_{(n-1;2)}} \u0026 \\cdots \u0026 {a_{(n-1;m-1)}+b_{(n-1;m-1)}}  \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                         |\n| compute the difference between two matrices        | __void subMatrix(matrix *a, matrix *b, matrix *res);__                  | compute the difference between two given matrices                                                                                                 | $`\\begin{align} \u0026{[A]}:\\;n\\;x\\;m \\\\ \u0026{[B]}:\\;n\\;x\\;m \\\\ \u0026{[A-B]}:\\;n\\;x\\;m \\end{align}`$                 | $`\\begin{align} \u0026{[A-B]}=\\begin{bmatrix} {a_{(0;0)}-b_{(0;0)}} \u0026 {a_{(0;1)}-b_{(0;1)}} \u0026 {a_{(0;2)}-b_{(0;2)}} \u0026 \\cdots \u0026 {a_{(0;m-1)}-b_{(0;m-1)}} \\\\\\ {a_{(1;0)}-b_{(1;0)}} \u0026 {a_{(1;1)}-b_{(1;1)}} \u0026 {a_{(1;2)}-b_{(1;2)}} \u0026 \\cdots \u0026 {a_{(1;m-1)}-b_{(1;m-1)}} \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ {a_{(n-1;0)}-b_{(n-1;0)}} \u0026 {a_{(n-1;1)}-b_{(n-1;1)}} \u0026 {a_{(n-1;2)}-b_{(n-1;2)}} \u0026 \\cdots \u0026 {a_{(n-1;m-1)}-b_{(n-1;m-1)}}  \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                         |\n| compute the scalar product of a matrix             | __void scalarProductMatrix(double scalar, matrix *a, matrix *res);__    | compute the scalar product of the matrix                                                                                                          | $`\\begin{align} \u0026{[A]}:\\;n\\;x\\;m \\\\ \u0026{[k \\cdot A]}:\\;n\\;x\\;m \\end{align}`$                               | $`\\begin{align} \u0026{[k \\cdot A]}=\\begin{bmatrix} {k \\cdot a_{(0;0)}} \u0026 {k \\cdot a_{(0;1)}} \u0026 {k \\cdot a_{(0;2)}} \u0026 \\cdots \u0026 {k \\cdot a_{(0;m-1)}} \\\\\\ {k \\cdot a_{(1;0)}} \u0026 {k \\cdot a_{(1;1)}} \u0026 {k \\cdot a_{(1;2)}} \u0026 \\cdots \u0026 {k \\cdot a_{(1;m-1)}} \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ {k \\cdot a_{(n-1;0)}} \u0026 {k \\cdot a_{(n-1;1)}} \u0026 {k \\cdot a_{(n-1;2)}} \u0026 \\cdots \u0026 {k \\cdot a_{(n-1;m-1)}}  \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                                                         |\n| compute the product between two matrices           | __void productMatrix(matrix *a, matrix *b, matrix *res);__              | compute the product between two given matrices                                                                                                    | $`\\begin{align} \u0026{[A]}:\\;n\\;x\\;p \\\\ \u0026{[B]}:\\;p\\;x\\;m \\\\ \u0026{[A \\cdot B]}:\\;n\\;x\\;m \\end{align}`$           | $`\\begin{align} \u0026{[A \\cdot B]}=\\begin{bmatrix} {\\sum_{k=1}^n{a_{(0;k)} \\cdot b_{(k;0)}}} \u0026 {\\sum_{k=1}^n{a_{(0;k)} \\cdot b_{(k;1)}}} \u0026 {\\sum_{k=1}^n{a_{(0;k)} \\cdot b_{(k;2)}}} \u0026 \\cdots \u0026 {\\sum_{k=1}^n{a_{(0;k)} \\cdot b_{(k;m-1)}}} \\\\\\ {\\sum_{k=1}^n{a_{(1;k)} \\cdot b_{(k;0)}}} \u0026 {\\sum_{k=1}^n{a_{(1;k)} \\cdot b_{(k;1)}}} \u0026 {\\sum_{k=1}^n{a_{(1;k)} \\cdot b_{(k;2)}}} \u0026 \\cdots \u0026 {\\sum_{k=1}^n{a_{(1;k)} \\cdot b_{(k;m-1)}}} \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ {\\sum_{k=1}^n{a_{(n-1;k)} \\cdot b_{(k;0)}}} \u0026 {\\sum_{k=1}^n{a_{(n-1;k)} \\cdot b_{(k;1)}}} \u0026 {\\sum_{k=1}^n{a_{(n-1;k)} \\cdot b_{(k;2)}}} \u0026 \\cdots \u0026 {\\sum_{k=1}^n{a_{(n-1;k)} \\cdot b_{(k;m-1)}}}  \\end{bmatrix} \\end{align}`$ |\n| compute the power elevation of a matrix            | __void powerMatrix(matrix *a, int k, matrix *res);__                    | compute the power elevation of the matrix                                                                                                         | $`\\begin{align} \u0026{[A]}:\\;n\\;x\\;n \\\\ \u0026{[A]^k}:\\;n\\;x\\;n \\end{align}`$                                     | $`\\begin{align} \u0026{[A]^k}=\\prod^k{\\begin{bmatrix} a_{(0;0)} \u0026 a_{(0;1)} \u0026 a_{(0;2)} \u0026 \\cdots \u0026 a_{(0;n-1)} \\\\\\ a_{(1;0)} \u0026 a_{(1;1)} \u0026 a_{(1;2)} \u0026 \\cdots \u0026 a_{(1;n-1)} \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ a_{(n-1;0)} \u0026 a_{(n-1;1)} \u0026 a_{(n-1;2)} \u0026 \\cdots \u0026 a_{(n-1;n-1)}  \\end{bmatrix}} \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                              |\n| 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} \u0026{[A]}:\\;n\\;x\\;m \\\\ \u0026{[B]}:\\;p\\;x\\;q \\\\ \u0026{[A \\oplus B]}:\\;(n+p)\\;x\\;(m+q) \\end{align}`$  | $`\\begin{align} \u0026{[A \\oplus B]}=\\begin{bmatrix} [A] \u0026 [0] \\\\\\ [0] \u0026 [B] \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |\n| compute the Kronecker product between two matrices | __void kroneckerProductMatrix(matrix *a, matrix *b, matrix *res);__     | compute the Kronecker product between two matrices                                                                                                | $`\\begin{align} \u0026{[A]}:\\;n\\;x\\;m \\\\ \u0026{[B]}:\\;p\\;x\\;q \\\\ \u0026{[A \\otimes B]}:\\;(n \\cdot p)\\;x\\;(m \\cdot q) \\end{align}`$ | $`\\begin{align} \u0026{[A \\otimes B]}=\\begin{bmatrix} {a_{(0;0)} \\cdot [B]} \u0026 {a_{(0;1)} \\cdot [B]} \u0026 {a_{(0;2)} \\cdot [B]} \u0026 \\cdots \u0026 {a_{(0;m-1)} \\cdot [B]} \\\\\\ {a_{(1;0)} \\cdot [B]} \u0026 {a_{(1;1)} \\cdot [B]} \u0026 {a_{(1;2)} \\cdot [B]} \u0026 \\cdots \u0026 {a_{(1;m-1)} \\cdot [B]} \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ {a_{(n-1;0)} \\cdot [B]} \u0026 {a_{(n-1;1)} \\cdot [B]} \u0026 {a_{(n-1;2)} \\cdot [B]} \u0026 \\cdots \u0026 {a_{(n-1;m-1)} \\cdot [B]}  \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                               |\n| swap two rows of a matrix                          | __void swapRowMatrix(matrix *a, int row1, int row2, matrix *swap);__    | swap two rows of given matrix                                                                                                                     | $`\\begin{align} \u0026{[A]}:\\;n\\;x\\;m \\\\ \u0026{[SR_{(i;j)}]}:\\;n\\;x\\;m \\end{align}`$                              | $`\\begin{align} \u0026{[SR_{(0;n)}]}=\\begin{bmatrix} a_{(n-1;0)} \u0026 a_{(n-1;1)} \u0026 a_{(n-1;2)} \u0026 \\cdots \u0026 a_{(n-1;m-1)} \\\\\\ a_{(1;0)} \u0026 a_{(1;1)} \u0026 a_{(1;2)} \u0026 \\cdots \u0026 a_{(1;m-1)} \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ a_{(0;0)} \u0026 a_{(0;1)} \u0026 a_{(0;2)} \u0026 \\cdots \u0026 a_{(0;m-1)}  \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                                |\n| swap two column of a matrix                        | __void swapColumnMatrix(matrix *a, int col1, int col2, matrix *swap);__ | swap two column of given matrix                                                                                                                   | $`\\begin{align} \u0026{[A]}:\\;n\\;x\\;m \\\\ \u0026{[SC_{(i;j)}]}:\\;n\\;x\\;m \\end{align}`$                              | $`\\begin{align} \u0026{[SC_{(0;n)}]}=\\begin{bmatrix} a_{(0;n-1)} \u0026 a_{(0;1)} \u0026 a_{(0;2)} \u0026 \\cdots \u0026 a_{(0;0)} \\\\\\ a_{(1;n-1)} \u0026 a_{(1;1)} \u0026 a_{(1;2)} \u0026 \\cdots \u0026 a_{(1;0)} \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ a_{(n-1;n-1)} \u0026 a_{(n-1;1)} \u0026 a_{(n-1;2)} \u0026 \\cdots \u0026 a_{(n-1;0)}  \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                                |\n| 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} \u0026{[A]}:\\;n\\;x\\;m \\end{align}`$                                                           |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |\n| 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} \u0026{[A]}:\\;n\\;x\\;m \\end{align}`$                                                           |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |\n| 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} \u0026{[A]}:\\;n\\;x\\;m \\end{align}`$                                                           | $`\\begin{align}\\overrightarrow{Diagonal}=\\begin{bmatrix} a_{(0;0)} \u0026 a_{(1;1)} \u0026 \\cdots \u0026 a_{(n-1;n-1)} \\end{bmatrix} \\end{align}`$                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |\n| 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} \u0026{[A]}:\\;n\\;x\\;m \\end{align}`$                                                           |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |\n| 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} \u0026{[A]}:\\;n\\;x\\;n \\\\ \u0026{[L]}:\\;n\\;x\\;n \\\\ \u0026{[U]}:\\;n\\;x\\;n \\end{align}`$                   | $`\\begin{align} \u0026{[A]=[L] \\cdot [U]} \\\\ \u0026{\\begin{cases} \u0026{{[L]}={\\begin{bmatrix} 1 \u0026 0 \u0026 0 \u0026 \\cdots \u0026 0 \\\\\\ l_{(1;0)} \u0026 1 \u0026 0 \u0026 \\cdots \u0026 0 \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ l_{(n-1;0)} \u0026 l_{(n-1;1)} \u0026 l_{(n-1;2)} \u0026 \\cdots \u0026 l_{(n-1;n-1)} \\end{bmatrix}}} \\\\ \\; \\\\ \u0026{{[U]}={\\begin{bmatrix} u_{(0;0)} \u0026 u_{(0;1)} \u0026 u_{(0;2)} \u0026 \\cdots \u0026 u_{(0;n-1)} \\\\\\ 0 \u0026 u_{(1;1)} \u0026 u_{(1;2)} \u0026 \\cdots \u0026 u_{1;n-1} \\\\\\ \\vdots \u0026 \\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \\\\\\ 0 \u0026 0 \u0026 0 \u0026 \\cdots \u0026 u_{(n-1;n-1)} \\end{bmatrix}}} \\end{cases}} \\end{align}`$                                                                                                                                                         |\n\n## How to run\n\n0. install gcc\n    ```bash\n    sudo apt-get install gcc \n    ```\n1. compile the project\n    ```bash\n    gcc -Wall -Werror -O2 -g3 main.c -o EXECUTABLE \n    ```\n2. run the project\n    ```bash\n    ./EXECUTABLE\n    ```\n\n\n\u003cbr\u003e\n\nThe Makefile in the repository can also be used to compile the code.\n- this option allows you to compile with the following tags: *-Wall -Werror -O2 -g3*\n   ```bash\n   make compile\n   ```\n- if you want to specify different tags, you can set them\n   ```bash\n   make compile CFLAGS=YOUR_FLAGS\n   ```\n- if you want to use Address SANitizer\n   ```bash\n   make asan\n   ```\n- if you want to delete some file - default is the executable file\n   ```bash\n   make clean\n   ```\n\n\n## Contribute\n\n- If you find a security vulnerability, do NOT open an issue. Email [Alessandro Conti](mailto:ale.conti.1101@gmail.com) instead.\n- If you find a bug or error or want to add some other function that is not implemented yet\n  1. **FORK** the repo\n  2. **CLONE** the project to your own machine\n  3. **COMMIT** to your own branch\n  4. **PUSH** your work back up to your fork\n  5. submit a **PULL REQUEST** so that I can review your changes\n  \u003e NOTE: Be sure to merge the latest from \"upstream\" before making a pull request!\n \n### Code Style\n\nEach new function must be documented using the following style:\n- *Short function description*: A brief description explaining what the function does.\n- *@details*: A detailed section describing how the function works, explaining the algorithms and logic used.\n- *@warning*: A section listing all the assumptions made by the function, such as the preconditions that the parameters must fulfil.\n- *Blank line*: Add a blank line to separate the documentation sections.\n- *@param*: A list of the parameters required by the function, each accompanied by a brief description of its role and type.\n- *@return*: A description of what the function returns, including the data type.\n\nWithin the function, *each variable* must be commented out to explain its purpose. \nIn general, any additional comments that might improve understanding of the code are welcome. 😃\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falessandroconti11%2Fmatrix_library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falessandroconti11%2Fmatrix_library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falessandroconti11%2Fmatrix_library/lists"}