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.

Revision 987155 of SIMD.Float64x2

  • Revision slug: Web/JavaScript/Reference/Global_Objects/Float64x2
  • Revision title: SIMD.Float64x2
  • Revision id: 987155
  • Created:
  • Creator: fscholz
  • Is current revision? No
  • Comment

Revision Content

{{JSRef}}

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_inline}}
An double specifying the value of the first lane. Defaults to {{jsxref("NaN")}}.
y {{optional_inline}}
An double specifying the value of the second lane. Defaults to {{jsxref("NaN")}}.

Constructor functions

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

{{jsxref("SIMD.splat", "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

{{jsxref("SIMD.check", "SIMD.Float64x2.check()")}}
Returns a new Float64x2 if the parameter is a valid Float64x2 data type. Throws a {{jsxref("TypeError")}} otherwise.

Accessing and mutating lanes

{{jsxref("SIMD.extractLane", "SIMD.Float64x2.extractLane()")}}
Returns the value of the given lane.
{{jsxref("SIMD.replaceLane", "SIMD.Float64x2.replaceLane()")}}
Returns a new Float64x2 with the given lane value replaced.
{{jsxref("SIMD.select", "SIMD.Float64x2.select()")}}
Returns a new loat64x2 with the lane values being a mix of the lanes depending on the selector mask.

Loading from and storing into typed arrays

{{jsxref("SIMD.load", "SIMD.Float64x2.load()")}}
Returns a new Float64x2 with the lane values loaded from a typed array.
{{jsxref("SIMD.store", "SIMD.Float64x2.store()")}}
Stores a Float64x2 into a typed array.

Arithmetic operations

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

Shuffling and swizzling

{{jsxref("SIMD.shuffle", "SIMD.Float64x2.shuffle()")}}
Returns a new Float64x2 with the lane values shuffled.
{{jsxref("SIMD.swizzle", "SIMD.Float64x2.swizzle()")}}
Returns a new Float64x2 with the lane values swizzled.

Min and max values

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

Comparisons

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

Data conversions

{{jsxref("SIMD.fromInt32x4", "SIMD.Float64x2.fromInt32x4()")}}
Creates a new Float64x2 data type with a Float conversion from an Int32x4.
{{jsxref("SIMD.fromInt32x4Bits", "SIMD.Float64x2.fromInt32x4Bits()")}}
Creates a new Float64x2 data type with a bit-wise copy from an Int32x4.
{{jsxref("SIMD.fromFloat32x4", "SIMD.Float64x2.fromFloat32x4()")}}
Creates a new Float64x2 data type with a Float conversion from a Float32x4.
{{jsxref("SIMD.fromFloat32x4Bits", "SIMD.Float64x2.fromFloat32x4Bits()")}}
Creates a new Float64x2 data type with a bit-wise copy from a Float32x4.
{{jsxref("SIMD.fromInt16x8Bits", "SIMD.Float64x2.fromInt16x8Bits()")}}
Creates a new Float64x2 data type with a bit-wise copy from an Int16x8.
{{jsxref("SIMD.fromInt8x16Bits", "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

{{WhyNoSpecStart}} The Float64x2 type is currently not part of the SIMD specification draft. {{WhyNoSpecEnd}}

Browser compatibility

{{CompatibilityTable}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatNo}} {{CompatNightly("firefox")}} {{CompatNo}} {{CompatNo}} {{CompatNo}}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatNo}} {{CompatNo}} {{CompatNightly("firefox")}} {{CompatNo}} {{CompatNo}} {{CompatNo}}

See also

  • {{jsxref("SIMD")}}

Revision Source

<div>{{JSRef}}</div>

<div class="note">
<p>Note: The Float64x2 type is currently not part of the SIMD specification draft.</p>
</div>

<p>The <strong><code>SIMD.Float64x2</code></strong> data type is a 128-bit vector divided into 2 lanes storing double precision floating point values.</p>

<div><img alt="SIMD.Float64x2" src="https://mdn.mozillademos.org/files/11251/float64x2.png" />
<p>Figure 1: SIMD.Float64x2 in a 128-bit SIMD register.</p>
</div>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox">
SIMD.Float64x2(x, y);</pre>

<h3 id="Parameters">Parameters</h3>

<dl>
 <dt><code>x</code> {{optional_inline}}</dt>
 <dd>An double specifying the value of the first lane. Defaults to {{jsxref("NaN")}}.</dd>
 <dt><code>y</code> {{optional_inline}}</dt>
 <dd>An double specifying the value of the second lane. Defaults to {{jsxref("NaN")}}.</dd>
</dl>

<h2 id="Constructor_functions">Constructor functions</h2>

<p>In addition to the simple creator functions, the SIMD API provides the following constructor functions:</p>

<dl>
 <dt>{{jsxref("SIMD.splat", "SIMD.Float64x2.splat()")}}</dt>
 <dd>Creates a Float64x2 with all lanes set to a given value.</dd>
</dl>

<p>Note that you can also <a href="#Data_conversions">convert from another SIMD data type to Float64x2</a>.</p>

<div class="note">
<p><strong>Note:</strong> SIMD types don't work with <code>new</code>, as SIMD values are no "boxed" objects (comparable to <code>String(s)</code> vs. <code>new String(s)</code>, which creates a String object).</p>

<pre class="brush: js example-bad">
var v = new SIMD.Float64x2(1,2); 
// TypeError: SIMD.Float64x2 is not a constructor</pre>

<p>Instead, you just write:</p>

<pre class="brush: js example-good">
var v = SIMD.Float64x4(1,2);</pre>
</div>

<h2 id="Operations">Operations</h2>

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

<h3 id="Checking_SIMD_types">Checking SIMD types</h3>

<dl>
 <dt>{{jsxref("SIMD.check", "SIMD.Float64x2.check()")}}</dt>
 <dd>Returns a new Float64x2 if the parameter is a valid Float64x2 data type. Throws a {{jsxref("TypeError")}} otherwise.</dd>
</dl>

<h3 id="Accessing_and_mutating_lanes">Accessing and mutating lanes</h3>

<dl>
 <dt>{{jsxref("SIMD.extractLane", "SIMD.Float64x2.extractLane()")}}</dt>
 <dd>Returns the value of the given lane.</dd>
 <dt>{{jsxref("SIMD.replaceLane", "SIMD.Float64x2.replaceLane()")}}</dt>
 <dd>Returns a new Float64x2 with the given lane value replaced.</dd>
 <dt>{{jsxref("SIMD.select", "SIMD.Float64x2.select()")}}</dt>
 <dd>Returns a new loat64x2 with the lane values being a mix of the lanes depending on the selector mask.</dd>
</dl>

<h3 id="Loading_from_and_storing_into_typed_arrays">Loading from and storing into typed arrays</h3>

<dl>
 <dt>{{jsxref("SIMD.load", "SIMD.Float64x2.load()")}}</dt>
 <dd>Returns a new Float64x2 with the lane values loaded from a <a href="/en-US/docs/Web/JavaScript/Typed_arrays">typed array</a>.</dd>
 <dt>{{jsxref("SIMD.store", "SIMD.Float64x2.store()")}}</dt>
 <dd>Stores a Float64x2 into a <a href="/en-US/docs/Web/JavaScript/Typed_arrays">typed array</a>.</dd>
</dl>

<h3 id="Arithmetic_operations">Arithmetic operations</h3>

<dl>
 <dt>{{jsxref("SIMD.abs", "SIMD.Float64x2.abs()")}}</dt>
 <dd>Returns a new Float64x2 with the absolute lane values.</dd>
 <dt>{{jsxref("SIMD.add", "SIMD.Float64x2.add()")}}</dt>
 <dd>Returns a new Float64x2 with the lane values added (<code>a + b</code>).</dd>
 <dt>{{jsxref("SIMD.div", "SIMD.Float64x2.div()")}}</dt>
 <dd>Returns a new Float64x2 with the lane values divided (<code>a / b</code>).</dd>
 <dt>{{jsxref("SIMD.mul", "SIMD.Float64x2.mul()")}}</dt>
 <dd>Returns a new loat64x2 with the lane values multiplied (<code>a * b</code>).</dd>
 <dt>{{jsxref("SIMD.neg", "SIMD.Float64x2.neg()")}}</dt>
 <dd>Returns a new Float64x2 with the negated lane values.</dd>
 <dt>{{jsxref("SIMD.reciprocalApproximation", "SIMD.Float64x2.reciprocalApproximation()")}}</dt>
 <dd>Returns a new Float64x2 with an approximation of the reciprocal lane values.</dd>
 <dt>{{jsxref("SIMD.reciprocalSqrtApproximation", "SIMD.Float64x2.reciprocalSqrtApproximation()")}}</dt>
 <dd>Returns a new Float64x2 with an approximation of the reciprocal square root lane values.</dd>
 <dt>{{jsxref("SIMD.sub", "SIMD.Float64x2.sub()")}}</dt>
 <dd>Returns a new Float64x2 with the lane values subtracted (<code>a - b</code>).</dd>
 <dt>{{jsxref("SIMD.sqrt", "SIMD.Float64x2.sqrt()")}}</dt>
 <dd>Returns a new Float64x2 with the square root of the lane values.</dd>
</dl>

<h3 id="Shuffling_and_swizzling">Shuffling and swizzling</h3>

<dl>
 <dt>{{jsxref("SIMD.shuffle", "SIMD.Float64x2.shuffle()")}}</dt>
 <dd>Returns a new Float64x2 with the lane values shuffled.</dd>
 <dt>{{jsxref("SIMD.swizzle", "SIMD.Float64x2.swizzle()")}}</dt>
 <dd>Returns a new Float64x2 with the lane values swizzled.</dd>
</dl>

<h3 id="Min_and_max_values">Min and max values</h3>

<dl>
 <dt>{{jsxref("SIMD.max", "SIMD.Float64x2.max()")}}</dt>
 <dd>Returns a new Float64x2 with the maximum of the lane values.</dd>
 <dt>{{jsxref("SIMD.maxNum", "SIMD.Float64x2.maxNum()")}}</dt>
 <dd>Returns a new Float64x2 with the maximum of the lane values, preferring numbers over {{jsxref("NaN")}}.</dd>
 <dt>{{jsxref("SIMD.min", "SIMD.Float64x2.min()")}}</dt>
 <dd>Returns a new Float64x2 with the minimum of the lane values.</dd>
 <dt>{{jsxref("SIMD.minNum", "SIMD.Float64x2.minNum()")}}</dt>
 <dd>Returns a new Float64x2 with the minimum of the lane values, preferring numbers over {{jsxref("NaN")}}.</dd>
</dl>

<h3 id="Comparisons">Comparisons</h3>

<dl>
 <dt>{{jsxref("SIMD.equal", "SIMD.Float64x2.equal()")}}</dt>
 <dd>Returns a selection mask depending on <code>a == b</code>.</dd>
 <dt>{{jsxref("SIMD.notEqual", "SIMD.Float64x2.notEqual()")}}</dt>
 <dd>Returns a selection mask depending on <code>a != b</code>.</dd>
 <dt>{{jsxref("SIMD.lessThan", "SIMD.Float64x2.lessThan()")}}</dt>
 <dd>Returns a selection mask depending on <code>a &lt; b</code>.</dd>
 <dt>{{jsxref("SIMD.lessThanOrEqual", "SIMD.Float64x2.lessThanOrEqual()")}}</dt>
 <dd>Returns a&nbsp;selection mask depending on <code>a &lt;= b</code>.</dd>
 <dt>{{jsxref("SIMD.greaterThan", "SIMD.Float64x2.greaterThan()")}}</dt>
 <dd>Returns a selection mask depending on <code>a &gt; b</code>.</dd>
 <dt>{{jsxref("SIMD.greaterThanOrEqual", "SIMD.Float64x2.greaterThanOrEqual()")}}</dt>
 <dd>Returns a selection mask depending on <code>a &gt;= b</code>.</dd>
</dl>

<h3 id="Data_conversions">Data conversions</h3>

<dl>
 <dt>{{jsxref("SIMD.fromInt32x4", "SIMD.Float64x2.fromInt32x4()")}}</dt>
 <dd>Creates a new Float64x2 data type with a Float conversion from an Int32x4.</dd>
 <dt>{{jsxref("SIMD.fromInt32x4Bits", "SIMD.Float64x2.fromInt32x4Bits()")}}</dt>
 <dd>Creates a new Float64x2 data type with a bit-wise copy from an Int32x4.</dd>
 <dt>{{jsxref("SIMD.fromFloat32x4", "SIMD.Float64x2.fromFloat32x4()")}}</dt>
 <dd>Creates a new Float64x2 data type with a Float conversion from a Float32x4.</dd>
 <dt>{{jsxref("SIMD.fromFloat32x4Bits", "SIMD.Float64x2.fromFloat32x4Bits()")}}</dt>
 <dd>Creates a new Float64x2 data type with a bit-wise copy from a Float32x4.</dd>
 <dt>{{jsxref("SIMD.fromInt16x8Bits", "SIMD.Float64x2.fromInt16x8Bits()")}}</dt>
 <dd>Creates a new Float64x2 data type with a bit-wise copy from an Int16x8.</dd>
 <dt>{{jsxref("SIMD.fromInt8x16Bits", "SIMD.Float64x2.fromInt8x16Bits()")}}</dt>
 <dd>Creates a new Float64x2 data type with a bit-wise copy from an Int8x16.</dd>
</dl>

<h2 id="Examples">Examples</h2>

<h3 id="Constructing_an_Float64x2">Constructing an Float64x2</h3>

<pre class="brush: js">
SIMD.Float64x2(1, 2); // Float64x2[1, 2]
SIMD.Float64x2(1);    // Float64x2[1, NaN]
SIMD.Float64x2();     // Float64x2[NaN, NaN]
</pre>

<h2 id="Specifications">Specifications</h2>

<p>{{WhyNoSpecStart}} The Float64x2 type is currently not part of the SIMD specification draft. {{WhyNoSpecEnd}}</p>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNightly("firefox")}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Chrome for Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNightly("firefox")}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{jsxref("SIMD")}}</li>
</ul>
Revert to this revision