ATAN(3clc)
β¨ ATAN(3clc) β¨
the OpenCL Manual β trig edition, but make it β¨anglesβ¨
okay so bestie, you wanna do some tangent math in your kernel? say less. this whole page is about the atan family and honestly? it's giving trigonometry but cute. let's get into it π
πΈ NAME πΈ
atan,_atan2,_atanh,_atanpi,_atan2pi β tangent functions π
and here's what they actually look like when you call them, verbatim:
gentype atan(gentype y_over_x);
gentype atan2(gentype y, gentype x);
gentype atanh(gentype );
gentype atanpi(gentype x);
gentype atan2pi(gentype y, gentype x);
(yes, atanh's parameter is unnamed in the spec. iconic of them. not my problem π)
π¦ DESCRIPTION π¦
atanβ it's the arc tangent function. classic.atan2β the arc tangent ofy / x. two arguments, one vibe.atanhβ the hyperbolic arc tangent function.atanpiβ computesatan (x) / Ο. that's right, it already divided by pi for you, no cap π₯§atan2piβ computesatan2 (y, x) / Ο. same deal, pi included, you're welcome.
π NOTES π
okay now the β¨fine printβ¨, but I promise it's important, bestie:
- the vector versions of the math functions operate component-wise. the description is per-component. so like, every lane gets the same treatment, no favorites π
- the built-in math functions are not affected by the prevailing rounding mode in the calling environment. they always return the same value as they would if called with the round to nearest even rounding mode. so whatever your environment is doing, these stay consistent. periodt.
- the built-in math functions take scalar or vector arguments. for any specific use of these functions, the actual type has to be the same for all arguments and the return type unless otherwise specified. no mixing, bestie, it's not that kind of party π
- the generic type name
gentypemeans the function can takefloat,float2,float3,float4,float8,float16,double,double2,double3,double4,double8, ordouble16as the type for the arguments. that's the whole roster π - if extended with
cl_khr_fp16(3clc), the generic type namegentypemay indicatehalfandhalf{2|3|4|8|16}as arguments and return values. half precision girlies, we see you π§ - the generic type name
gentypefmeans the function can takefloat,float2,float3,float4,float8, orfloat16as the type for the arguments. floats only, no doubles allowed π - the generic type name
gentypedmeans the function can takedouble,double2,double3,double4,double8, ordouble16as the type for the arguments. doubles only, that's the whole personality π
β SPECIFICATION β
OpenCL Specification[1] β yes, that's the one. go read it, iykyk π
π₯ SEE ALSO π₯
mathFunctions(3clc)β your other bestie, the whole math function family π«Ά
π AUTHORS π
The Khronos Group π (the ones who made all of this happen, respectfully)
π COPYRIGHT π
Copyright Β© 2007-2011 The Khronos Group Inc.
and now the legal bit, verbatim because we do NOT paraphrase lawyers, bestie:
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.
π NOTES π
(yes there's a second NOTES section, don't @ me, that's just how the page is structured)
- OpenCL Specification page 244, section 6.12.2 - Math Functions
lowkey the most important thing here: these are component-wise and rounding-mode-proof. the built-ins don't care what your environment is doing. they're booked, busy, and consistent. π
and that's the whole page!! πβ¨ this was brought to you by The Khronos Group, dated 01/14/2021, and yes we are still obsessed with it. go forth and compute your angles, bestie, you're gonna slay π«Άπ
π¦ 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