min
On this page

min()

Function in Builtins

min(a, b): component-wise minimum.

import { min } from 'typeshade/core/ir'

This export returns an IR node. A "use typeshade" file calls the builtin itself: min()

The signature, the description and the examples come from the compiler's own source at commit af54ddad5.

Syntax

const min: <K extends FloatKey | Float64Key | IntKey>(
a: ReadonlyNode<K>,
b: NoInfer<ArithArg<K>>,
) => Node<K>

Parameters

a ReadonlyNode<K>
b NoInfer<ArithArg<K>>

Return value

Node<K>

Description

b may be a scalar broadcast against a vector a, the same rule as the arithmetic methods, so min(color, 1) caps every channel against one literal without unrolling per component.

Examples

Example

import { fn, min, f32T } from 'typeshade/core/ir'
const capped = fn('capped', { x: f32T }, ({ x }) => min(x, 1))

Targets

TargetSupportNotes
WGSL (WebGPU) Supported

min(a, b). Over f64 operands the fp64 pass rewrites it into its df64 helper.

GLSL ES 3.00 (WebGL2) Supported

min(a, b). Over f64 operands the fp64 pass rewrites it into its df64 helper.

CPU oracle Supported

Evaluated in f64 by the oracle.

In the guide

See also

Source

src/core/ir/node.ts, line 1401, at commit af54ddad5

Edit this page Report a problem