COS(3clc)
π COS(3clc) β the OpenCL Manual, but make it make sense π
okay bestie, sit down, hydrate, because we're talking about the cosine functions from the OpenCL manual and honestly? they're giving trig legend energy. π this is COS(3clc), straight outta the OpenCL Manual, and yes we're doing all of it. no skips. periodt.
β¨ NAME β¨
cos, _cosh, _cospi, _half_cos, _native_cos β Cosine functions. π¦
gentype cos(gentype );
gentype cosh(gentype );
gentype cospi(gentype x);
gentype half_cos(gentype x);
gentype native_cos(gentype x);
πΈ DESCRIPTION πΈ
so here's the lineup, bestie, and every single one of them is serving:
cosβ it's the cosine function. that's it, that's the vibe. πcoshβ the hyperbolic cosine function. she's got range (literally, hyperbolically). πcospiβ computescos (x * pi). yes, she multiplies by pi for you. iconic behavior. β¨half_cosβ computes cosine. but listen:xmust be in the range-216... +216. and she's implemented with a minimum of 10-bits of accuracy, i.e. an ULP value less than or equal to8192 ulp. so like... she's cute but she's not your precision queen, and we respect her for that. πnative_cosβ computes cosine over an implementation-defined range. the maximum error is also implementation-defined. no cap.
π«Ά real talk about thenative__prefix, because this matters: functions with thenative__prefix may map to one or more native device instructions, and will typically have better performance compared to the corresponding functions (without thenative__prefix). the trade-off? the accuracy (and in some cases the input range(s)) of these functions is implementation-defined. so she's fast, she's fun, she's a little unpredictable. main character energy fr fr. π
π NOTES π
okay this is the part everyone skips and then everyone regrets skipping, so let's go:
- the vector versions of the math functions operate component-wise. the description is per-component. π§
- the built-in math functions are not affected by the prevailing rounding mode in the calling environment, and always return the same value as they would if called with the round to nearest even rounding mode. consistent queen. π
- 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. π
- the generic type name
gentypeis used to indicate that the function can takefloat,float2,float3,float4,float8,float16,double,double2,double3,double4,double8, ordouble16as the type for the arguments. πΈ - if extended with
cl_khr_fp16(3clc), generic type namegentypemay indicatehalfandhalf{2|3|4|8|16}as arguments and return values. β¨ - the generic type name
gentypefis used to indicate that the function can takefloat,float2,float3,float4,float8, orfloat16as the type for the arguments. π - the generic type name
gentypedis used to indicate that the function can takedouble,double2,double3,double4,double8, ordouble16as the type for the arguments. β
π SPECIFICATION π
OpenCL Specification[1]
(yeah, footnote one. we'll get there. patience, bestie. π)
π¦ SEE ALSO π¦
go read her next, she's the whole friend group. π
π AUTHORS π
The Khronos Group β the collective. the council. the ones who decided all of 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 following conditions:
the condition is that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials. that's the whole deal. keep the receipt. π§Ύ
β NOTES (the footnote one, not the other one) β
- OpenCL Specification page 244, section 6.12.2 - Math Functions
and that's the whole page, bestie!! π every flag, every range, every ULP, every gentype variant, all of it, accounted for. no details were harmed in the making of this manpage.
this was The Khronos Group, dated 01/14/2021, and the page is COS(3clc). mwah. π go compute some cosines. 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