SIMD.Float64x2

by 1 contributor:

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
An double specifying the value of the first lane. Defaults to NaN.
y Optional
An 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

Instead, you just write:

var v = SIMD.Float64x4(1,2);

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()
Returns a new Float64x2 with the lane values loaded from a typed array.
SIMD.Float64x2.store()
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.fromInt32x4()
Creates a new Float64x2 data type with a Float conversion from an Int32x4.
SIMD.Float64x2.fromInt32x4Bits()
Creates a new Float64x2 data type with a bit-wise copy from an Int32x4.
SIMD.Float64x2.fromFloat32x4()
Creates a new Float64x2 data type with a Float conversion from a Float32x4.
SIMD.Float64x2.fromFloat32x4Bits()
Creates a new Float64x2 data type with a bit-wise copy from a Float32x4.
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.

Examples

Constructing an 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 Not supported Nightly build Not supported Not supported Not supported
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support Not supported Not supported Nightly build Not supported Not supported Not supported

See also

Document Tags and Contributors

Contributors to this page: fscholz
Last updated by: fscholz,
Hide Sidebar