Our volunteers haven't translated this article into Català yet. Join us and help get the job done!
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.
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. |
Draft | 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 |