Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

SIMD.Float64x2

Наши волонтёры ещё не перевели данную статью на Русский. Присоединяйтесь к нам и помогите закончить эту работу!

Note: The Float64x2 type is currently not part of the SIMD specification draft.

The SIMD.Float64x2 data type is a 128-bit vector divided into 2 lanes storing double precision floating point values.

SIMD.Float64x2

Figure 1: SIMD.Float64x2 in a 128-bit SIMD register.

Syntax

SIMD.Float64x2(x, y);

Parameters

x Optional
A double specifying the value of the first lane. Defaults to NaN.
y Optional
A double specifying the value of the second lane. Defaults to NaN.

Constructor functions

In addition to the simple creator functions, the SIMD API provides the following constructor functions:

SIMD.Float64x2.splat()
Creates a Float64x2 with all lanes set to a given value.

Note that you can also convert from another SIMD data type to Float64x2.

Note: SIMD types don't work with new, as SIMD values are no "boxed" objects (comparable to String(s) vs. new String(s), which creates a String object).

var v = new SIMD.Float64x2(1,2); 
// TypeError: SIMD.Float64x2 is not a constructor
var w = new SIMD.Float64x2.splat(3); 
// TypeError: SIMD.Float64x2.splat is not a constructor

Instead, you just write:

var v = SIMD.Float64x2(1,2); 
var w = SIMD.Float64x2.splat(3); 

Operations

To actually do something with SIMD types, SIMD operations are needed that work on SIMD data types.

Checking SIMD types

SIMD.Float64x2.check()
Returns a new Float64x2 if the parameter is a valid Float64x2 data type. Throws a TypeError otherwise.

Accessing and mutating lanes

SIMD.Float64x2.extractLane()
Returns the value of the given lane.
SIMD.Float64x2.replaceLane()
Returns a new Float64x2 with the given lane value replaced.

Loading from and storing into typed arrays

SIMD.Float64x2.load()
SIMD.Float64x2.load1()
Returns a new Float64x2 with the lane values loaded from a typed array.
SIMD.Float64x2.store()
SIMD.Float64x2.store1()
Stores a Float64x2 into a typed array.

Arithmetic operations

SIMD.Float64x2.abs()
Returns a new Float64x2 with the absolute lane values.
SIMD.Float64x2.add()
Returns a new Float64x2 with the lane values added (a + b).
SIMD.Float64x2.div()
Returns a new Float64x2 with the lane values divided (a / b).
SIMD.Float64x2.mul()
Returns a new loat64x2 with the lane values multiplied (a * b).
SIMD.Float64x2.neg()
Returns a new Float64x2 with the negated lane values.
SIMD.Float64x2.reciprocalApproximation()
Returns a new Float64x2 with an approximation of the reciprocal lane values.
SIMD.Float64x2.reciprocalSqrtApproximation()
Returns a new Float64x2 with an approximation of the reciprocal square root lane values.
SIMD.Float64x2.sub()
Returns a new Float64x2 with the lane values subtracted (a - b).
SIMD.Float64x2.sqrt()
Returns a new Float64x2 with the square root of the lane values.

Shuffling and swizzling

SIMD.Float64x2.shuffle()
Returns a new Float64x2 with the lane values shuffled.
SIMD.Float64x2.swizzle()
Returns a new Float64x2 with the lane values swizzled.

Min and max values

SIMD.Float64x2.max()
Returns a new Float64x2 with the maximum of the lane values.
SIMD.Float64x2.maxNum()
Returns a new Float64x2 with the maximum of the lane values, preferring numbers over NaN.
SIMD.Float64x2.min()
Returns a new Float64x2 with the minimum of the lane values.
SIMD.Float64x2.minNum()
Returns a new Float64x2 with the minimum of the lane values, preferring numbers over NaN.

Selections

SIMD.Float64x2.select()
Returns a new loat64x2 with the lane values being a mix of the lanes depending on the selector mask.

Comparisons

SIMD.Float64x2.equal()
Returns a selection mask depending on a == b.
SIMD.Float64x2.notEqual()
Returns a selection mask depending on a != b.
SIMD.Float64x2.lessThan()
Returns a selection mask depending on a < b.
SIMD.Float64x2.lessThanOrEqual()
Returns a selection mask depending on a <= b.
SIMD.Float64x2.greaterThan()
Returns a selection mask depending on a > b.
SIMD.Float64x2.greaterThanOrEqual()
Returns a selection mask depending on a >= b.

Data conversions

SIMD.Float64x2.fromFloat32x4Bits()
Creates a new Float64x2 data type with a bit-wise copy from a Float32x4.
SIMD.Float64x2.fromInt32x4Bits()
Creates a new Float64x2 data type with a bit-wise copy from an Int32x4.
SIMD.Float64x2.fromInt16x8Bits()
Creates a new Float64x2 data type with a bit-wise copy from an Int16x8.
SIMD.Float64x2.fromInt8x16Bits()
Creates a new Float64x2 data type with a bit-wise copy from an Int8x16.
SIMD.Float64x2.fromUint32x4Bits()
Creates a new Float64x2 data type with a bit-wise copy from a Uint32x4.
SIMD.Float64x2.fromUint16x8Bits()
Creates a new Float64x2 data type with a bit-wise copy from a Uint16x8.
SIMD.Float64x2.fromUint8x16Bits()
Creates a new Float64x2 data type with a bit-wise copy from a Uint8x16.

SIMD prototype

The following methods and properties are installed on the SIMD.Float64x2.prototype.

SIMD.Float64x2.prototype.constructor
Specifies the function that creates a SIMD object's prototype.
SIMD.Float64x2.prototype.toLocaleString()
Returns a localized string representing the SIMD type and its elements. Overrides the Object.prototype.toLocaleString() method.
SIMD.Float64x2.prototype.toString()
Returns a string representing the SIMD type and its elements. Overrides the Object.prototype.toString() method.
SIMD.Float64x2.prototype.valueOf()
Returns the primitive value of a SIMD object.
SIMD.Float64x2.prototype.toSource()
Returns a string representing the source code of the object. Overrides the Object.prototype.toSource() method.

Examples

Constructing a Float64x2

SIMD.Float64x2(1, 2); // Float64x2[1, 2]
SIMD.Float64x2(1);    // Float64x2[1, NaN]
SIMD.Float64x2();     // Float64x2[NaN, NaN]

Specifications

The Float64x2 type is currently not part of the SIMD specification draft.

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

Метки документа и участники

Метки: 
 Внесли вклад в эту страницу: fscholz
 Обновлялась последний раз: fscholz,