min
On this page

min()

Function in Builtins

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

import { min } from 'typeshade'

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

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'
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

Source

src/core/ir/node.ts, line 1633, at commit 26de7be8

Edit this page Report a problem