Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 part of dart.scalarlist; | |
| 6 | |
| 7 /** | |
| 8 * Interface of Dart Simd128Float32x4 and operations. | |
| 9 * Simd128Float32x4 stores 4 32-bit floating point values in "lanes". | |
| 10 * The lanes are "x", "y", "z", and "w" respectively. | |
| 11 */ | |
| 12 abstract class Simd128Float32x4 { | |
| 13 external factory Simd128Float32x4(double x, double y, double z, double w); | |
| 14 external factory Simd128Float32x4.zero(); | |
| 15 | |
| 16 /// Addition operator. | |
| 17 Simd128Float32x4 operator+(Simd128Float32x4 other); | |
|
srdjan
2013/02/21 21:43:25
Space between operator and its name (see int.dart)
Cutch
2013/02/22 03:30:55
Done.
| |
| 18 /// Negate operator. | |
| 19 Simd128Float32x4 operator-(); | |
| 20 /// Subtraction operator. | |
| 21 Simd128Float32x4 operator-(Simd128Float32x4 other); | |
| 22 /// Multiplication operator. | |
| 23 Simd128Float32x4 operator*(Simd128Float32x4 other); | |
| 24 /// Division operator. | |
| 25 Simd128Float32x4 operator/(Simd128Float32x4 other); | |
| 26 | |
| 27 /// Relational less than. | |
| 28 Simd128Mask lessThan(Simd128Float32x4 other); | |
| 29 /// Relational less than or equal. | |
| 30 Simd128Mask lessThanOrEqual(Simd128Float32x4 other); | |
| 31 /// Relational greater than. | |
| 32 Simd128Mask greaterThan(Simd128Float32x4 other); | |
| 33 /// Relational greater than or equal. | |
| 34 Simd128Mask greaterThanOrEqual(Simd128Float32x4 other); | |
| 35 /// Relational equal. | |
| 36 Simd128Mask equal(Simd128Float32x4 other); | |
| 37 /// Relational not-equal. | |
| 38 Simd128Mask notEqual(Simd128Float32x4 other); | |
| 39 | |
| 40 /// Returns a copy of [this] each lane being scaled by [s]. | |
| 41 Simd128Float32x4 scale(double s); | |
| 42 /// Returns the absolute value of this [Simd128Float32]. | |
| 43 Simd128Float32x4 abs(); | |
| 44 /// Clamps [this] to be in the range [lowerLimit]-[upperLimit]. | |
| 45 Simd128Float32x4 clamp(Simd128Float32x4 lowerLimit, | |
| 46 Simd128Float32x4 upperLimit); | |
| 47 | |
| 48 /// Extracted x value. | |
| 49 double get x; | |
| 50 /// Extracted y value. | |
| 51 double get y; | |
| 52 /// Extracted z value. | |
| 53 double get z; | |
| 54 /// Extracted w value. | |
| 55 double get w; | |
| 56 | |
| 57 /// Returns a new [Simd128Float32x4] with [this]' x value in all four lanes. | |
| 58 Simd128Float32x4 get xxxx; | |
| 59 /// Returns a new [Simd128Float32x4] with [this]' y value in all four lanes. | |
| 60 Simd128Float32x4 get yyyy; | |
| 61 /// Returns a new [Simd128Float32x4] with [this]' z value in all four lanes. | |
| 62 Simd128Float32x4 get zzzz; | |
| 63 /// Returns a new [Simd128Float32x4] with [this]' w value in all four lanes. | |
| 64 Simd128Float32x4 get wwww; | |
| 65 // TODO(johnmccutchan): Add all 256 possible combinations. | |
|
srdjan
2013/02/21 21:43:25
What would be better: pass an argument, e.g. a Str
Cutch
2013/02/22 03:30:55
So long as it's a constant at the call site that w
kasperl
2013/02/22 06:38:47
That seems like asking for trouble though. We stil
| |
| 66 | |
| 67 /// Returns a new [Simd128Float32x4] copied from [this] with a new x value. | |
| 68 Simd128Float32x4 withX(double x); | |
| 69 /// Returns a new [Simd128Float32x4] copied from [this] with a new y value. | |
| 70 Simd128Float32x4 withY(double y); | |
| 71 /// Returns a new [Simd128Float32x4] copied from [this] with a new z value. | |
| 72 Simd128Float32x4 withZ(double z); | |
| 73 /// Returns a new [Simd128Float32x4] copied from [this] with a new w value. | |
| 74 Simd128Float32x4 withW(double w); | |
| 75 | |
| 76 /// Returns the lane-wise minimum value in [this] or [other]. | |
| 77 Simd128Float32x4 min(Simd128Float32x4 other); | |
| 78 | |
| 79 /// Returns the lane-wise maximum value in [this] or [other]. | |
| 80 Simd128Float32x4 max(Simd128Float32x4 other); | |
| 81 | |
| 82 /// Returns the square root of [this]. | |
| 83 Simd128Float32x4 sqrt(); | |
| 84 | |
| 85 /// Returns the reciprocal of [this]. | |
| 86 Simd128Float32x4 reciprocal(); | |
| 87 | |
| 88 /// Returns the square root of the reciprocal of [this]. | |
| 89 Simd128Float32x4 reciprocalSqrt(); | |
| 90 | |
| 91 /// Returns a bit-wise copy of [this] as a [Simd128Mask]. | |
| 92 Simd128Mask toSimd128Mask(); | |
| 93 } | |
| 94 | |
| 95 /** | |
| 96 * Interface of Dart Simd128Mask and operations. | |
| 97 * Simd128Mask stores 4 32-bit bit-masks in "lanes". | |
| 98 * The lanes are "x", "y", "z", and "w" respectively. | |
| 99 */ | |
| 100 abstract class Simd128Mask { | |
| 101 external factory Simd128Mask(int x, int y, int z, int w); | |
| 102 external factory Simd128Mask.bool(bool x, bool y, bool z, bool w); | |
| 103 | |
| 104 /// The bit-wise or operator. | |
| 105 Simd128Mask operator|(Simd128Mask other); | |
| 106 /// The bit-wise and operator. | |
| 107 Simd128Mask operator&(Simd128Mask other); | |
| 108 /// The bit-wise xor operator. | |
| 109 Simd128Mask operator^(Simd128Mask other); | |
| 110 | |
| 111 /// Extract 32-bit mask from x lane. | |
| 112 int get x; | |
| 113 /// Extract 32-bit mask from y lane. | |
| 114 int get y; | |
| 115 /// Extract 32-bit mask from z lane. | |
| 116 int get z; | |
| 117 /// Extract 32-bit mask from w lane. | |
| 118 int get w; | |
| 119 | |
| 120 /// Returns a new [Simd128Mask] copied from [this] with a new x value. | |
| 121 Simd128Mask withX(int x); | |
| 122 /// Returns a new [Simd128Mask] copied from [this] with a new y value. | |
| 123 Simd128Mask withY(int y); | |
| 124 /// Returns a new [Simd128Mask] copied from [this] with a new z value. | |
| 125 Simd128Mask withZ(int z); | |
| 126 /// Returns a new [Simd128Mask] copied from [this] with a new w value. | |
| 127 Simd128Mask withW(int w); | |
| 128 | |
| 129 /// Extracted x value. Returns false for 0, true for any other value. | |
| 130 bool get flagX; | |
| 131 /// Extracted y value. Returns false for 0, true for any other value. | |
| 132 bool get flagY; | |
| 133 /// Extracted z value. Returns false for 0, true for any other value. | |
| 134 bool get flagZ; | |
| 135 /// Extracted w value. Returns false for 0, true for any other value. | |
| 136 bool get flagW; | |
| 137 | |
| 138 /// Returns a new [Simd128Mask] copied from [this] with a new x value. | |
| 139 Simd128Mask withFlagX(bool x); | |
| 140 /// Returns a new [Simd128Mask] copied from [this] with a new y value. | |
| 141 Simd128Mask withFlagY(bool y); | |
| 142 /// Returns a new [Simd128Mask] copied from [this] with a new z value. | |
| 143 Simd128Mask withFlagZ(bool z); | |
| 144 /// Returns a new [Simd128Mask] copied from [this] with a new w value. | |
| 145 Simd128Mask withFlagW(bool w); | |
| 146 | |
| 147 /// Merge [trueValue] and [falseValue] based on [this]' bit mask: | |
| 148 /// Select bit from [trueValue] when bit in [this] is on. | |
| 149 /// Select bit from [falseValue] when bit in [this] is off. | |
| 150 Simd128Float32x4 select(Simd128Float32x4 trueValue, | |
| 151 Simd128Float32x4 falseValue); | |
| 152 | |
| 153 /// Returns a bit-wise copy of [this] as a [Simd128Float32x4]. | |
| 154 Simd128Float32x4 toSimd128Float32x4(); | |
| 155 } | |
| 156 | |
| 157 /** | |
| 158 * A fixed-length list of Simd128Float32x4 numbers that is viewable as a | |
| 159 * [ByteArray]. For long lists, this implementation will be considerably more | |
| 160 * space- and time-efficient than the default [List] implementation. | |
| 161 */ | |
| 162 abstract class Simd128Float32x4List implements List<Simd128Float32x4>, | |
| 163 ByteArrayViewable { | |
| 164 /** | |
| 165 * Creates a [Simd128Float32List] of the specified length (in elements), | |
| 166 * all of whose elements are initially zero. | |
| 167 */ | |
| 168 external factory Simd128Float32x4List(int length); | |
| 169 | |
| 170 /** | |
| 171 * Creates a [Simd128Float32x4List] _view_ of the specified region in the | |
| 172 * specified byte [array]. Changes in the [Simd128Float32x4List] will be | |
| 173 * visible in the byte array and vice versa. If the [start] index of the | |
| 174 * region is not specified, it defaults to zero (the first byte in the byte | |
| 175 * array). If the length is not specified, it defaults to null, which | |
| 176 * indicates that the view extends to the end of the byte array. | |
| 177 * | |
| 178 * Throws [ArgumentError] if the length of the specified region is not | |
| 179 * divisible by 16 (the size of a "Simd128Float32x4" in bytes), or if the | |
| 180 * [start] of the region is not divisible by 16. If, however, [array] is a | |
| 181 * view of another byte array, this constructor will throw [ArgumentError] | |
| 182 * if the implicit starting position in the "ultimately backing" byte array | |
| 183 * is not divisible by 16. In plain terms, this constructor throws | |
| 184 * [ArgumentError] if the specified region does not contain an integral | |
| 185 * number of "Simd128Float32x4s," or if it is not "Simd128Float32x4-aligned." | |
| 186 */ | |
| 187 external factory Simd128Float32x4List.view(ByteArray array, | |
| 188 [int start = 0, int length]); | |
| 189 } | |
| OLD | NEW |