DISTANCE(3clc)
π NAME π
okay bestie, listen up β distance is literally THE vector distance girlie β¨ she tells you how far apart two points are, and she's serving it in every precision you could want:
float distance(floatn p0, floatn p1);
double distance(doublen p0, doublen p1);
half distance (gentype p0, gentype p1)
// if half extension enabled
no cap, those are the exact signatures, don't @ me π«Ά
πΈ DESCRIPTION πΈ
So she returns the distance between p0 and p1. That's it, that's the whole vibe π
But how tho? It's calculated as length(3clc)(p0 - p1) β yes bestie, she's just subtracting and then taking the length. Subtract the points, length the result, boom, distance. lowkey elegant, highkey iconic π₯
β¨ NOTES β¨
okay here's the tea β the built-in geometric functions (distance included) operate component-wise β the description is per-component, so think of it as each component doing its own lil thing π
Quick glossary moment, no gatekeeping:
floatnis one offloat,float2,float3, orfloat4doublenis one ofdouble,double2,double3, ordouble4
And these built-in geometric functions are implemented using the round to nearest even rounding mode. fr fr, that's the rounding mode, remember it π
Also she can be implemented using contractions like mad(3clc) or fma(3clc) β efficient queen π
And if you extend with cl_khr_fp16(3clc), the generic type name gentype may indicate half and half{2|3|4} as arguments. yes, half{2|3|4} means half2, half3, half4 β the brace notation is doing the most but it's valid, iykyk π
π SPECIFICATION π
OpenCL Specification[1] β she's official, she's documented, she's in the book π
π¦ SEE ALSO π¦
geometricFunctions(3clc)β go read the whole fam, bestie, they all hang out together πΈ
π AUTHORS π
The Khronos Group β the actual main characters who wrote this π
β COPYRIGHT β
Copyright Β© 2007-2011 The Khronos Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.
bestie that's the whole legal paragraph, I'm not paraphrasing it, I'm not summarising it, I'm not even breathing on it. verbatim. periodt π
π NOTES π
- OpenCL Specification β page 262, section 6.12.5 - Geometric Functions π
and that's the whole page, bestie!! π«Ά this lil masterpiece comes to you from The Khronos Group, dated 01/14/2021, and it's filed under DISTANCE(3clc) in the OpenCL Manual β¨ go forth and compute your distances, you've got this ππΈπ¦π
π
π¦ where this page comes from
- ubuntu jammy: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- ubuntu noble: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms