CLAMP(3clc)

πŸ“¦
version 1.0~svn33624 Β· 3 versions
, in ubuntu jammy, ubuntu noble

πŸ’– 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 πŸ’œ


πŸŽ€ AUTHORS πŸŽ€

The Khronos Group β€” the actual main characters, no notes πŸ‘‘


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) 🌈

  1. 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