{"id":38543948,"url":"https://github.com/matthewsanetra/vector","last_synced_at":"2026-01-18T13:22:05.727Z","repository":{"id":135902683,"uuid":"271323568","full_name":"matthewsanetra/vector","owner":"matthewsanetra","description":"A simple 0 allocation math vector structure library","archived":false,"fork":false,"pushed_at":"2020-06-10T17:50:00.000Z","size":4,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-20T15:57:18.021Z","etag":null,"topics":["math","mathematics","maths","vector","vector-math","vectors"],"latest_commit_sha":null,"homepage":null,"language":"Go","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/matthewsanetra.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":"2020-06-10T16:06:09.000Z","updated_at":"2020-06-14T23:23:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"e05b8948-a42b-4f22-9ccf-20264e40d357","html_url":"https://github.com/matthewsanetra/vector","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/matthewsanetra/vector","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewsanetra%2Fvector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewsanetra%2Fvector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewsanetra%2Fvector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewsanetra%2Fvector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matthewsanetra","download_url":"https://codeload.github.com/matthewsanetra/vector/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewsanetra%2Fvector/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28503331,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T06:57:29.758Z","status":"ssl_error","status_checked_at":"2026-01-17T06:56:03.931Z","response_time":85,"last_error":"SSL_read: 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":["math","mathematics","maths","vector","vector-math","vectors"],"created_at":"2026-01-17T07:16:34.868Z","updated_at":"2026-01-18T13:22:05.720Z","avatar_url":"https://github.com/matthewsanetra.png","language":"Go","readme":"# Vector\nA very simple math vector library that does 0 memory allocation, allowing you to reuse objects.\n\nSimply specify an `out *Vector` and it will store the result there.\nI have found this to be espescially useful in iterative integration, where I can store the results\nof math operations in a variable declared outside of the for loop to make allocations O(1) instead of O(n)\n\n### With other libraries\nO(n) allocations; slow.\n```go\ncounter := \u0026Vector2f{.1, .1}\nfor i := 0; i \u003c 200; i++ {\n  counter = counter.Add(counter)\n}\n```\nIgnore that this code can be simplified, this is just demonstrating that the Add operation returns a new object, hence an allocation.\n\n### With this library\nO(1) allocations; fast.\n```go\ncounter := \u0026Vector2f{.1, .1}\nfor i := 0; i \u003c 200; i++ {\n    // Add2f(v1, v2, out *Vector2f)\n    vector.Add2f(counter, counter, counter)\n}\n```\nThis writes the result to the out vector directly, not creating\nany new object. The allocation is up to the user, which can reuse\nobjects to make code faster, and possibly even cache friendly.\n\n## Structures and functions\nCurrently only `Vector2f` and `Vector3f` are implemented.\n\nFor brevity the `2f` and `3f` will be replaced with `Xf`\n```go\n// out = v1 + v2\nfunc AddXf(v1, v2, out *VectorXf)\n\n// out = v1 - v2\nfunc SubXf(v1, v2 out *VectorXf)\n\n// out = v * k\nfunc MulXf(v *VectorXf, k float64, out *VectorXf)\n\n// out = v / k\nfunc DivXf(v *VectorXf, k float64, out *VectorXf)\n\n// return ||v||\nfunc (v *VectorXf) Mag() float64\n\n// return \"\u003cx, y[, z]\u003e|mag|\"\nfunc (v *VectorXf) String() string\n```\n\n## Possible improvements\nImplementing SIMD is not something this library is aiming to do.\nThis library is solely to allow the user to manage memory as allocations hog down calculations, espescially in tight loops.\n\n* [ ] Cross and dot multiplication\n* [ ] Unit tests\n* [ ] More types with more dimensions? This is up for discussion if it is necessary and at which point there is enough.\n\nPull requests and contributions welcome\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthewsanetra%2Fvector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatthewsanetra%2Fvector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthewsanetra%2Fvector/lists"}