This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.
The static SIMD.%type%.splat()
method creates a new SIMD data type with all lanes set to a given value.
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)
Optional
A new SIMD data type with all lanes set to a given value.
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
.
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]
Specification | Status | Comment |
---|---|---|
SIMD The definition of 'SIMDConstructor.splat' in that specification. | Draft | Initial definition. |
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 |
© 2005–2017 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