We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

SIMD.%type%.splat()

SIMD.js has been taken out of active development in TC39 and removed from Stage 3. It is not being pursued by web browsers for implementation anymore. SIMD operations exposed to the web are under active development within WebAssembly, with operations based on the SIMD.js operations.

The static SIMD.%type%.splat() method creates a new SIMD data type with all lanes set to a given value.

Syntax

SIMD.Float32x4.splat(s)
SIMD.Float64x2.splat(s)

SIMD.Int8x16.splat(s)
SIMD.Int16x8.splat(s)
SIMD.Int32x4.splat(s)

SIMD.Uint8x16.splat(s)
SIMD.Uint16x8.splat(s)
SIMD.Uint32x4.splat(s)

Parameters

s Optional
The value to set all lanes to. This is an integer for int types and a double for float types.

Return value

A new SIMD data type with all lanes set to a given value.

Description

When constructing SIMD data types, multiple arguments for the lane values are expected. The splat function sets a single value for all lanes, allowing you to quickly assemble a new SIMD data type.

If you don't specify a value s, the lanes of int SIMD types will be set to 0, and for float SIMD types the lanes will be set to NaN.

Examples

SIMD.Float32x4.splat(3);
// Float32x4[3,3,3,3]

SIMD.Float64x2.splat(3);
// Float64x2[3,3]

SIMD.Int8x16.splat(3);
// Int8x16[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3]

SIMD.Int16x8.splat(3);
// Int16x8[3,3,3,3,3,3,3,3]

SIMD.Int32x4.splat(3);
// Int32x4[3,3,3,3]

SIMD.Uint8x16.splat(3); 
// Uint8x16[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3] 

SIMD.Uint16x8.splat(3); 
// Uint16x8[3,3,3,3,3,3,3,3] 

SIMD.Uint32x4.splat(3); 
// Uint32x4[3,3,3,3]

Specifications

Specification Status Comment
SIMD
The definition of 'SIMDConstructor.splat' in that specification.
Obsolete Initial definition.

Browser compatibility

Experimental SIMD.js has been removed from browsers. It's still available in Firefox Nightly, but will be removed in favor of a SIMD implementation in WebAssembly. See also bug 1416723.

See also

Document Tags and Contributors

Contributors to this page: fscholz, eduardoboucas
Last updated by: fscholz,