{"id":13711692,"url":"https://github.com/Laremere/alg","last_synced_at":"2025-05-06T21:32:00.865Z","repository":{"id":72558053,"uuid":"444592828","full_name":"Laremere/alg","owner":"Laremere","description":"Algebra for Zig","archived":false,"fork":false,"pushed_at":"2022-01-19T08:58:10.000Z","size":58,"stargazers_count":24,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-08-03T23:23:41.702Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Zig","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/Laremere.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":"2022-01-04T23:24:23.000Z","updated_at":"2024-04-02T09:10:17.000Z","dependencies_parsed_at":"2023-05-24T13:15:42.077Z","dependency_job_id":null,"html_url":"https://github.com/Laremere/alg","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/Laremere%2Falg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Laremere%2Falg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Laremere%2Falg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Laremere%2Falg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Laremere","download_url":"https://codeload.github.com/Laremere/alg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224535407,"owners_count":17327527,"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":[],"created_at":"2024-08-02T23:01:10.728Z","updated_at":"2024-11-13T22:30:32.238Z","avatar_url":"https://github.com/Laremere.png","language":"Zig","readme":"# Alg\r\n\r\nalg.math does concise formulas for custom types.  Similar to operator overloading in other languages.\r\n\r\nI'm making this for a private project which needs to do various types of algebraic math.  Unless Alg takes on a life of its own, things will mostly be implemented whent I need them.  Also I'm new to Zig and things are likely to not be idiomatic.  Issues, comments, and requests are welcome, but will only be acted upon as I see fit.\r\n\r\nExample:\r\n\r\n```zig\r\nvar a = alg.mat.Matrix(f32, 2, 1).lit(.{\r\n    1,\r\n    2,\r\n});\r\n\r\nvar b = alg.mat.Matrix(f32, 1, 2).lit(.{\r\n    3, 4,\r\n});\r\n\r\nvar c: f32 = 5;\r\n\r\nvar result = alg.math(\"a * b * c\", .{\r\n    .a = a,\r\n    .b = b,\r\n    .c = c,\r\n});\r\n\r\ntry expectEqual(alg.mat.Matrix(f32, 2, 2).lit(.{\r\n    15, 20,\r\n    30, 40,\r\n}), result);\r\n```\r\n\r\nCurrent limitations:\r\n\r\n- Only a limited number of operations implemented so far.\r\n- There is no order of operations.  All chained operations must be the same.  Use parethesis to determine order.  Eg, \"(a * b) + c\".\r\n- Chained operations are always carried out left to right.  This may be inefficient for some equations, and not standard for others (eg, raising to a power).\r\n\r\nAll more complex types have a single underlying type, and all operations require the same underlying type between operands.  Eg you can't add a matrix backed by floats with one backed by integers.\r\n\r\nImplemented:\r\n- Matrices:\r\n  - Define matrix in terms of rows, and columns.\r\n  - Addition between matrices of the same size.\r\n  - Multiplication with compatible shaped matricies resulting in a third, possibly differently shapped, matrix.\r\n  - Multiplication with scaler values, which multiplies each value in the matrix by the scaler.\r\n- Imaginary Numbers:\r\n  - Define in terms of real and imaginary parts.\r\n  - Addition and Multiplication with other imaginary numbers.\r\n\r\nFeature Wishlist:\r\n- Types:\r\n  - Floats\r\n  - Integers\r\n  - Comptime float and integers\r\n  - Vectory / Array\r\n  - Matrix\r\n  - Affine Matrix\r\n  - Geometic Algebra\r\n  - Maybe custom functions?\r\n  - Imaginary Numbers\r\n  - Quaternion\r\n- Operations\r\n  - Add\r\n  - multiply\r\n  - dot\r\n  - etc.\r\n- Built in values?\r\n  - e\r\n  - pi\r\n  - Identity matrix?  Is this useful?\r\n- Make parse errors actually useful.\r\n- Pairwise conversion of underlying type.","funding_links":[],"categories":["Zig","Data \u0026 Science"],"sub_categories":["Linear Algebra"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLaremere%2Falg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLaremere%2Falg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLaremere%2Falg/lists"}