{"id":42491384,"url":"https://github.com/lazear/simd-euclidean","last_synced_at":"2026-01-28T12:19:50.313Z","repository":{"id":62026718,"uuid":"180904699","full_name":"lazear/simd-euclidean","owner":"lazear","description":"Calculation of euclidean distance between vectors, with SIMD","archived":false,"fork":false,"pushed_at":"2024-01-17T02:34:17.000Z","size":29,"stargazers_count":9,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-01-17T09:40:21.799Z","etag":null,"topics":["algorithm","clustering","euclidean-distances","machine-learning","rust","simd"],"latest_commit_sha":null,"homepage":null,"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/lazear.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}},"created_at":"2019-04-12T01:15:36.000Z","updated_at":"2024-01-17T02:34:22.000Z","dependencies_parsed_at":"2022-10-25T09:30:27.122Z","dependency_job_id":null,"html_url":"https://github.com/lazear/simd-euclidean","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lazear/simd-euclidean","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lazear%2Fsimd-euclidean","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lazear%2Fsimd-euclidean/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lazear%2Fsimd-euclidean/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lazear%2Fsimd-euclidean/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lazear","download_url":"https://codeload.github.com/lazear/simd-euclidean/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lazear%2Fsimd-euclidean/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28845107,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T10:53:21.605Z","status":"ssl_error","status_checked_at":"2026-01-28T10:53:20.789Z","response_time":57,"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":["algorithm","clustering","euclidean-distances","machine-learning","rust","simd"],"created_at":"2026-01-28T12:19:49.845Z","updated_at":"2026-01-28T12:19:50.308Z","avatar_url":"https://github.com/lazear.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simd-euclidean\n\nBlazing fast euclidean distance implementation, utilizing LLVM and Rust's auto-vectorization.\n\nFor vectors \u003e= 32 elements, the SIMD-enabled algorithm is 2 to 8 times faster, with longer inputs provided greater speedups.\n\nTwo traits are exposed by this library, `Naive` and `Vectorized`, which both provide a `squared_distance` and `distance` function. \n\n```\n// Vectorized::distance will dispatch to Naive::distance for an input of this size\nlet v = Vectorized::distance(\u0026[0.1, 0.2, 0.3, 0.4f32], \u0026[0.4, 0.3, 0.2, 0.1f32]);\nlet n = Naive::distance(\u0026[0.1, 0.2, 0.3, 0.4f32], \u0026[0.4, 0.3, 0.2, 0.1f32]);\nassert!((n-v).abs() \u003c 0.00001);\n\nfor \u0026i in [16, 32, 64, 128].into_iter() {\n  // Dispatch to F32x4 or F32x8 (above 64 elements)\n    let mut rng = rand::thread_rng();\n    let a = (0..i).map(|_| rng.gen::\u003cf32\u003e()).collect::\u003cVec\u003cf32\u003e\u003e();\n    let b = (0..i).map(|_| rng.gen::\u003cf32\u003e()).collect::\u003cVec\u003cf32\u003e\u003e();\n\n    let v = Vectorized::distance(\u0026a, \u0026b);\n    let n = Naive::distance(\u0026a, \u0026b);\n    assert!((n-v).abs() \u003c 0.00001);\n}\n```\n\nThe `Vectorized` trait attempts to heuristically determine which SIMD layout (F32x4, F32x8, etc) will be fastest with the given input size.\n\nShown below is a comparison between `Naive::distance` and `Vectorized::distance` on random vectors of single precision floating point numbers. \n\n![Benchmark, f32](linesf32.svg \"Benchmark, f32\")\n\nAnd for double precision `f64` vectors:\n\n![Benchmark, f64](linesf64.svg \"Benchmark, f64\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flazear%2Fsimd-euclidean","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flazear%2Fsimd-euclidean","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flazear%2Fsimd-euclidean/lists"}