RiptideRiptide
Download Riptide SDKInstall Riptorch
Menu
Raya docs · Geometry, physics and speed

SIMD helpers

SIMD helpers over Float32x4, Int32x4 and Float64x2 that compile to single NEON instructions on arm64.

import 'package:riptide_simd/riptide_simd.ray';
6 classes105 functions and methods46 of 117 documented99 runnable examples

Overview

SIMD helpers for engine code. On Raya for arm64 (macOS, iOS, Android) every operation here compiles to one NEON instruction; on other runtimes, other targets and the web the same Raya code runs and gives the same result.

import 'package:riptide_simd/riptide_simd.ray';

final d = a.dot(b);                       // FMUL + FADDP + FADDP
final acc2 = a.fma(b, acc);               // FMLA: a * b + acc, one rounding
final q = (v * k).clamp(lo, hi).round().toInt32x4Truncated(); // FRINTA + FCVTZS
final m = x.lessThan(y);                  // Float64x2 compare -> 64-bit lane mask
final r = m.selectF64(x, y);              // BSL
final w = Float32x8.load(list, i) * Float32x8.splat(0.5); // two registers, no allocation

What's in it

APIRaya arm64Portable body
Float32x4.fma(b, c), Float64x2.fma(b, c)FMLA (fused)computed in double (see below)
Float32x4.sum, .dot(b)FADDP ×2 (+ FMUL)the same pairwise order, (x+y)+(z+w)
Float64x2.sum, .dot(b)FADDP (+ FMUL)x + y
Float32x4.minLane, .maxLaneFMINV / FMAXVshuffles + min/max
floor, ceil, truncate, round (both float types)FRINTM / FRINTP / FRINTZ / FRINTAfloorToDouble etc. per lane
Float32x4.toInt32x4TruncatedFCVTZS (saturating, NaN → 0)the same rule in Raya
Int32x4.toFloat32x4ValueSCVTFtoDouble per lane
Int32x4 * Int32x4, .equal, .greaterThanMUL / CMEQ / CMGTper lane
Int32x4.shiftLeft(n), .shiftRightArithmetic(n), .shiftRightLogical(n)SHL / SSHR / USHR when n is a constantper lane
Float64x2.lessThan … .notEqualFCMGT / FCMGE / FCMEQper lane
Int32x4.selectF64(t, f)BSLbitwise, through a scratch buffer
Float32x4.lowToFloat64x2, .highToFloat64x2FCVTL / FCVTL2Float64x2.fromFloat32x4
Float32x8, Float64x4, Int32x8two Q registers (@pragma('raya:value'),)immutable classes

Results are bit-identical between Raya and the portable bodies, with two documented exceptions:

  • fma: Raya rounds once (true fused multiply-add). The portable Float32x4.fma computes a * b + c in double and rounds to float, which equals the fused result except in rare halfway cases (at most 1 ulp). The portable Float64x2.fma is unfused (two roundings).
  • Lane min/max with NaN or 0.0 vs -0.0 are unspecified, exactly as for Float32x4.min/max today (the VM's runtime and compiled code already disagree there).

How it works

Each member carries @pragma('raya:simd', '<op>'). Raya's compiler replaces a call to a function with that pragma by one IL SimdOp when the signature matches the op; anything else (other runtimes, x64, the web, a tear-off) calls the Raya body. Raya also:

  • Lowers the raya:typed_data operations themselves to single instructions on arm64 (shuffles, shuffleMix, select, scale, conversions, signMask; v * c.shuffle(Float32x4.yyyy) becomes one multiply-by-element);
  • auto-vectorises element-wise Float32List/Float64List loops in AOT (for (i = 0; i < n; i++) out[i] = …, including if/else on doubles), four elements per iteration, with a scalar tail and bit-identical results.

Int8 lanes. Int32x4.sdot/udot (each lane += the dot product of its 4 bytes; one SDOT/UDOT) and smmla/ummla/usmmla (the accumulator as a 2 x 2 int32 matrix += A·Bᵀ of two 2 x 8 byte matrices; one SMMLA/UMMLA/USMMLA, 32 multiply-adds) treat the vector as 16 bytes, in the order of an Int32x4List view over an Int8List/Uint8List. SDOT/UDOT are on by default; the SMMLA family needs --raya-simd-i8mm at compile time (raya compile exe --extra-gen-snapshot-options=--raya-simd-i8mm), because M1 and A14 lack it. Measured on one M5 Pro core, all-pairs Gram 4,096 x 128: f32 fma 65 GOPS, sdot 156, smmla 279, exact.

So plain scalar typed-data code gets faster on Raya too; reach for riptide_simd for the operations Raya has no syntax for (fma, horizontal sums, rounding, integer conversions) and for 256-bit types.

Classes

extension SplitOSFloat32x4Ops on Float32x4

Float32x4 operations.

Properties

Float64x2 get lowToFloat64x2

Lanes x and y as a Float64x2 (FCVTL).

Float64x2 get highToFloat64x2

Lanes z and w as a Float64x2 (FCVTL2 on Raya, via a shuffle here).

Methods

fmamethod
Float32x4 fma(Float32x4 b, Float32x4 c)

this * b + c per lane. On Raya arm64 it is fused (FMLA, one rounding); the portable body computes in double and rounds twice, which can differ from the fused result by 1 ulp in rare halfway cases.

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float32x4(1.5, -2.25, 3.0, 0.5), b = Float32x4(2.0, 4.0, -1.0, 8.0);
  final c = Float32x4(0.25, 0.25, 0.25, 0.25);
  final r = a.fma(b, c);
  print('a * b + c = ${[r.x, r.y, r.z, r.w]}');
}
Output
a * b + c = [3.25, -8.75, -2.75, 4.25]
summethod
double sum()

(x + y) + (z + w), each addition rounded to float (FADDP twice).

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float32x4(1.5, -2.25, 3.0, 0.5), b = Float32x4(2.0, 4.0, -1.0, 8.0);
  print('sum of a = ${a.sum()}');
  print('sum of (0.1, 0.2, 0.3, 0.4) in float32 = ${Float32x4(0.1, 0.2, 0.3, 0.4).sum()}');
}
Output
sum of a = 2.75
sum of (0.1, 0.2, 0.3, 0.4) in float32 = 1.0
dotmethod
double dot(Float32x4 b)

The dot product: (this * b).sum.

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float32x4(1.5, -2.25, 3.0, 0.5), b = Float32x4(2.0, 4.0, -1.0, 8.0);
  print('a · b = ${a.dot(b)}');
  print('a · a = ${a.dot(a)}');
}
Output
a · b = -5.0
a · a = 16.5625
minLanemethod
double minLane()

The smallest lane (FMINV). NaN and 0.0 vs -0.0 are unspecified, as for Float32x4.min.

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float32x4(1.5, -2.25, 3.0, 0.5), b = Float32x4(2.0, 4.0, -1.0, 8.0);
  print('smallest lane of a: ${a.minLane()}');
  print('of b: ${b.minLane()}');
}
Output
smallest lane of a: -2.25
of b: -1.0
maxLanemethod
double maxLane()

The largest lane (FMAXV). NaN and 0.0 vs -0.0 are unspecified, as for Float32x4.max.

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float32x4(1.5, -2.25, 3.0, 0.5), b = Float32x4(2.0, 4.0, -1.0, 8.0);
  print('largest lane of a: ${a.maxLane()}');
  print('of b: ${b.maxLane()}');
}
Output
largest lane of a: 3.0
of b: 8.0
floormethod
Float32x4 floor()

double.floorToDouble per lane (FRINTM).

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final v = Float32x4(-1.5, -0.5, 0.5, 2.5);
  final r = v.floor();
  print('floor(-1.5, -0.5, 0.5, 2.5) = ${[r.x, r.y, r.z, r.w]}');
}
Output
floor(-1.5, -0.5, 0.5, 2.5) = [-2.0, -1.0, 0.0, 2.0]
ceilmethod
Float32x4 ceil()

double.ceilToDouble per lane (FRINTP).

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final v = Float32x4(-1.5, -0.5, 0.5, 2.5);
  final r = v.ceil();
  print('ceil(-1.5, -0.5, 0.5, 2.5) = ${[r.x, r.y, r.z, r.w]}');
}
Output
ceil(-1.5, -0.5, 0.5, 2.5) = [-1.0, -0.0, 1.0, 3.0]
truncatemethod
Float32x4 truncate()

double.truncateToDouble per lane (FRINTZ).

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final v = Float32x4(-1.5, -0.5, 0.5, 2.5);
  final r = v.truncate();
  print('truncate(-1.5, -0.5, 0.5, 2.5) = ${[r.x, r.y, r.z, r.w]}');
}
Output
truncate(-1.5, -0.5, 0.5, 2.5) = [-1.0, -0.0, 0.0, 2.0]
roundmethod
Float32x4 round()

double.roundToDouble per lane, halves away from zero (FRINTA).

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final v = Float32x4(-1.5, -0.5, 0.5, 2.5);
  final r = v.round();
  print('round(-1.5, -0.5, 0.5, 2.5) = ${[r.x, r.y, r.z, r.w]}');
}
Output
round(-1.5, -0.5, 0.5, 2.5) = [-2.0, -1.0, 1.0, 3.0]
Int32x4 toInt32x4Truncated()

Each lane converted to an int32, rounding toward zero; out-of-range lanes saturate and NaN becomes 0 (FCVTZS). Unlike Float32x4 → Int32x4 constructors, this converts values, not bits.

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final v = Float32x4(-2.7, 3.9, 1e10, double.nan);
  final i = v.toInt32x4Truncated();
  print('values: ${[i.x, i.y, i.z, i.w]}');
  print('bits instead (fromFloat32x4Bits): ${Int32x4.fromFloat32x4Bits(Float32x4(1.0, 0, 0, 0)).x}');
}
Output
values: [-2, 3, 2147483647, 0]
bits instead (fromFloat32x4Bits): 1065353216
extension SplitOSFloat64x2Ops on Float64x2

Float64x2 operations.

Methods

fmamethod
Float64x2 fma(Float64x2 b, Float64x2 c)

this * b + c per lane. Fused on Raya arm64 (FMLA); the portable body is unfused (two roundings).

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float64x2(1.5, -2.0), b = Float64x2(3.0, 0.25);
  final r = a.fma(b, Float64x2(1.0, 1.0));
  print('a * b + 1 = ${[r.x, r.y]}');
}
Output
a * b + 1 = [5.5, 0.5]
summethod
double sum()

x + y (FADDP).

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float64x2(1.5, -2.0), b = Float64x2(3.0, 0.25);
  print('sum = ${a.sum()}');
  print('0.1 + 0.2 = ${Float64x2(0.1, 0.2).sum()}');
}
Output
sum = -0.5
0.1 + 0.2 = 0.30000000000000004
dotmethod
double dot(Float64x2 b)

x * b.x + y * b.y, products rounded before the sum.

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float64x2(1.5, -2.0), b = Float64x2(3.0, 0.25);
  print('a · b = ${a.dot(b)}');
}
Output
a · b = 4.0
floormethod
Float64x2 floor()
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final v = Float64x2(-2.5, 2.5);
  final r = v.floor();
  print('floor(-2.5, 2.5) = ${[r.x, r.y]}');
  print('floor(0.49, -0.51) = ${[Float64x2(0.49, -0.51).floor().x, Float64x2(0.49, -0.51).floor().y]}');
}
Output
floor(-2.5, 2.5) = [-3.0, 2.0]
floor(0.49, -0.51) = [0.0, -1.0]
ceilmethod
Float64x2 ceil()
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final v = Float64x2(-2.5, 2.5);
  final r = v.ceil();
  print('ceil(-2.5, 2.5) = ${[r.x, r.y]}');
  print('ceil(0.49, -0.51) = ${[Float64x2(0.49, -0.51).ceil().x, Float64x2(0.49, -0.51).ceil().y]}');
}
Output
ceil(-2.5, 2.5) = [-2.0, 3.0]
ceil(0.49, -0.51) = [1.0, -0.0]
truncatemethod
Float64x2 truncate()
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final v = Float64x2(-2.5, 2.5);
  final r = v.truncate();
  print('truncate(-2.5, 2.5) = ${[r.x, r.y]}');
  print('truncate(0.49, -0.51) = ${[Float64x2(0.49, -0.51).truncate().x, Float64x2(0.49, -0.51).truncate().y]}');
}
Output
truncate(-2.5, 2.5) = [-2.0, 2.0]
truncate(0.49, -0.51) = [0.0, -0.0]
roundmethod
Float64x2 round()

Halves away from zero.

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final v = Float64x2(-2.5, 2.5);
  final r = v.round();
  print('round(-2.5, 2.5) = ${[r.x, r.y]}');
  print('round(0.49, -0.51) = ${[Float64x2(0.49, -0.51).round().x, Float64x2(0.49, -0.51).round().y]}');
}
Output
round(-2.5, 2.5) = [-3.0, 3.0]
round(0.49, -0.51) = [0.0, -1.0]
equalmethod
Int32x4 equal(Float64x2 b)

Lane masks: Int32x4 lanes x and y hold lane x's result (all ones when true), z and w lane y's. Use with SplitOSInt32x4Ops.selectF64.

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float64x2(1.0, 5.0), b = Float64x2(1.0, 3.0);
  final m = a.equal(b);
  print('mask lanes: ${[m.x, m.y, m.z, m.w]}');
  // Pick a where the test holds, else b.
  final r = m.selectF64(a, b);
  print('selected: ${[r.x, r.y]}');
}
Output
mask lanes: [-1, -1, 0, 0]
selected: [1.0, 3.0]
notEqualmethod
Int32x4 notEqual(Float64x2 b)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float64x2(1.0, 5.0), b = Float64x2(1.0, 3.0);
  final m = a.notEqual(b);
  print('mask lanes: ${[m.x, m.y, m.z, m.w]}');
  // Pick a where the test holds, else b.
  final r = m.selectF64(a, b);
  print('selected: ${[r.x, r.y]}');
}
Output
mask lanes: [0, 0, -1, -1]
selected: [1.0, 5.0]
Int32x4 greaterThan(Float64x2 b)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float64x2(1.0, 5.0), b = Float64x2(1.0, 3.0);
  final m = a.greaterThan(b);
  print('mask lanes: ${[m.x, m.y, m.z, m.w]}');
  // Pick a where the test holds, else b.
  final r = m.selectF64(a, b);
  print('selected: ${[r.x, r.y]}');
}
Output
mask lanes: [0, 0, -1, -1]
selected: [1.0, 5.0]
Int32x4 greaterThanOrEqual(Float64x2 b)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float64x2(1.0, 5.0), b = Float64x2(1.0, 3.0);
  final m = a.greaterThanOrEqual(b);
  print('mask lanes: ${[m.x, m.y, m.z, m.w]}');
  // Pick a where the test holds, else b.
  final r = m.selectF64(a, b);
  print('selected: ${[r.x, r.y]}');
}
Output
mask lanes: [-1, -1, -1, -1]
selected: [1.0, 5.0]
lessThanmethod
Int32x4 lessThan(Float64x2 b)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float64x2(1.0, 5.0), b = Float64x2(1.0, 3.0);
  final m = a.lessThan(b);
  print('mask lanes: ${[m.x, m.y, m.z, m.w]}');
  // Pick a where the test holds, else b.
  final r = m.selectF64(a, b);
  print('selected: ${[r.x, r.y]}');
}
Output
mask lanes: [0, 0, 0, 0]
selected: [1.0, 3.0]
Int32x4 lessThanOrEqual(Float64x2 b)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float64x2(1.0, 5.0), b = Float64x2(1.0, 3.0);
  final m = a.lessThanOrEqual(b);
  print('mask lanes: ${[m.x, m.y, m.z, m.w]}');
  // Pick a where the test holds, else b.
  final r = m.selectF64(a, b);
  print('selected: ${[r.x, r.y]}');
}
Output
mask lanes: [-1, -1, 0, 0]
selected: [1.0, 3.0]
extension SplitOSInt32x4Ops on Int32x4

Int32x4 operations.

Methods

Float32x4 toFloat32x4Value()

Each lane converted to a float (SCVTF). Unlike Float32x4.fromInt32x4Bits, this converts values, not bits.

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final i = Int32x4(-3, 0, 7, 16777217);
  final f = i.toFloat32x4Value();
  print('as floats: ${[f.x, f.y, f.z, f.w]}');
  print('16777217 rounds to the nearest float32');
}
Output
as floats: [-3.0, 0.0, 7.0, 16777216.0]
16777217 rounds to the nearest float32
equalmethod
Int32x4 equal(Int32x4 b)

All ones where lanes are equal (CMEQ).

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Int32x4(1, 5, -3, 7), b = Int32x4(1, 2, -3, 9);
  final m = a.equal(b);
  print('equal mask: ${[m.x, m.y, m.z, m.w]}');
}
Output
equal mask: [-1, 0, -1, 0]
Int32x4 greaterThan(Int32x4 b)

All ones where this lane is greater, signed (CMGT).

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Int32x4(1, 5, -3, 7), b = Int32x4(1, 2, -3, 9);
  final m = a.greaterThan(b);
  print('a > b mask: ${[m.x, m.y, m.z, m.w]}');
}
Output
a > b mask: [0, -1, 0, 0]
shiftLeftmethod
Int32x4 shiftLeft(int n)

Shift left by n (0-31). One SHL when n is a constant.

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final v = Int32x4(1, -8, 0x40000000, -1);
  final r = v.shiftLeft(2);
  print('<< 2: ${[r.x, r.y, r.z, r.w]}  (wraps to 32 bits)');
}
Output
<< 2: [4, -32, 0, -4]  (wraps to 32 bits)
Int32x4 shiftRightArithmetic(int n)

Arithmetic shift right by n (0-31). One SSHR when n is a constant.

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final v = Int32x4(1, -8, 0x40000000, -1);
  final r = v.shiftRightArithmetic(2);
  print('>> 2: ${[r.x, r.y, r.z, r.w]}  (sign kept)');
}
Output
>> 2: [0, -2, 268435456, -1]  (sign kept)
Int32x4 shiftRightLogical(int n)

Logical shift right by n (0-31). One USHR when n is a constant.

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final v = Int32x4(1, -8, 0x40000000, -1);
  final r = v.shiftRightLogical(2);
  print('>>> 2: ${[r.x, r.y, r.z, r.w]}  (zeros shifted in)');
}
Output
>>> 2: [0, 1073741822, 268435456, 1073741823]  (zeros shifted in)
sdotmethod
Int32x4 sdot(Int32x4 a, Int32x4 b)

Each lane plus the dot product of its 4 signed bytes in a and b (SDOT). On by default in Raya (--raya-simd-dotprod; every Apple chip from A13 and M1).

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';
int pack(List<int> b) => (b[0] & 0xff) | (b[1] & 0xff) << 8 | (b[2] & 0xff) << 16 | (b[3] & 0xff) << 24;

void main() {
  // Each lane holds 4 bytes; the result adds the 4-byte dot product to the accumulator lane.
  final a = Int32x4(pack([1, 2, 3, 4]), pack([-1, -1, -1, -1]), pack([100, 0, 0, 0]), pack([127, 127, 127, 127]));
  final b = Int32x4(pack([1, 1, 1, 1]), pack([2, 3, 4, 5]), pack([100, 0, 0, 0]), pack([127, 127, 127, 127]));
  final r = Int32x4(10, 0, 0, 0).sdot(a, b);
  print('signed dot + acc: ${[r.x, r.y, r.z, r.w]}');
}
Output
signed dot + acc: [20, -14, 10000, 64516]
udotmethod
Int32x4 udot(Int32x4 a, Int32x4 b)

sdot with unsigned bytes (UDOT).

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';
int pack(List<int> b) => (b[0] & 0xff) | (b[1] & 0xff) << 8 | (b[2] & 0xff) << 16 | (b[3] & 0xff) << 24;

void main() {
  // Each lane holds 4 bytes; the result adds the 4-byte dot product to the accumulator lane.
  final a = Int32x4(pack([1, 2, 3, 4]), pack([-1, -1, -1, -1]), pack([100, 0, 0, 0]), pack([127, 127, 127, 127]));
  final b = Int32x4(pack([1, 1, 1, 1]), pack([2, 3, 4, 5]), pack([100, 0, 0, 0]), pack([127, 127, 127, 127]));
  final r = Int32x4(10, 0, 0, 0).udot(a, b);
  print('unsigned dot + acc: ${[r.x, r.y, r.z, r.w]}');
}
Output
unsigned dot + acc: [20, 3570, 10000, 64516]
smmlamethod
Int32x4 smmla(Int32x4 a, Int32x4 b)

This as a 2 x 2 int32 matrix (x y / z w) plus A·Bᵀ, where a and b are 2 x 8 signed byte matrices (row r = bytes 8r.. 8r + 7): 32 multiply-adds in one SMMLA. Raya replaces it only with --raya-simd-i8mm (A15/M2 and later); otherwise this body runs.

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';
int pack(List<int> b) => (b[0] & 0xff) | (b[1] & 0xff) << 8 | (b[2] & 0xff) << 16 | (b[3] & 0xff) << 24;

void main() {
  // a and b are 2 × 8 byte matrices: row r is bytes 8r..8r+7 (lanes 2r and 2r+1).
  final a = Int32x4(pack([1, 2, 3, 4]), pack([5, 6, 7, 8]), pack([1, 1, 1, 1]), pack([1, 1, 1, 1]));
  final b = Int32x4(pack([1, 0, 0, 0]), pack([0, 0, 0, 1]), pack([-1, -1, -1, -1]), pack([-1, -1, -1, -1]));
  final c = Int32x4(0, 0, 0, 0).smmla(a, b);
  print('C = A·Bᵀ (signed × signed): [[${c.x}, ${c.y}], [${c.z}, ${c.w}]]');
}
Output
C = A·Bᵀ (signed × signed): [[9, -36], [2, -8]]
ummlamethod
Int32x4 ummla(Int32x4 a, Int32x4 b)

smmla with unsigned bytes (UMMLA).

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';
int pack(List<int> b) => (b[0] & 0xff) | (b[1] & 0xff) << 8 | (b[2] & 0xff) << 16 | (b[3] & 0xff) << 24;

void main() {
  // a and b are 2 × 8 byte matrices: row r is bytes 8r..8r+7 (lanes 2r and 2r+1).
  final a = Int32x4(pack([1, 2, 3, 4]), pack([5, 6, 7, 8]), pack([1, 1, 1, 1]), pack([1, 1, 1, 1]));
  final b = Int32x4(pack([1, 0, 0, 0]), pack([0, 0, 0, 1]), pack([-1, -1, -1, -1]), pack([-1, -1, -1, -1]));
  final c = Int32x4(0, 0, 0, 0).ummla(a, b);
  print('C = A·Bᵀ (unsigned × unsigned): [[${c.x}, ${c.y}], [${c.z}, ${c.w}]]');
}
Output
C = A·Bᵀ (unsigned × unsigned): [[9, 9180], [2, 2040]]
usmmlamethod
Int32x4 usmmla(Int32x4 a, Int32x4 b)

smmla with a unsigned and b signed (USMMLA).

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';
int pack(List<int> b) => (b[0] & 0xff) | (b[1] & 0xff) << 8 | (b[2] & 0xff) << 16 | (b[3] & 0xff) << 24;

void main() {
  // a and b are 2 × 8 byte matrices: row r is bytes 8r..8r+7 (lanes 2r and 2r+1).
  final a = Int32x4(pack([1, 2, 3, 4]), pack([5, 6, 7, 8]), pack([1, 1, 1, 1]), pack([1, 1, 1, 1]));
  final b = Int32x4(pack([1, 0, 0, 0]), pack([0, 0, 0, 1]), pack([-1, -1, -1, -1]), pack([-1, -1, -1, -1]));
  final c = Int32x4(0, 0, 0, 0).usmmla(a, b);
  print('C = A·Bᵀ (unsigned × signed): [[${c.x}, ${c.y}], [${c.z}, ${c.w}]]');
}
Output
C = A·Bᵀ (unsigned × signed): [[9, -36], [2, -8]]
selectF64method
Float64x2 selectF64(Float64x2 t, Float64x2 f)

Bitwise select of two Float64x2 by this mask (BSL): bits of t where the mask is set, of f elsewhere. Masks come from the Float64x2 comparisons in SplitOSFloat64x2Ops.

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float64x2(-1.5, 2.5), zero = Float64x2(0, 0);
  // max(a, 0) per lane: a mask from a comparison picks lanes bit by bit.
  final r = a.greaterThan(zero).selectF64(a, zero);
  print('max(a, 0) = ${[r.x, r.y]}');
}
Output
max(a, 0) = [0.0, 2.5]

Operators

operator *operator
Int32x4 operator *(Int32x4 b)

Lane-wise multiply, wrapping to 32 bits (MUL).

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Int32x4(3, -4, 65536, 2147483647), b = Int32x4(5, 6, 65536, 2);
  final r = a * b;
  print('a * b = ${[r.x, r.y, r.z, r.w]}  (wraps to 32 bits)');
}
Output
a * b = [15, -24, 0, -2]  (wraps to 32 bits)
final class Float32x8

Eight float32 lanes: lo holds lanes 0-3, hi lanes 4-7.

Constructors

const Float32x8.fromHalves(this.lo, this.hi)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final v = Float32x8.fromHalves(Float32x4(1, 2, 3, 4), Float32x4(5, 6, 7, 8));
  print('$v');
  print('lo.x = ${v.lo.x}, hi.w = ${v.hi.w}');
}
Output
Float32x8(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)
lo.x = 1.0, hi.w = 8.0
Float32x8constructor
Float32x8(double l0, double l1, double l2, double l3, double l4, double l5, double l6, double l7)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final v = Float32x8(0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4);
  print('$v');
  print('lane 5: ${v[5]}');
}
Output
Float32x8(0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0)
lane 5: 3.0
Float32x8.splatconstructor
Float32x8.splat(double v)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final v = Float32x8.splat(0.1);
  print(v.toList());
  print('0.1 in float32 is ${v[0]}');
}
Output
[0.10000000149011612, 0.10000000149011612, 0.10000000149011612, 0.10000000149011612, 0.10000000149011612, 0.10000000149011612, 0.10000000149011612, 0.10000000149011612]
0.1 in float32 is 0.10000000149011612
Float32x8.zeroconstructor
Float32x8.zero()
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final v = Float32x8.zero();
  print('$v, sum ${v.sum()}');
}
Output
Float32x8(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), sum 0.0
factory Float32x8.load(Float32x4List list, int index)

Lanes 8 * index.. 8 * index + 7 of list (two Float32x4 loads).

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final data = Float32x4List.fromList([for (var i = 0; i < 4; i++) Float32x4(4.0 * i, 4.0 * i + 1, 4.0 * i + 2, 4.0 * i + 3)]);
  final v = Float32x8.load(data, 1); // lanes 8..15
  print('block 1: ${v.toList()}');
}
Output
block 1: [8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0]

Properties

lofield
final Float32x4 lo
hifield
final Float32x4 hi
hashCodegetter
int get hashCode

Methods

storemethod
void store(Float32x4List list, int index)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final out = Float32x4List(4);
  Float32x8.splat(2).store(out, 0);
  (Float32x8.splat(2) * Float32x8(1, 2, 3, 4, 5, 6, 7, 8)).store(out, 1);
  print([for (final q in out) [q.x, q.y, q.z, q.w]]);
}
Output
[[2.0, 2.0, 2.0, 2.0], [2.0, 2.0, 2.0, 2.0], [2.0, 4.0, 6.0, 8.0], [10.0, 12.0, 14.0, 16.0]]
scalemethod
Float32x8 scale(double s)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float32x8(1, 2, 3, 4, 5, 6, 7, 8), b = Float32x8(8, 7, 6, 5, 4, 3, 2, 1);
  print('a × 0.5 = ${a.scale(0.5).toList()}');
}
Output
a × 0.5 = [0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0]
minmethod
Float32x8 min(Float32x8 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float32x8(1, 2, 3, 4, 5, 6, 7, 8), b = Float32x8(8, 7, 6, 5, 4, 3, 2, 1);
  print('min(a, b) = ${a.min(b).toList()}');
}
Output
min(a, b) = [1.0, 2.0, 3.0, 4.0, 4.0, 3.0, 2.0, 1.0]
maxmethod
Float32x8 max(Float32x8 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float32x8(1, 2, 3, 4, 5, 6, 7, 8), b = Float32x8(8, 7, 6, 5, 4, 3, 2, 1);
  print('max(a, b) = ${a.max(b).toList()}');
}
Output
max(a, b) = [8.0, 7.0, 6.0, 5.0, 5.0, 6.0, 7.0, 8.0]
absmethod
Float32x8 abs()
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final v = Float32x8(-1, 2, -3, 4, -5, 6, -7, 8);
  print('|v| = ${v.abs().toList()}');
}
Output
|v| = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]
sqrtmethod
Float32x8 sqrt()
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final v = Float32x8(0, 1, 2, 4, 9, 16, 0.25, 2.25);
  print('√v = ${v.sqrt().toList()}');
}
Output
√v = [0.0, 1.0, 1.4142135381698608, 2.0, 3.0, 4.0, 0.5, 1.5]
fmamethod
Float32x8 fma(Float32x8 b, Float32x8 c)

this * b + c, fused on Raya arm64 (see SplitOSFloat32x4Ops.fma).

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float32x8(1, 2, 3, 4, 5, 6, 7, 8), b = Float32x8(8, 7, 6, 5, 4, 3, 2, 1);
  final r = a.fma(b, Float32x8.splat(1));
  print('a·b + 1 = ${r.toList()}');
}
Output
a·b + 1 = [9.0, 15.0, 19.0, 21.0, 21.0, 19.0, 15.0, 9.0]
summethod
double sum()

lo.sum + hi.sum, rounded to float.

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float32x8(1, 2, 3, 4, 5, 6, 7, 8), b = Float32x8(8, 7, 6, 5, 4, 3, 2, 1);
  print('sum of a = ${a.sum()}');
}
Output
sum of a = 36.0
dotmethod
double dot(Float32x8 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float32x8(1, 2, 3, 4, 5, 6, 7, 8), b = Float32x8(8, 7, 6, 5, 4, 3, 2, 1);
  print('a · b = ${a.dot(b)}');
  print('a · a = ${a.dot(a)}');
}
Output
a · b = 120.0
a · a = 204.0
lessThanmethod
Int32x8 lessThan(Float32x8 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float32x8(1, 2, 3, 4, 5, 6, 7, 8), b = Float32x8(8, 7, 6, 5, 4, 3, 2, 1);
  final m = a.lessThan(b);
  print('mask: ${m.toList()}');
  print('signMask: ${m.signMask.toRadixString(2).padLeft(8, '0')}');
  print('picked: ${m.select(a, b).toList()}');
}
Output
mask: [-1, -1, -1, -1, 0, 0, 0, 0]
signMask: 00001111
picked: [1.0, 2.0, 3.0, 4.0, 4.0, 3.0, 2.0, 1.0]
Int32x8 lessThanOrEqual(Float32x8 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float32x8(1, 2, 3, 4, 5, 6, 7, 8), b = Float32x8(8, 7, 6, 5, 4, 3, 2, 1);
  final m = a.lessThanOrEqual(b);
  print('mask: ${m.toList()}');
  print('signMask: ${m.signMask.toRadixString(2).padLeft(8, '0')}');
  print('picked: ${m.select(a, b).toList()}');
}
Output
mask: [-1, -1, -1, -1, 0, 0, 0, 0]
signMask: 00001111
picked: [1.0, 2.0, 3.0, 4.0, 4.0, 3.0, 2.0, 1.0]
Int32x8 greaterThan(Float32x8 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float32x8(1, 2, 3, 4, 5, 6, 7, 8), b = Float32x8(8, 7, 6, 5, 4, 3, 2, 1);
  final m = a.greaterThan(b);
  print('mask: ${m.toList()}');
  print('signMask: ${m.signMask.toRadixString(2).padLeft(8, '0')}');
  print('picked: ${m.select(a, b).toList()}');
}
Output
mask: [0, 0, 0, 0, -1, -1, -1, -1]
signMask: 11110000
picked: [8.0, 7.0, 6.0, 5.0, 5.0, 6.0, 7.0, 8.0]
Int32x8 greaterThanOrEqual(Float32x8 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float32x8(1, 2, 3, 4, 5, 6, 7, 8), b = Float32x8(8, 7, 6, 5, 4, 3, 2, 1);
  final m = a.greaterThanOrEqual(b);
  print('mask: ${m.toList()}');
  print('signMask: ${m.signMask.toRadixString(2).padLeft(8, '0')}');
  print('picked: ${m.select(a, b).toList()}');
}
Output
mask: [0, 0, 0, 0, -1, -1, -1, -1]
signMask: 11110000
picked: [8.0, 7.0, 6.0, 5.0, 5.0, 6.0, 7.0, 8.0]
equalmethod
Int32x8 equal(Float32x8 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float32x8(1, 2, 3, 4, 5, 6, 7, 8), b = Float32x8(8, 7, 6, 5, 4, 3, 2, 1);
  final m = a.equal(b);
  print('mask: ${m.toList()}');
  print('signMask: ${m.signMask.toRadixString(2).padLeft(8, '0')}');
  print('picked: ${m.select(a, b).toList()}');
}
Output
mask: [0, 0, 0, 0, 0, 0, 0, 0]
signMask: 00000000
picked: [8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0]
toListmethod
List<double> toList()
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final v = Float32x8(1, 2, 3, 4, 5, 6, 7, 8) * Float32x8.splat(0.5);
  final l = v.toList();
  print('$l (${l.length} lanes)');
}
Output
[0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0] (8 lanes)
toStringmethod
String toString()
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  print(Float32x8(1, -2, 3.5, 0, 0, 0, 0, 1e-3));
}
Output
Float32x8(1.0, -2.0, 3.5, 0.0, 0.0, 0.0, 0.0, 0.0010000000474974513)

Operators

operator +operator
Float32x8 operator +(Float32x8 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float32x8(1, 2, 3, 4, 5, 6, 7, 8), b = Float32x8(8, 7, 6, 5, 4, 3, 2, 1);
  final r = a + b;
  print('a + b = ${r.toList()}');
}
Output
a + b = [9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0]
operator -operator
Float32x8 operator -(Float32x8 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float32x8(1, 2, 3, 4, 5, 6, 7, 8), b = Float32x8(8, 7, 6, 5, 4, 3, 2, 1);
  final r = a - b;
  print('a - b = ${r.toList()}');
}
Output
a - b = [-7.0, -5.0, -3.0, -1.0, 1.0, 3.0, 5.0, 7.0]
operator *operator
Float32x8 operator *(Float32x8 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float32x8(1, 2, 3, 4, 5, 6, 7, 8), b = Float32x8(8, 7, 6, 5, 4, 3, 2, 1);
  final r = a * b;
  print('a * b = ${r.toList()}');
}
Output
a * b = [8.0, 14.0, 18.0, 20.0, 20.0, 18.0, 14.0, 8.0]
operator /operator
Float32x8 operator /(Float32x8 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float32x8(1, 2, 3, 4, 5, 6, 7, 8), b = Float32x8(8, 7, 6, 5, 4, 3, 2, 1);
  final r = a / b;
  print('a / b = ${r.toList()}');
}
Output
a / b = [0.125, 0.2857142984867096, 0.5, 0.800000011920929, 1.25, 2.0, 3.5, 8.0]
operator -operator
Float32x8 operator -()
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float32x8(1, 2, 3, 4, 5, 6, 7, 8), b = Float32x8(8, 7, 6, 5, 4, 3, 2, 1);
  print('−a = ${(-a).toList()}');
}
Output
−a = [-1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0]
operator []operator
double operator [](int i)

Lane i (0-7).

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float32x8(1, 2, 3, 4, 5, 6, 7, 8), b = Float32x8(8, 7, 6, 5, 4, 3, 2, 1);
  print('a[0] = ${a[0]}, a[3] = ${a[3]}, a[4] = ${a[4]}, a[7] = ${a[7]}');
}
Output
a[0] = 1.0, a[3] = 4.0, a[4] = 5.0, a[7] = 8.0
operator ==operator
bool operator ==(Object other)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  print(Float32x8.splat(1) == Float32x8(1, 1, 1, 1, 1, 1, 1, 1));
  print(Float32x8.splat(1) == Float32x8.zero());
}
Output
true
false
final class Float64x4

Four float64 lanes: lo holds lanes 0-1, hi lanes 2-3.

Constructors

const Float64x4.fromHalves(this.lo, this.hi)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final v = Float64x4.fromHalves(Float64x2(1, 2), Float64x2(3, 4));
  print('$v');
}
Output
Float64x4(1.0, 2.0, 3.0, 4.0)
Float64x4constructor
Float64x4(double l0, double l1, double l2, double l3)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final v = Float64x4(0.1, 0.2, 0.3, 0.4);
  print('$v, sum ${v.sum()}');
}
Output
Float64x4(0.1, 0.2, 0.3, 0.4), sum 1.0
Float64x4.splatconstructor
Float64x4.splat(double v)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  print(Float64x4.splat(0.1).toList());
}
Output
[0.1, 0.1, 0.1, 0.1]
Float64x4.zeroconstructor
Float64x4.zero()
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  print(Float64x4.zero());
}
Output
Float64x4(0.0, 0.0, 0.0, 0.0)
factory Float64x4.load(Float64x2List list, int index)

Lanes 4 * index.. 4 * index + 3 of list.

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final data = Float64x2List.fromList([Float64x2(0, 1), Float64x2(2, 3), Float64x2(4, 5), Float64x2(6, 7)]);
  print('block 1: ${Float64x4.load(data, 1).toList()}');
}
Output
block 1: [4.0, 5.0, 6.0, 7.0]
factory Float64x4.fromFloat32x4(Float32x4 v)

Four floats widened to doubles (FCVTL + FCVTL2 on Raya arm64).

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final f = Float32x4(0.1, 0.2, 0.3, 0.4);
  final d = Float64x4.fromFloat32x4(f);
  print('widened: ${d.toList()}');
  print('the float32 value of 0.1 differs from 0.1 by ${(d.toList()[0] - 0.1).abs()}');
}
Output
widened: [0.10000000149011612, 0.20000000298023224, 0.30000001192092896, 0.4000000059604645]
the float32 value of 0.1 differs from 0.1 by 1.4901161138336505e-9

Properties

lofield
final Float64x2 lo
hifield
final Float64x2 hi
hashCodegetter
int get hashCode

Methods

storemethod
void store(Float64x2List list, int index)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final out = Float64x2List(2);
  Float64x4(1, 2, 3, 4).scale(10).store(out, 0);
  print([for (final p in out) [p.x, p.y]]);
}
Output
[[10.0, 20.0], [30.0, 40.0]]
scalemethod
Float64x4 scale(double s)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float64x4(1, 2, 3, 4), b = Float64x4(0.5, -1, 2, 8);
  print('a × 3 = ${a.scale(3).toList()}');
}
Output
a × 3 = [3.0, 6.0, 9.0, 12.0]
minmethod
Float64x4 min(Float64x4 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float64x4(1, 2, 3, 4), b = Float64x4(0.5, -1, 2, 8);
  print('min = ${a.min(b).toList()}');
}
Output
min = [0.5, -1.0, 2.0, 4.0]
maxmethod
Float64x4 max(Float64x4 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float64x4(1, 2, 3, 4), b = Float64x4(0.5, -1, 2, 8);
  print('max = ${a.max(b).toList()}');
}
Output
max = [1.0, 2.0, 3.0, 8.0]
absmethod
Float64x4 abs()
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  print(Float64x4(-1.5, 2, -0.0, -8).abs().toList());
}
Output
[1.5, 2.0, 0.0, 8.0]
sqrtmethod
Float64x4 sqrt()
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  print(Float64x4(2, 4, 9, 0.25).sqrt().toList());
}
Output
[1.4142135623730951, 2.0, 3.0, 0.5]
fmamethod
Float64x4 fma(Float64x4 b, Float64x4 c)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float64x4(1, 2, 3, 4), b = Float64x4(0.5, -1, 2, 8);
  print('a·b + 1 = ${a.fma(b, Float64x4.splat(1)).toList()}');
}
Output
a·b + 1 = [1.5, -1.0, 7.0, 33.0]
summethod
double sum()

(l0 + l2) + (l1 + l3).

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float64x4(1, 2, 3, 4), b = Float64x4(0.5, -1, 2, 8);
  print('sum = ${a.sum()}');
}
Output
sum = 10.0
dotmethod
double dot(Float64x4 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float64x4(1, 2, 3, 4), b = Float64x4(0.5, -1, 2, 8);
  print('a · b = ${a.dot(b)}');
}
Output
a · b = 36.5
Float32x4 toFloat32x4()

The four lanes narrowed to floats.

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final f = Float64x4(0.1, 1 / 3, 1e40, -2).toFloat32x4();
  print('narrowed: ${[f.x, f.y, f.z, f.w]}');
}
Output
narrowed: [0.10000000149011612, 0.3333333432674408, Infinity, -2.0]
toListmethod
List<double> toList()
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float64x4(1, 2, 3, 4), b = Float64x4(0.5, -1, 2, 8);
  print(a.toList());
}
Output
[1.0, 2.0, 3.0, 4.0]
toStringmethod
String toString()
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  print(Float64x4(1, 0.5, -2, 1e-9));
}
Output
Float64x4(1.0, 0.5, -2.0, 1e-9)

Operators

operator +operator
Float64x4 operator +(Float64x4 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float64x4(1, 2, 3, 4), b = Float64x4(0.5, -1, 2, 8);
  print('a + b = ${(a + b).toList()}');
}
Output
a + b = [1.5, 1.0, 5.0, 12.0]
operator -operator
Float64x4 operator -(Float64x4 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float64x4(1, 2, 3, 4), b = Float64x4(0.5, -1, 2, 8);
  print('a - b = ${(a - b).toList()}');
}
Output
a - b = [0.5, 3.0, 1.0, -4.0]
operator *operator
Float64x4 operator *(Float64x4 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float64x4(1, 2, 3, 4), b = Float64x4(0.5, -1, 2, 8);
  print('a * b = ${(a * b).toList()}');
}
Output
a * b = [0.5, -2.0, 6.0, 32.0]
operator /operator
Float64x4 operator /(Float64x4 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float64x4(1, 2, 3, 4), b = Float64x4(0.5, -1, 2, 8);
  print('a / b = ${(a / b).toList()}');
}
Output
a / b = [2.0, -2.0, 1.5, 0.5]
operator -operator
Float64x4 operator -()
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Float64x4(1, 2, 3, 4), b = Float64x4(0.5, -1, 2, 8);
  print('−a = ${(-a).toList()}');
}
Output
−a = [-1.0, -2.0, -3.0, -4.0]
operator ==operator
bool operator ==(Object other)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  print(Float64x4(1, 2, 3, 4) == Float64x4(1, 2, 3, 4));
  print(Float64x4(1, 2, 3, 4) == Float64x4(1, 2, 3, 5));
}
Output
true
false
class

Int32x8

final class Int32x8

Eight int32 lanes or a Float32x8 comparison mask.

Constructors

const Int32x8.fromHalves(this.lo, this.hi)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Int32x8.fromHalves(Int32x4(1, 2, 3, 4), Int32x4(5, 6, 7, 8));
  final b = Int32x8.fromHalves(Int32x4(8, 7, 6, 5), Int32x4(4, 3, 2, 1));
  print('$a');
}
Output
Int32x8(1, 2, 3, 4, 5, 6, 7, 8)

Properties

lofield
final Int32x4 lo
hifield
final Int32x4 hi
signMaskgetter
int get signMask

Bit i set when lane i's sign bit is set.

hashCodegetter
int get hashCode

Methods

selectmethod
Float32x8 select(Float32x8 t, Float32x8 f)

Lanes of t where the mask is set, of f elsewhere (BSL per half).

Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final x = Float32x8(-3, 1, -2, 4, 0, -1, 5, -6);
  final mask = x.greaterThan(Float32x8.zero());
  final relu = mask.select(x, Float32x8.zero());
  print('max(x, 0) = ${relu.toList()}');
}
Output
max(x, 0) = [0.0, 1.0, 0.0, 4.0, 0.0, 0.0, 5.0, 0.0]
toListmethod
List<int> toList()
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Int32x8.fromHalves(Int32x4(1, 2, 3, 4), Int32x4(5, 6, 7, 8));
  final b = Int32x8.fromHalves(Int32x4(8, 7, 6, 5), Int32x4(4, 3, 2, 1));
  print(a.toList());
}
Output
[1, 2, 3, 4, 5, 6, 7, 8]
toStringmethod
String toString()
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Int32x8.fromHalves(Int32x4(1, 2, 3, 4), Int32x4(5, 6, 7, 8));
  final b = Int32x8.fromHalves(Int32x4(8, 7, 6, 5), Int32x4(4, 3, 2, 1));
  print(a * b);
}
Output
Int32x8(8, 14, 18, 20, 20, 18, 14, 8)

Operators

operator &operator
Int32x8 operator &(Int32x8 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Int32x8.fromHalves(Int32x4(1, 2, 3, 4), Int32x4(5, 6, 7, 8));
  final b = Int32x8.fromHalves(Int32x4(8, 7, 6, 5), Int32x4(4, 3, 2, 1));
  final r = a & b;
  print('a & b = ${r.toList()}');
}
Output
a & b = [0, 2, 2, 4, 4, 2, 2, 0]
operator |operator
Int32x8 operator |(Int32x8 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Int32x8.fromHalves(Int32x4(1, 2, 3, 4), Int32x4(5, 6, 7, 8));
  final b = Int32x8.fromHalves(Int32x4(8, 7, 6, 5), Int32x4(4, 3, 2, 1));
  final r = a | b;
  print('a | b = ${r.toList()}');
}
Output
a | b = [9, 7, 7, 5, 5, 7, 7, 9]
operator ^operator
Int32x8 operator ^(Int32x8 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Int32x8.fromHalves(Int32x4(1, 2, 3, 4), Int32x4(5, 6, 7, 8));
  final b = Int32x8.fromHalves(Int32x4(8, 7, 6, 5), Int32x4(4, 3, 2, 1));
  final r = a ^ b;
  print('a ^ b = ${r.toList()}');
}
Output
a ^ b = [9, 5, 5, 1, 1, 5, 5, 9]
operator +operator
Int32x8 operator +(Int32x8 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Int32x8.fromHalves(Int32x4(1, 2, 3, 4), Int32x4(5, 6, 7, 8));
  final b = Int32x8.fromHalves(Int32x4(8, 7, 6, 5), Int32x4(4, 3, 2, 1));
  final r = a + b;
  print('a + b = ${r.toList()}');
}
Output
a + b = [9, 9, 9, 9, 9, 9, 9, 9]
operator -operator
Int32x8 operator -(Int32x8 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Int32x8.fromHalves(Int32x4(1, 2, 3, 4), Int32x4(5, 6, 7, 8));
  final b = Int32x8.fromHalves(Int32x4(8, 7, 6, 5), Int32x4(4, 3, 2, 1));
  final r = a - b;
  print('a - b = ${r.toList()}');
}
Output
a - b = [-7, -5, -3, -1, 1, 3, 5, 7]
operator *operator
Int32x8 operator *(Int32x8 o)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Int32x8.fromHalves(Int32x4(1, 2, 3, 4), Int32x4(5, 6, 7, 8));
  final b = Int32x8.fromHalves(Int32x4(8, 7, 6, 5), Int32x4(4, 3, 2, 1));
  final r = a * b;
  print('a * b = ${r.toList()}');
}
Output
a * b = [8, 14, 18, 20, 20, 18, 14, 8]
operator ==operator
bool operator ==(Object other)
Example
import 'package:riptide_simd/riptide_simd.ray';
import 'raya:convert';
import 'raya:typed_data';

void main() {
  final a = Int32x8.fromHalves(Int32x4(1, 2, 3, 4), Int32x4(5, 6, 7, 8));
  final b = Int32x8.fromHalves(Int32x4(8, 7, 6, 5), Int32x4(4, 3, 2, 1));
  print(a == Int32x8.fromHalves(Int32x4(1, 2, 3, 4), Int32x4(5, 6, 7, 8)));
  print(a == b);
}
Output
true
false