{"id":20740774,"url":"https://github.com/mgeisler/smawk","last_synced_at":"2025-04-24T02:27:01.016Z","repository":{"id":25930348,"uuid":"106667814","full_name":"mgeisler/smawk","owner":"mgeisler","description":"Rust functions for finding row-minima in monotone matrices.","archived":false,"fork":false,"pushed_at":"2024-08-19T23:55:13.000Z","size":163,"stargazers_count":6,"open_issues_count":5,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-22T06:19:39.568Z","etag":null,"topics":["matrices","optimization","rust","smawk"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/mgeisler.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":"2017-10-12T08:46:52.000Z","updated_at":"2024-08-12T23:55:03.000Z","dependencies_parsed_at":"2022-08-07T11:16:10.476Z","dependency_job_id":"b5fb2c43-9a24-40ce-ae41-256b3e0ab7a3","html_url":"https://github.com/mgeisler/smawk","commit_stats":{"total_commits":141,"total_committers":2,"mean_commits":70.5,"dds":0.007092198581560294,"last_synced_commit":"388c782a09e4717aef8de43e82cf37af0ff7227a"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgeisler%2Fsmawk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgeisler%2Fsmawk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgeisler%2Fsmawk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgeisler%2Fsmawk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mgeisler","download_url":"https://codeload.github.com/mgeisler/smawk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250547240,"owners_count":21448454,"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":["matrices","optimization","rust","smawk"],"created_at":"2024-11-17T06:29:50.777Z","updated_at":"2025-04-24T02:27:00.987Z","avatar_url":"https://github.com/mgeisler.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SMAWK Algorithm in Rust\n\n[![](https://github.com/mgeisler/smawk/workflows/build/badge.svg)][build-status]\n[![](https://codecov.io/gh/mgeisler/smawk/branch/master/graph/badge.svg)][codecov]\n[![](https://img.shields.io/crates/v/smawk.svg)][crates-io]\n[![](https://docs.rs/smawk/badge.svg)][api-docs]\n\nThis crate contains an implementation of the [SMAWK algorithm][smawk] for\nfinding the smallest element per row in a totally monotone matrix.\n\nThe SMAWK algorithm allows you to lower the running time of some algorithms from\nO(*n*²) to just O(_n_). In other words, you can turn a quadratic time complexity\n(which is often too expensive) into linear time complexity.\n\nFinding optimal line breaks in a paragraph of text is an example of an algorithm\nwhich would normally take O(*n*²) time for _n_ words. With this crate, the\nrunning time becomes linear. Please see the [textwrap crate][textwrap] for an\nexample of this.\n\n## Usage\n\nAdd this to your `Cargo.toml`:\n\n```toml\n[dependencies]\nsmawk = \"0.3\"\n```\n\nYou can now efficiently find row and column minima. Here is an example where we\nfind the column minima:\n\n```rust\nuse smawk::Matrix;\n\nlet matrix = vec![\n    vec![3, 2, 4, 5, 6],\n    vec![2, 1, 3, 3, 4],\n    vec![2, 1, 3, 3, 4],\n    vec![3, 2, 4, 3, 4],\n    vec![4, 3, 2, 1, 1],\n];\nlet minima = vec![1, 1, 4, 4, 4];\nassert_eq!(smawk::column_minima(\u0026matrix), minima);\n```\n\nThe `minima` vector gives the index of the minimum value per column, so\n`minima[0] == 1` since the minimum value in the first column is 2 (row 1). Note\nthat the smallest row index is returned.\n\n### Cargo Features\n\nThis crate has an optional dependency on the\n[`ndarray` crate](https://docs.rs/ndarray/), which provides an efficient matrix\nimplementation. Enable the `ndarray` Cargo feature to use it.\n\n## Documentation\n\n**[API documentation][api-docs]**\n\n## Changelog\n\n### Version 0.3.2 (2023-09-17)\n\nThis release adds more documentation and renames the top-level SMAWK functions.\nThe old names have been kept for now to ensure backwards compatibility, but they\nwill be removed in a future release.\n\n- [#65](https://github.com/mgeisler/smawk/pull/65): Forbid the use of unsafe\n  code.\n- [#69](https://github.com/mgeisler/smawk/pull/69): Migrate to the Rust 2021\n  edition.\n- [#73](https://github.com/mgeisler/smawk/pull/73): Add examples to all\n  functions.\n- [#74](https://github.com/mgeisler/smawk/pull/74): Add “mathematics” as a crate\n  category.\n- [#75](https://github.com/mgeisler/smawk/pull/75): Remove `smawk_` prefix from\n  optimized functions.\n\n### Version 0.3.1 (2021-01-30)\n\nThis release relaxes the bounds on the `smawk_row_minima`,\n`smawk_column_minima`, and `online_column_minima` functions so that they work on\nmatrices containing floating point numbers.\n\n- [#55](https://github.com/mgeisler/smawk/pull/55): Relax bounds to `PartialOrd`\n  instead of `Ord`.\n- [#56](https://github.com/mgeisler/smawk/pull/56): Update dependencies to their\n  latest versions.\n- [#59](https://github.com/mgeisler/smawk/pull/59): Give an example of what\n  SMAWK does in the README.\n\n### Version 0.3.0 (2020-09-02)\n\nThis release slims down the crate significantly by making `ndarray` an optional\ndependency.\n\n- [#45](https://github.com/mgeisler/smawk/pull/45): Move non-SMAWK code and unit\n  tests out of lib and into separate modules.\n- [#46](https://github.com/mgeisler/smawk/pull/46): Switch `smawk_row_minima`\n  and `smawk_column_minima` functions to a new `Matrix` trait.\n- [#47](https://github.com/mgeisler/smawk/pull/47): Make the dependency on the\n  `ndarray` crate optional.\n- [#48](https://github.com/mgeisler/smawk/pull/48): Let `is_monge` take a\n  `Matrix` argument instead of `ndarray::Array2`.\n- [#50](https://github.com/mgeisler/smawk/pull/50): Remove mandatory\n  dependencies on `rand` and `num-traits` crates.\n\n### Version 0.2.0 (2020-07-29)\n\nThis release updates the code to Rust 2018.\n\n- [#18](https://github.com/mgeisler/smawk/pull/18): Make `online_column_minima`\n  generic in matrix type.\n- [#23](https://github.com/mgeisler/smawk/pull/23): Switch to the\n  [Rust 2018][rust-2018] edition. We test against the latest stable and nightly\n  version of Rust.\n- [#29](https://github.com/mgeisler/smawk/pull/29): Drop strict Rust 2018\n  compatibility by not testing with Rust 1.31.0.\n- [#32](https://github.com/mgeisler/smawk/pull/32): Fix crash on overflow in\n  `is_monge`.\n- [#33](https://github.com/mgeisler/smawk/pull/33): Update `rand` dependency to\n  latest version and get rid of `rand_derive`.\n- [#34](https://github.com/mgeisler/smawk/pull/34): Bump `num-traits` and\n  `version-sync` dependencies to latest versions.\n- [#35](https://github.com/mgeisler/smawk/pull/35): Drop unnecessary Windows\n  tests. The assumption is that the numeric computations we do are\n  cross-platform.\n- [#36](https://github.com/mgeisler/smawk/pull/36): Update `ndarray` dependency\n  to the latest version.\n- [#37](https://github.com/mgeisler/smawk/pull/37): Automate publishing new\n  releases to crates.io.\n\n### Version 0.1.0 — August 7th, 2018\n\nFirst release with the classical offline SMAWK algorithm as well as a newer\nonline version where the matrix entries can depend on previously computed column\nminima.\n\n## License\n\nSMAWK can be distributed according to the [MIT license][mit]. Contributions will\nbe accepted under the same license.\n\n[build-status]: https://github.com/mgeisler/smawk/actions?query=branch%3Amaster+workflow%3Abuild\n[crates-io]: https://crates.io/crates/smawk\n[codecov]: https://codecov.io/gh/mgeisler/smawk\n[textwrap]: https://crates.io/crates/textwrap\n[smawk]: https://en.wikipedia.org/wiki/SMAWK_algorithm\n[api-docs]: https://docs.rs/smawk/\n[rust-2018]: https://doc.rust-lang.org/edition-guide/rust-2018/\n[mit]: LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgeisler%2Fsmawk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmgeisler%2Fsmawk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgeisler%2Fsmawk/lists"}