{"id":14992104,"url":"https://github.com/elsuizo/static-math","last_synced_at":"2025-09-25T14:30:53.378Z","repository":{"id":57668563,"uuid":"268367607","full_name":"elsuizo/static-math","owner":"elsuizo","description":"Safe and fast mathematical operations with static arrays in the Rust programming language","archived":false,"fork":false,"pushed_at":"2022-03-17T03:04:34.000Z","size":1102,"stargazers_count":40,"open_issues_count":5,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-12-15T17:44:31.473Z","etag":null,"topics":["determinant","dual-quaternion","euler-angles","linear-algebra","matrix","matrix-calculations","matrix-computations","matrix-inverse","qr-decomposition","quaternions","rust","rust-programming-language"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elsuizo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-31T21:31:20.000Z","updated_at":"2024-06-27T12:30:27.000Z","dependencies_parsed_at":"2022-08-27T01:41:04.489Z","dependency_job_id":null,"html_url":"https://github.com/elsuizo/static-math","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/elsuizo%2Fstatic-math","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elsuizo%2Fstatic-math/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elsuizo%2Fstatic-math/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elsuizo%2Fstatic-math/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elsuizo","download_url":"https://codeload.github.com/elsuizo/static-math/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234178975,"owners_count":18791840,"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":["determinant","dual-quaternion","euler-angles","linear-algebra","matrix","matrix-calculations","matrix-computations","matrix-inverse","qr-decomposition","quaternions","rust","rust-programming-language"],"created_at":"2024-09-24T15:00:44.230Z","updated_at":"2025-09-25T14:30:48.055Z","avatar_url":"https://github.com/elsuizo.png","language":"Rust","funding_links":[],"categories":["Scientific Computation"],"sub_categories":[],"readme":"![MIT](https://img.shields.io/badge/license-MIT-blue.svg)\n[![Documentation](https://docs.rs/static-math/badge.svg)](https://docs.rs/static-math)\n[![crates.io](https://img.shields.io/crates/v/static-math.svg)](https://crates.io/crates/static-math)\n\n# Static Math in Rust programming language\n\n\"*Simple things should be simple, complex things should be possible*\" Alan Kay.\n\n- This crate take advantage of the static arrays in Rust for fast operations in\nstack memory.\n\n- We use a tuple to indexing elements: `m[(i, j)]` allowing nice interface with the `match` feature of Rust\n\n- You could index the rows of the matrix with simply: `m[i]`\n\n- No `unsafe` code :ballot_box_with_check:\n\n- Could be optimize more with the use of SIMD\n\n- This crate could be used in an `no-std` environment.\n\n   by enabling the feature `no-std`, for example in your `Cargo.toml`:\n\n   ```toml\n   [dependencies.static-math]\n   default-features = false\n   version = \"0.2.0\"\n   features = [\"no-std\"]\n   ```\n\n- You can visualize the matrices\n\n```text\ninverse:\n|-0.54    0.58    0.67    -0.08   -0.17    -1.18|\n|2.16     -1.53   -2.44   0.44    0.32      3.77|\n|0.21     -0.42   -0.39   0.15    0.20      0.62|\n|0.70     -0.24   -0.53   0.20    -0.21     0.73|\n|0.85     -0.47   -0.83   0.11    0.11      1.20|\n|-3.91    2.47    4.17    -0.87   -0.31    -6.08|\n```\n\n- The determinant of the matrices are evaluated \"in-place\" without loops and code\nbifurcations\n\n- The use cases can be: Robotics, Game programming, Simulations ...etc.\n\nThe matrix types `Mnn` (where `n=2..6`) implements the Methods from the\n`LinearAlgebra` trait:\n\n - `det()`: Determinant of the matrix\n - `inverse()`: Inverse of the matrix\n - `qr()`: QR decomposition of the matrix\n - `norm2()`: norm of the matrix\n - `transpose()`: transpose of the matrix\n - `trace()`: trace of the matrix\n - `shape()`: shape of the matrix\n\n - We have implemented `Quaternion`s (and all the most used methods)\n - We have implemented `DualQuaternion`s (and all the most used methods in Robotics and graphics like *Screw Linear Interpolation*)\n - We have implemented in the `transformations.rs` module a wide variety of functions used in Robotics (which conforms to the screw theory)\n\n## Benchmarks\n\nUsing the criterion crate:\n\nhttps://github.com/bheisler/criterion.rs\n\nrun with: `cargo bench`\n\nOthers benches comparing the performance with others crates are in this repo: https://github.com/bitshifter/mathbench-rs\n\n*NOTE*: this is the only crate that not have unsafe code\n\nwith the following results:\n\n\n| benchmark                      |          glam   |        cgmath   |      nalgebra   |       euclid   |           vek   |    pathfinder   |   static-math   |   ultraviolet   |\n|--------------------------------|-----------------|-----------------|-----------------|----------------|-----------------|-----------------|-----------------|-----------------|\n| euler 2d x10000                |      16.23 us   |      16.13 us   |    __9.954 us__ |     16.18 us   |       16.2 us   |      10.42 us   |     __9.97 us__ |      16.17 us   |\n| euler 3d x10000                |    __15.95 us__ |      32.11 us   |      32.13 us   |     32.13 us   |      32.13 us   |    __16.27 us__ |      32.16 us   |      32.11 us   |\n| matrix2 determinant            |   __2.0386 ns__ |     2.0999 ns   |     2.1018 ns   |      N/A       |     2.0997 ns   |     2.0987 ns   |     2.0962 ns   |     2.1080 ns   |\n| matrix2 inverse                |   __2.8226 ns__ |     8.4418 ns   |     7.6303 ns   |      N/A       |       N/A       |     3.3459 ns   |     9.4636 ns   |     5.8796 ns   |\n| matrix2 mul matrix2            |   __2.6036 ns__ |     5.0007 ns   |     4.8172 ns   |      N/A       |     9.3814 ns   |   __2.5516 ns__ |     4.7274 ns   |     4.9428 ns   |\n| matrix2 mul vector2 x1         |     2.4904 ns   |     2.6144 ns   |     2.8714 ns   |      N/A       |     4.2139 ns   |   __2.0839 ns__ |     2.8873 ns   |     2.6250 ns   |\n| matrix2 mul vector2 x100       |   227.5271 ns   |   243.3579 ns   |   265.1698 ns   |      N/A       |   400.6940 ns   | __219.7127 ns__ |   267.8780 ns   |   243.9880 ns   |\n| matrix2 return self            |   __2.4235 ns__ |     2.8841 ns   |     2.8756 ns   |      N/A       |     2.8754 ns   |   __2.4147 ns__ |     2.8717 ns   |     2.8697 ns   |\n| matrix2 transpose              |   __2.2887 ns__ |     3.0645 ns   |     7.9154 ns   |      N/A       |     2.9635 ns   |       N/A       |     3.0637 ns   |     3.0652 ns   |\n| matrix3 determinant            |     3.9129 ns   |   __3.8107 ns__ |   __3.8191 ns__ |      N/A       |   __3.8180 ns__ |       N/A       |   __3.8151 ns__ |     8.9368 ns   |\n| matrix3 inverse                |    17.5373 ns   |    18.6931 ns   |  __12.3183 ns__ |      N/A       |       N/A       |       N/A       |    12.8195 ns   |    21.9098 ns   |\n| matrix3 mul matrix3            |     9.9578 ns   |    13.3648 ns   |     7.8154 ns   |      N/A       |    35.5802 ns   |       N/A       |   __6.4938 ns__ |    10.0527 ns   |\n| matrix3 mul vector3 x1         |     4.8090 ns   |     4.9339 ns   |   __4.5046 ns__ |      N/A       |    12.5518 ns   |       N/A       |     4.8002 ns   |     4.8118 ns   |\n| matrix3 mul vector3 x100       |   __0.4836 us__ |   __0.4808 us__ |   __0.4755 us__ |      N/A       |      1.247 us   |       N/A       |   __0.4816 us__ |   __0.4755 us__ |\n| matrix3 return self            |   __5.4421 ns__ |   __5.4469 ns__ |   __5.4526 ns__ |      N/A       |   __5.4656 ns__ |       N/A       |   __5.4718 ns__ |   __5.4043 ns__ |\n| matrix3 transpose              |   __9.9567 ns__ |  __10.0794 ns__ |    10.9704 ns   |      N/A       |   __9.9257 ns__ |       N/A       |    10.7350 ns   |    10.5334 ns   |\n| matrix4 determinant            |   __6.2050 ns__ |    11.1041 ns   |    69.2549 ns   |   17.1809 ns   |    18.5233 ns   |       N/A       |    16.5331 ns   |     8.2704 ns   |\n| matrix4 inverse                |  __16.4386 ns__ |    47.0674 ns   |    71.8174 ns   |   64.1356 ns   |   284.3703 ns   |       N/A       |    52.6993 ns   |    41.1780 ns   |\n| matrix4 mul matrix4            |   __7.7715 ns__ |    26.7308 ns   |     8.6500 ns   |   10.4414 ns   |    86.1501 ns   |       N/A       |    21.7985 ns   |    26.8056 ns   |\n| matrix4 mul vector4 x1         |   __3.0303 ns__ |     7.7400 ns   |     3.4091 ns   |      N/A       |    21.0968 ns   |       N/A       |     6.2971 ns   |     6.2537 ns   |\n| matrix4 mul vector4 x100       |   __0.6136 us__ |     0.9676 us   |    __0.627 us__ |      N/A       |      2.167 us   |       N/A       |     0.7893 us   |     0.8013 us   |\n| matrix4 return self            |     7.1741 ns   |   __6.8838 ns__ |     7.5030 ns   |      N/A       |     7.0410 ns   |       N/A       |   __6.7768 ns__ |     6.9508 ns   |\n| matrix4 transpose              |   __6.6826 ns__ |    12.4966 ns   |    15.3265 ns   |      N/A       |    12.6386 ns   |       N/A       |    15.2657 ns   |    12.3396 ns   |\n| ray-sphere intersection x10000 |       56.2 us   |       55.7 us   |    __15.32 us__ |     55.45 us   |      56.02 us   |       N/A       |       N/A       |      50.94 us   |\n| rotation3 inverse              |   __2.3113 ns__ |     3.1752 ns   |     3.3292 ns   |    3.3311 ns   |     3.1808 ns   |       N/A       |     8.7109 ns   |     3.6535 ns   |\n| rotation3 mul rotation3        |   __3.6584 ns__ |     7.5255 ns   |     7.4808 ns   |    8.1393 ns   |    14.1636 ns   |       N/A       |     6.8044 ns   |     7.6386 ns   |\n| rotation3 mul vector3 x1       |   __6.4950 ns__ |     7.6808 ns   |     7.5784 ns   |    7.5746 ns   |    18.2547 ns   |       N/A       |     7.2727 ns   |     8.9732 ns   |\n| rotation3 mul vector3 x100     |   __0.6465 us__ |     0.7844 us   |     0.7573 us   |    0.7533 us   |      1.769 us   |       N/A       |     0.7317 us   |     0.9416 us   |\n| rotation3 return self          |   __2.4928 ns__ |     2.8740 ns   |     2.8687 ns   |      N/A       |     2.8724 ns   |       N/A       |     4.7868 ns   |     2.8722 ns   |\n| transform point2 x1            |     2.7854 ns   |     2.8878 ns   |     4.4207 ns   |    2.8667 ns   |    11.9427 ns   |   __2.3601 ns__ |       N/A       |     4.1770 ns   |\n| transform point2 x100          |     0.3316 us   |     0.3574 us   |     0.4445 us   |  __0.3008 us__ |      1.212 us   |     0.3184 us   |       N/A       |     0.4332 us   |\n| transform point3 x1            |   __2.9619 ns__ |    10.6812 ns   |     6.1037 ns   |    7.7051 ns   |    13.2607 ns   |     3.0934 ns   |       N/A       |     6.8419 ns   |\n| transform point3 x100          |   __0.6095 us__ |       1.27 us   |     0.8064 us   |    0.7674 us   |      1.446 us   |   __0.6189 us__ |       N/A       |     0.8899 us   |\n| transform vector2 x1           |   __2.4944 ns__ |       N/A       |     3.7174 ns   |    2.6273 ns   |    11.9424 ns   |       N/A       |       N/A       |     3.0458 ns   |\n| transform vector2 x100         |     0.3125 us   |       N/A       |     0.3871 us   |  __0.2817 us__ |      1.213 us   |       N/A       |       N/A       |     0.3649 us   |\n| transform vector3 x1           |   __2.8091 ns__ |     7.7343 ns   |     5.5064 ns   |    4.4810 ns   |    15.4097 ns   |       N/A       |       N/A       |     4.8819 ns   |\n| transform vector3 x100         |   __0.6035 us__ |     0.9439 us   |     0.7573 us   |    0.6327 us   |       1.63 us   |       N/A       |       N/A       |     0.6703 us   |\n| transform2 inverse             |   __9.0256 ns__ |       N/A       |    12.2614 ns   |    9.4803 ns   |       N/A       |   __8.9047 ns__ |       N/A       |       N/A       |\n| transform2 mul transform2      |     4.5111 ns   |       N/A       |     8.1434 ns   |    5.8677 ns   |       N/A       |   __3.8513 ns__ |       N/A       |       N/A       |\n| transform2 return self         |   __4.1707 ns__ |       N/A       |     5.4356 ns   |    4.2775 ns   |       N/A       |   __4.1117 ns__ |       N/A       |       N/A       |\n| transform3 inverse             |  __10.9869 ns__ |       N/A       |    71.4437 ns   |   56.0136 ns   |       N/A       |    23.0392 ns   |       N/A       |       N/A       |\n| transform3 mul transform3d     |   __6.5903 ns__ |       N/A       |     8.5673 ns   |   10.1802 ns   |       N/A       |     7.6587 ns   |       N/A       |       N/A       |\n| transform3 return self         |   __7.1828 ns__ |       N/A       |   __7.2619 ns__ |  __7.2407 ns__ |       N/A       |   __7.3214 ns__ |       N/A       |       N/A       |\n| vector3 cross                  |   __2.4257 ns__ |     3.6842 ns   |     3.7945 ns   |    3.6821 ns   |     3.8323 ns   |       N/A       |     3.8622 ns   |     3.6927 ns   |\n| vector3 dot                    |   __2.1055 ns__ |     2.3179 ns   |     2.3174 ns   |    2.3190 ns   |     2.3195 ns   |       N/A       |     2.3204 ns   |     2.3160 ns   |\n| vector3 length                 |   __2.5020 ns__ |   __2.5002 ns__ |     2.5986 ns   |  __2.5013 ns__ |   __2.5021 ns__ |       N/A       |   __2.5036 ns__ |   __2.5017 ns__ |\n| vector3 normalize              |   __4.0454 ns__ |     5.8411 ns   |     8.4069 ns   |    8.0679 ns   |     8.8137 ns   |       N/A       |       N/A       |     5.8440 ns   |\n| vector3 return self            |   __2.4087 ns__ |     3.1021 ns   |     3.1061 ns   |      N/A       |     3.1052 ns   |       N/A       |     3.1136 ns   |     3.1071 ns   |\n\n\n## TODOS:\n\n - [X] `Quaternion` type and methods\n - [ ] `expm()`: Exponential matrix implementation\n - [X] Eigenvalues\n - [X] QR decomposition\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felsuizo%2Fstatic-math","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felsuizo%2Fstatic-math","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felsuizo%2Fstatic-math/lists"}