{"id":13736661,"url":"https://github.com/planetis-m/manu","last_synced_at":"2025-07-02T13:33:05.744Z","repository":{"id":161973706,"uuid":"192165806","full_name":"planetis-m/manu","owner":"planetis-m","description":"Nim MAtrix NUmeric package","archived":false,"fork":false,"pushed_at":"2024-05-25T12:35:31.000Z","size":486,"stargazers_count":42,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-15T04:32:31.508Z","etag":null,"topics":["decomposition","determinants","linear-algebra","matrices","matrix-decompositions","matrix-functions","nim","nim-library","scientific","simultaneous-linear-equations"],"latest_commit_sha":null,"homepage":null,"language":"Nim","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/planetis-m.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":"2019-06-16T08:05:48.000Z","updated_at":"2024-09-12T13:19:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"b0fb57c8-17d0-4cbc-bf49-6ca5441a37b9","html_url":"https://github.com/planetis-m/manu","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/planetis-m%2Fmanu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/planetis-m%2Fmanu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/planetis-m%2Fmanu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/planetis-m%2Fmanu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/planetis-m","download_url":"https://codeload.github.com/planetis-m/manu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247548793,"owners_count":20956800,"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":["decomposition","determinants","linear-algebra","matrices","matrix-decompositions","matrix-functions","nim","nim-library","scientific","simultaneous-linear-equations"],"created_at":"2024-08-03T03:01:25.970Z","updated_at":"2025-04-06T20:33:17.490Z","avatar_url":"https://github.com/planetis-m.png","language":"Nim","funding_links":[],"categories":["Algorithms"],"sub_categories":["Math"],"readme":"# Manu — Nim Matrix Numeric library\n\nManu is a pure Nim library, no external dependencies to BLAS frameworks.\nSupports constructing and manipulating only real, dense matrices.\nIt started as a port of [JAMA](https://math.nist.gov/javanumerics/jama/)\nlibrary, and is adapted to Nim programming paradigm and specific performace considerations.\n\nWhat is supported:\n\n- Compute solutions of simultaneous linear equations, determinants, inverses and other matrix functions.\n- Generics allow matrices of ``SomeFloat`` only.\n- Arithmetic operators are overloaded to support matrices.\n  * Broadcast scalars, column and row vectors to work with matrices.\n- Destructors, with sink annotations, copies can be avoided in some cases.\n\nAPI [documentation](https://planetis-m.github.io/manu/)\n\n## Examples\n\nIn the examples directory you will find the following:\n\n1. [two layer neural network](https://github.com/planetis-m/manu/blob/master/examples/neural.nim)\n2. [stress state analysis script](https://github.com/planetis-m/manu/blob/master/examples/mohr.nim)\n\nshowcasing what can already be done.\n\n### example2.nim\n\n```nim\n  import manu\n\n  # Solve a linear system A x = b and compute the residual norm, ||b - A x||.\n  let vals = @[@[1.0, 2, 3], @[4.0, 5, 6], @[7.0, 8, 10]]\n  let A = matrix(vals)\n  let b = randMatrix64(3, 1)\n  let x = A.solve(b)\n  let r = A * x - b\n  let rnorm = r.normInf()\n  echo(\"x =\\n\", x)\n  echo(\"residual norm = \", rnorm)\n```\n\nOutput:\n\n```\nx =\n⎡-918.9217543597e-3⎤\n⎢      2.1952979104⎥\n⎣     -1.0796593055⎦\nresidual norm = 1.554312234475219e-15\n```\n\n## Matrix decompositions\n\nFive matrix decompositions are used to compute solutions of simultaneous linear equations,\ndeterminants, inverses and other matrix functions. Theses are:\n\n- Cholesky Decomposition of symmetric, positive definite matrices\n- LU Decomposition (Gaussian elimination) of rectangular matrices\n- QR Decomposition of rectangular matrices\n- Eigenvalue Decomposition of both symmetric and nonsymmetric square matrices\n- Singular Value Decomposition of rectangular matrices\n\n## Broadcasting\n\nIt is implemented with the help of two ``distinct`` types ``RowVector[T]`` and ``ColVector[T]``.\nYou can cast any compatible matrix to these and when performing matrix operations,\nit will be broadcasted to the correct dimensions:\n\n```nim\nvar a = matrix(1, 5, 2.0)\nlet b = ones64(2, 1)\necho ColVector64(b) + RowVector64(a)\necho 2.0 + a # matrix-scalar ops are implicit\n```\n\nResults in:\n\n```\n⎡3  3  3  3  3⎤\n⎣3  3  3  3  3⎦\n⎡4  4  4  4  4⎤\n```\n\nIf the matrices are not broadcastable an ``AssertionDefect`` will be thrown at runtime.\n\nThe correct paradigm of usage is to first initialize a matrix, i.e ``let a = ones64(1, 5)``\nand cast it to ``RowVector64`` where broadcasting is needed: ``RowVector64(a) + zeros64(5, 5)``.\nThis system is designed to be more explicit, and since it is type-checked,\nwork well with ``sink`` optimizations.\n\n## Feature improvements / contributions\n- Add more tests\n- Incorporate usefull additions from [Apache Commons Math](https://github.com/apache/commons-math)\n\n## License\nThis library is distributed under the [MIT license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplanetis-m%2Fmanu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplanetis-m%2Fmanu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplanetis-m%2Fmanu/lists"}