mozilla
Your Search Results

    SIMD.float32x4

    This is an experimental technology, part of the Harmony (ECMAScript 7) proposal.
    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 version of browsers as the spec changes.

    The SIMD.float32x4 data type is a 128-bit vector divided into 4 lanes storing single precision floating point values.

    SIMD.float32x4

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

    Syntax

    SIMD.float32x4(x, y, z, w);

    Parameters

    The input values are specified in double precision floating and are converted to single precision floating point values before being stored.

    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.
    z Optional
    An double specifying the value of the third lane. Defaults to NaN.
    w Optional
    An double specifying the value of the fourth lane. Defaults to NaN.

    Constructors

    In addition to the simple constructors, the SIMD API provides the following constructor. Note that you can also convert from another SIMD data type to float32x4.

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

    Operations

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

    Checking SIMD types

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

    Accessing and mutating lanes

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

    Loading from and storing into typed arrays

    SIMD.float32x4.load()
    Returns a new float32x4 with the lane values loaded from a typed array.
    SIMD.float32x4.store()
    Stores an float32x4 into a typed array.

    Arithmetic operations

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

    Shuffling and swizzling

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

    Min/max and clamping

    SIMD.float32x4.clamp()
    Returns a new float32x4 with the lane values clamped between a lower limit and an upper limit.
    SIMD.float32x4.max()
    Returns a new float32x4 with the maximum of the lane values.
    SIMD.float32x4.maxNum()
    Returns a new float32x4 with the maximum of the lane values, preferring numbers over NaN.
    SIMD.float32x4.min()
    Returns a new float32x4 with the minimum of the lane values.
    SIMD.float32x4.minNum()
    Returns a new float32x4 with the minimum of the lane values, preferring numbers over NaN.

    Selections

     

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

    Comparisons

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

    Bitwise logical operations

    SIMD.float32x4.and()
    Returns a new float32x4 with the logical AND of the lane values (a & b).
    SIMD.float32x4.or()
    Returns a new float32x4 with the logical OR of the lane values (a | b).
    SIMD.float32x4.xor()
    Returns a new float32x4 with the logical XOR of the lane values (a ^ b).
    SIMD.float32x4.not()
    Returns a new float32x4 with lane with the logical NOT of the lane values (~a).

    Data conversions (packing / unpacking)

    SIMD.float32x4.fromInt32x4()
    Creates a new float32x4 data type with a float conversion from an int32x4.
    SIMD.float32x4.fromInt32x4Bits()
    Creates a new float32x4 data type with a bit-wise copy from an int32x4.
    SIMD.float32x4.fromFloat64x2()
    Creates a new float32x4 data type with a float conversion from a float64x2.
    SIMD.float32x4.fromFloat64x2Bits()
    Creates a new float32x4 data type with a bit-wise copy from a float64x2.
    SIMD.float32x4.fromInt16x8Bits()
    Creates a new float32x4 data type with a bit-wise copy from an int16x8.
    SIMD.float32x4.fromInt8x16Bits()
    Creates a new float32x4 data type with a bit-wise copy from an int8x16.

    Examples

    Constructing an float32x4

    new SIMD.float32x4(1, 2, 3, 4); // float32x4[1, 2, 3, 4]
    new SIMD.float32x4(1, 2);       // float32x4[1, 2, NaN, NaN]
    new SIMD.float32x4();           // float32x4[NaN, NaN, NaN, NaN]
    

    Specifications

    SIMD is not yet part of an official standards document or draft. For standardization work and a Polyfill implementation based on typed arrays, see the ecmascript_simd GitHub repository.

    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