{"id":16237314,"url":"https://github.com/tannerdolby/matrmath","last_synced_at":"2025-04-08T08:45:30.181Z","repository":{"id":57292582,"uuid":"393881007","full_name":"tannerdolby/matrmath","owner":"tannerdolby","description":"A matrix math library capable of performing row-reduction and other common matrix operations.","archived":false,"fork":false,"pushed_at":"2021-08-09T17:22:57.000Z","size":59,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T05:42:29.909Z","etag":null,"topics":["linear-algebra","matrix-library","row-reduction"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/matrmath","language":"JavaScript","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/tannerdolby.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}},"created_at":"2021-08-08T06:41:25.000Z","updated_at":"2021-08-10T04:47:27.000Z","dependencies_parsed_at":"2022-08-27T16:51:04.353Z","dependency_job_id":null,"html_url":"https://github.com/tannerdolby/matrmath","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tannerdolby%2Fmatrmath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tannerdolby%2Fmatrmath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tannerdolby%2Fmatrmath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tannerdolby%2Fmatrmath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tannerdolby","download_url":"https://codeload.github.com/tannerdolby/matrmath/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247808508,"owners_count":20999744,"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":["linear-algebra","matrix-library","row-reduction"],"created_at":"2024-10-10T13:35:14.535Z","updated_at":"2025-04-08T08:45:30.163Z","avatar_url":"https://github.com/tannerdolby.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# matrmath\nA library for performing matrix operations.\n\n## Installation\n\n```js\nnpm install matrmath\n```\n\n## Usage\nUtilize the [functions](https://github.com/tannerdolby/matrmath#config) in this library for performing matrix operations.\n\nFor example, compute the diagonal difference of a square (n x n) matrix:\n\n```js\nconst mtr = require(\"matrmath\");\n\nlet diff = mtr.diagonalDiff([\n    [2, 5, 3],\n    [4, 6, 1],\n    [7, 8, 9]\n]);\n\nconsole.log(diff);\n// |(2+6+9) - (3+6+7)| = |17-16| = 1\n```\n\nOr compute a matrix in reduced row echelon form:\n\n```js\nconst mtr = require(\"matrmath\");\n\nlet reduced = mtr.rowReduce([\n    [5, 8, 2],\n    [3, 5, 3],\n    [6, 4, 9]\n]);\n\nconsole.log(reduced);\n// [ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ]\n```\n\n## Config\n\n### rowReduce(M)\n\nTransform a matrix in-place and return the reduced row-echelon form of a matrix. Row replacement is achieved through [Gaussian Elimination](https://en.wikipedia.org/wiki/Gaussian_elimination#:~:text=In%20mathematics%2C%20Gaussian%20elimination%2C%20also,the%20corresponding%20matrix%20of%20coefficients.).\n\n- `M` - `number[][]` - A 2-dimensional array.\n- `square` - `boolean` - Optional boolean parameter to specify if the matrix is square (ie 3x3, 4x4 etc).\n\n### diagonalDiff(M)\nReturn the diagonal difference of a [square](https://en.wikipedia.org/wiki/Square_matrix). The diagonal difference is the absolute value of the left diagonal minus the right diagonal in a square matrix.\n\n- `M` - `number[][] | number[]` - A 2-dimensional array, or optionally 1D array.\n- `is2D` - `boolean` - Optional boolean parameter to specify if the matrix is 1D instead of 2D.\n- `debug` - `boolean` - Optional boolean parameter to output the `lib` object with items used in computations.\n\n### isSquare(M)\nCheck whether a 2D or 1D matrix is square. That is the number of rows equals the number of columns in a `n x m` layout where n = rows and m = columns and n must equal m.\n\n- `M` - `number[][] | number[]` - A 2D or 1D array, or optionally 1D array.\n- `is2D` - `boolean` - Optional boolean parameter to specify if the matrix is 1D instead of 2D.\n\n### det(M)\nCalculate the [determinant](https://en.wikipedia.org/wiki/Determinant) of a matrix.\n\n- `M` - `number[][]` - A 2-dimensional array.\n\n\n### isIndependent(M)\nCalculate whether a square matrix is [linearly independent](https://en.wikipedia.org/wiki/Linear_independence#:~:text=In%20the%20theory%20of%20vector,to%20the%20definition%20of%20dimension.). If the determinant of a matrix is not equal to 0, its linearly independent.\n\n- `M` - `number[][]` - A 2-dimensional array.\n\n### isDependent(M)\nCalculate whether a square matrix is linearly dependent. Meaning its determinant equals 0.\n\n- `M` - `number[][]` - A 2-dimensional array.\n\n## Tests\n```js\nnpm run test\n```\n\n\n## Todo\n- [ ] Add a utility for transforming points in R^n to R^n. In other words, transform a set of points in some space (R2) to points in (R3). Have a initial input matrix and a transformation matrix as parameters to output the points after being multiplied by the transformation matrix.\n\n\n## Resources\n- [Reduced Row Echelon Form (JavaScript)](https://rosettacode.org/wiki/Reduced_row_echelon_form#JavaScript) - code example by rosettacode.\n- [Determinant - JavaScript](https://rosettacode.org/wiki/Determinant_and_permanent#JavaScript) - code example by rosettacode.\n- [substrack/rref](https://github.com/substack/rref) - library for row reducing based on rosettacode example.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftannerdolby%2Fmatrmath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftannerdolby%2Fmatrmath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftannerdolby%2Fmatrmath/lists"}