首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

SIMD.splat

SIMD.js已经从TC39中取消了积极的开发,并从第三阶段中删除了。它不再被网页浏览器所追求。暴露在 web 上的SIMD 操作在 WebAssembly 中正处于积极的发展之中, 其操作基于 SIMD. js 操作。

静态SIMD.%type%.splat()方法将创建一个新的SIMD数据类型,并将所有通道设置为给定值。

语法

代码语言:javascript
复制
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)

参数

s 可选

设置所有通道的值。这是int类型的整数,float类型是double。

返回值

所有通道设置为给定值的新SIMD数据类型。

描述

在构造SIMD数据类型时,需要多个通道值的参数。splat函数为所有通道设置单个值,使您可以快速组装新的SIMD数据类型。

如果你不指定一个值s,int SIMD类型的通道将被设置为0,并且对于float SIMD类型,通道将被设置为NaN

例子

代码语言:javascript
复制
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

SIMDThe 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

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com