{"id":33939368,"url":"https://github.com/stelar-labs/opis-rs","last_synced_at":"2026-04-07T04:31:54.721Z","repository":{"id":40690379,"uuid":"410511662","full_name":"stelar-labs/opis-rs","owner":"stelar-labs","description":"Opis is a library for rational number and matrix arithmetic.","archived":false,"fork":false,"pushed_at":"2024-06-20T14:39:09.000Z","size":153,"stargazers_count":2,"open_issues_count":20,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-02T11:05:54.771Z","etag":null,"topics":["arithmetic","dynamic","dynamic-size","fractions","integers","matrix","rational-numbers"],"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/stelar-labs.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":"2021-09-26T09:46:53.000Z","updated_at":"2024-06-20T14:39:13.000Z","dependencies_parsed_at":"2023-09-22T21:15:48.417Z","dependency_job_id":"2fd99949-bbe7-4408-b974-0a3f79e28b0a","html_url":"https://github.com/stelar-labs/opis-rs","commit_stats":{"total_commits":42,"total_committers":6,"mean_commits":7.0,"dds":0.5238095238095238,"last_synced_commit":"1433b03ef07b90417a34634c3ad1216e194bfcdc"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/stelar-labs/opis-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stelar-labs%2Fopis-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stelar-labs%2Fopis-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stelar-labs%2Fopis-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stelar-labs%2Fopis-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stelar-labs","download_url":"https://codeload.github.com/stelar-labs/opis-rs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stelar-labs%2Fopis-rs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31500397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T03:10:19.677Z","status":"ssl_error","status_checked_at":"2026-04-07T03:10:13.982Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["arithmetic","dynamic","dynamic-size","fractions","integers","matrix","rational-numbers"],"created_at":"2025-12-12T15:26:13.237Z","updated_at":"2026-04-07T04:31:54.714Z","avatar_url":"https://github.com/stelar-labs.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Opis\n\nOpis is a library for rational number and matrix arithmetic.\n\n## Author\n\n- Roy R. O. Okello: [Email](mailto:royokello@protonmail.com) \u0026 [GitHub](https://github.com/royokello)\n\n## Features\n\n- Arbitrary Precision Integer Representation and Arithmetic\n- Fractions Arithmetic\n- Matrix Arithmetic \u0026 Linear Regression\n\n## Usage\n\n### Import\n\n```text\nuse opis::{ Bit, Integer, Fraction, Matrix };\n```\n\n### Bit\n\nAdd `a + b`\n\nAnd `a \u0026 b`\n\nEq `a == a`\n\nNot `!a`\n\nOr `a | b`\n\nXor `a ^ b`\n\n### Integer\n\npub struct Integer(pub Vec\u003cBit\u003e)\n\n- Hash\n- Display\n- Debug (:?, :#, :x, :b)\n\nAddition `a + b, a += b`\n\nAnd `a \u0026 b`\n\nBase2 `Integer::from_bin(\"1010101\"), a.to_bin()`\n\nBase10 `Integer::from_dec(\"674755\"), a.to_dec()`\n\nBase16 `Integer::from_hex(\"00ABC012\"), a.to_hex()`\n\nBytes `Integer::from(\u0026bytes), a.into()`\n\nComparision `a \u003c b, a \u003c= b, a \u003e b, a \u003e= b`\n\nDivision `a / b?`\n\nEquality `a == b`\n\nExtended Euclidean Algorithm `a.ext_gcd(\u0026b)`\n\nExtended Bits `a.to_ext_bits(256)`\n\nExtended Bytes `a.to_ext_bytes(32)`\n\nLinear Feedback Shift Register `a.lfsr(1)?`\n\nModulo: `a.modulo(\u0026m)`\n\nModular Exponentiation: `base.mod_pow(\u0026exponent, \u0026modulus)`\n\nMultiply `a * b, a *= b`\n\nNegate `a.negate()`\n\nNot `!a`\n\nOr `a | b`\n\nExponentiation `a.pow(e)?`\n\nRemainder: `a % b?`\n\nShifts `a \u003c\u003c 1, a \u003c\u003c= 1, a \u003e\u003e 1, a \u003e\u003e= 1`\n\n#### String Conversion\n\n`fn try_from(value: \u0026str) -\u003e Result\u003cSelf, Box\u003cdyn Error\u003e\u003e`\n\n- Binary (b'11, b'00, b'01)\n- Decimal (-1, 0, 1)\n- Hexadecimal (0xFF, 0x00, 0x01)\n\nSubtraction `a - b, a -= b`\n\n#### Type Conversion\n\n- From: \u0026[Bits], \u0026[u8], u8, u16, u32, u64, u128, usize\n- Into: Vec\u003cu8\u003e\n\n#### String Conversion\n\nSupport: Binary, Decimal, Hexadecimal, Floating Literal\n\n### Fraction\n\npub struct Fraction(pub Integer, pub Integer)\n\n- Clone\n- Hash\n- Display\n- Debug (:?, :#, :x, :b)\n\n#### Addition\n\n(a,b) + (c,d) = (ad + bc, bd)\n\n- Add (+)\n- AddAssign (+=)\n\n#### Subtraction\n\n(a,b) - (c,d) = (ad - bc, bd)\n\n- Sub (-)\n- SubAssign (-=)\n\n#### Multiplication\n\n(a,b) * (c,d) = (ac, bd)\n\n- Mul (*)\n- MulAssign (*=)\n\n#### Division\n\n(a,b) / (c,d) = (ad, bc) with c != 0\n\n- Div (/) -\u003e `Result\u003cFraction, Box\u003cdyn Error\u003e\u003e`\n\n#### Comparison \u0026 Equality\n\n#### Additive Inverse / Opposite\n\n-(a,b) = (-a,b)\n\n- `fraction.opposite() -\u003e Fraction`\n\n#### Multiplicative Inverse / Reciprocal\n\n(a,b)^-1 = (b,a)\n\n- `fraction.reciprocal() -\u003e Result\u003cFraction, Box\u003cdyn Error\u003e\u003e`\n\n#### Reduce\n\n- `pub fn reduce(\u0026mut self)`\n- `pub fn reduction(\u0026self) -\u003e Fraction`\n\n#### String Conversion\n\nSupport:  Binary, Decimal, Hexadecimal, Floating Point Literal\n\n#### Type Conversion\n\nFrom: Integer, u8, u16, u32, u64, u128, usize\n\n### Matrix\n\n#### Addition\n`fn add(self, b: Self) -\u003e Result\u003cMatrix\u003cT\u003e, Box\u003cdyn Error\u003e\u003e`\n\n#### Cofactors\n`fn cofactors(\u0026self, neg_one: T) -\u003e Result\u003cMatrix\u003cT\u003e, Box\u003cdyn Error\u003e\u003e`\n```\nA = [ 3 -1 -2]  C = [ 3  1 -2]\n    [ 3  1 -1]      [-3  1  1]\n    [ 3  4  2]      [ 3 -4  2]\n```\n\n#### Determinant\n`fn determinant(\u0026self, neg_one: T) -\u003e Result\u003cT, Box\u003cdyn std::error::Error\u003e\u003e`\n\n#### Dimensions\n`fn dimensions(\u0026self) -\u003e Result\u003c(usize, usize), Box\u003cdyn Error\u003e\u003e`\n\n#### Equality\n`fn eq(\u0026self, b: \u0026Self) -\u003e bool`\n\n#### Identity\n`fn identity(size: usize, zero: T, one: T) -\u003e Matrix\u003cT\u003e`\n\n#### inverse\n`fn inverse(\u0026self, neg_one: T, zero: T, one: T) -\u003e Result\u003cMatrix\u003cT\u003e, Box\u003cdyn Error\u003e\u003e`\n\n#### Linear Regression\n`fn linear_regression(\u0026self, variables: \u0026Matrix\u003cT\u003e, neg_one: T, zero: T, one: T) -\u003e Result\u003cMatrix\u003cT\u003e, Box\u003cdyn Error\u003e\u003e`\n\n#### Minors\n`fn minors(\u0026self, neg_one: T) -\u003e Result\u003cMatrix\u003cT\u003e, Box\u003cdyn Error\u003e\u003e`\n\n#### Multiplication\n`fn mul(self, b: Self) -\u003e Result\u003cMatrix\u003cT\u003e, Box\u003cdyn Error\u003e\u003e`\n`fn mul(self, b: T) -\u003e Matrix\u003cT\u003e`\n\n#### Subtraction\n`fn sub(self, b: Self) -\u003e Result\u003cMatrix\u003cT\u003e, Box\u003cdyn Error\u003e\u003e`\n\n#### Trace\n```\nA = [-1  2  7  0]   Tr(A) = (-1 + 5 + 7 + 0) = 11\n    [ 3  5 -8  4]\n    [ 1  2  7 -3]\n    [ 4 -2  1  0]\n```\n`fn trace(\u0026self) -\u003e Result\u003cT, Box\u003cdyn Error\u003e\u003e`\n\n#### Transpose\n`fn transpose(\u0026self) -\u003e Result\u003cMatrix\u003cT\u003e, Box\u003cdyn Error\u003e\u003e`\n```\nA = [2 0]   A' = [2 1 4]\n    [1 1]        [0 1 3]\n    [4 3]\n```\n\n## License\n\nMIT License\n\nCopyright Stelar Labs\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\n## Disclaimer\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstelar-labs%2Fopis-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstelar-labs%2Fopis-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstelar-labs%2Fopis-rs/lists"}