W3cubDocs

/JavaScript

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

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support No support Nightly build No support No support No support
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support No support No support Nightly build No support No support No support

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SIMD/splat