CLAMP(3clc)
π CLAMP(3clc) β the OpenCL Manual, bestie edition π
okay so. welcome to clamp from the OpenCL manual, you're gonna eat this up. no cap.
β¨ NAME β¨
clamp β Clamp x to range given by min, max π
πΈ SYNOPSIS πΈ
gentype clamp(gentype x, gentype minval, gentype maxval);
gentypef clamp(gentypef x, float minval, float maxval);
gentyped clamp(gentyped x, double minval, double maxval);
gentype clamp (gentype x, gentype
minval, gentype maxval) // if half
extension enabled
gentype clamp (gentype x, half minval,
half maxval) // if half extension
enabled
like. four whole flavors. pick your fighter π
π¦ DESCRIPTION π¦
It literally returns min(fmax(x, minval), maxval). that's the whole vibe. β¨
π¨ Results are undefined if minval > maxval. π¨ not me warning you β that's undefined behaviour, bestie, it's giving chaos, do not pass go.
π NOTES π
The generic type name gentype is used to indicate that the function can take float, float2, float3, float4, float8, float16, double, double2, double3, double4, double8, or double16 as the type for the arguments. like she's flexible, she contains multitudes π«Ά
The generic type name gentypef is used to indicate that the function can take float, float2, float3, float4, float8, or float16 as the type for the arguments. floats only, gatekeeping is real π
The generic type name gentyped is used to indicate that the function can take double, double2, double3, double4, double8, or double16 as the type for the arguments. doubles only, precision girlies rise π
The built-in common functions are implemented using the round to nearest even rounding mode. periodt. that's the rule and we respect it π
If extended with cl_khr_fp16(3clc), generic type name gentype may indicate half and half{2|3|4|8|16} as arguments and return values. tiny float era, iconic π§
β SPECIFICATION β
OpenCL Specification[1] β yes the real one, go read it, iykyk π
π SEE ALSO π
commonFunctions(3clc)β go say hi, she's the whole friend group πΈ
π AUTHORS π
The Khronos Group β the actual main characters, no notes π
π 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 condition:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Materials.
π NOTES (the footnote one, yes there's another one, stay with me) π
- OpenCL Specification β page 260, section 6.12.4 - Common Functions π
and that's the whole page, bestie. you understood it, i know you did. π«Ά
The Khronos Group β 01/14/2021 β CLAMP(3clc) β¨ bye ily, go clamp responsibly π
π¦ 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