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 Float32x4 and operations. |
| 9 * Float32x4 stores 4 32-bit floating point values in "lanes". |
| 10 * The lanes are "x", "y", "z", and "w" respectively. |
| 11 */ |
| 12 abstract class Float32x4 { |
| 13 external factory Float32x4(double x, double y, double z, double w); |
| 14 external factory Float32x4.zero(); |
| 15 |
| 16 /// Addition operator. |
| 17 Float32x4 operator+(Float32x4 other); |
| 18 /// Negate operator. |
| 19 Float32x4 operator-(); |
| 20 /// Subtraction operator. |
| 21 Float32x4 operator-(Float32x4 other); |
| 22 /// Multiplication operator. |
| 23 Float32x4 operator*(Float32x4 other); |
| 24 /// Division operator. |
| 25 Float32x4 operator/(Float32x4 other); |
| 26 |
| 27 /// Relational less than. |
| 28 Uint32x4 lessThan(Float32x4 other); |
| 29 /// Relational less than or equal. |
| 30 Uint32x4 lessThanOrEqual(Float32x4 other); |
| 31 /// Relational greater than. |
| 32 Uint32x4 greaterThan(Float32x4 other); |
| 33 /// Relational greater than or equal. |
| 34 Uint32x4 greaterThanOrEqual(Float32x4 other); |
| 35 /// Relational equal. |
| 36 Uint32x4 equal(Float32x4 other); |
| 37 /// Relational not-equal. |
| 38 Uint32x4 notEqual(Float32x4 other); |
| 39 |
| 40 /// Returns a copy of [this] each lane being scaled by [s]. |
| 41 Float32x4 scale(double s); |
| 42 /// Returns the absolute value of this [Simd128Float32]. |
| 43 Float32x4 abs(); |
| 44 /// Clamps [this] to be in the range [lowerLimit]-[upperLimit]. |
| 45 Float32x4 clamp(Float32x4 lowerLimit, |
| 46 Float32x4 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 [Float32x4] with [this]' x value in all four lanes. |
| 58 Float32x4 get xxxx; |
| 59 /// Returns a new [Float32x4] with [this]' y value in all four lanes. |
| 60 Float32x4 get yyyy; |
| 61 /// Returns a new [Float32x4] with [this]' z value in all four lanes. |
| 62 Float32x4 get zzzz; |
| 63 /// Returns a new [Float32x4] with [this]' w value in all four lanes. |
| 64 Float32x4 get wwww; |
| 65 // TODO(johnmccutchan): Add all 256 possible combinations. |
| 66 |
| 67 /// Returns a new [Float32x4] copied from [this] with a new x value. |
| 68 Float32x4 withX(double x); |
| 69 /// Returns a new [Float32x4] copied from [this] with a new y value. |
| 70 Float32x4 withY(double y); |
| 71 /// Returns a new [Float32x4] copied from [this] with a new z value. |
| 72 Float32x4 withZ(double z); |
| 73 /// Returns a new [Float32x4] copied from [this] with a new w value. |
| 74 Float32x4 withW(double w); |
| 75 |
| 76 /// Returns the lane-wise minimum value in [this] or [other]. |
| 77 Float32x4 min(Float32x4 other); |
| 78 |
| 79 /// Returns the lane-wise maximum value in [this] or [other]. |
| 80 Float32x4 max(Float32x4 other); |
| 81 |
| 82 /// Returns the square root of [this]. |
| 83 Float32x4 sqrt(); |
| 84 |
| 85 /// Returns the reciprocal of [this]. |
| 86 Float32x4 reciprocal(); |
| 87 |
| 88 /// Returns the square root of the reciprocal of [this]. |
| 89 Float32x4 reciprocalSqrt(); |
| 90 |
| 91 /// Returns a bit-wise copy of [this] as a [Uint32x4]. |
| 92 Uint32x4 toUint32x4(); |
| 93 } |
| 94 |
| 95 /** |
| 96 * Interface of Dart Uint32x4 and operations. |
| 97 * Uint32x4 stores 4 32-bit bit-masks in "lanes". |
| 98 * The lanes are "x", "y", "z", and "w" respectively. |
| 99 */ |
| 100 abstract class Uint32x4 { |
| 101 external factory Uint32x4(int x, int y, int z, int w); |
| 102 external factory Uint32x4.bool(bool x, bool y, bool z, bool w); |
| 103 |
| 104 /// The bit-wise or operator. |
| 105 Uint32x4 operator|(Uint32x4 other); |
| 106 /// The bit-wise and operator. |
| 107 Uint32x4 operator&(Uint32x4 other); |
| 108 /// The bit-wise xor operator. |
| 109 Uint32x4 operator^(Uint32x4 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 [Uint32x4] copied from [this] with a new x value. |
| 121 Uint32x4 withX(int x); |
| 122 /// Returns a new [Uint32x4] copied from [this] with a new y value. |
| 123 Uint32x4 withY(int y); |
| 124 /// Returns a new [Uint32x4] copied from [this] with a new z value. |
| 125 Uint32x4 withZ(int z); |
| 126 /// Returns a new [Uint32x4] copied from [this] with a new w value. |
| 127 Uint32x4 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 [Uint32x4] copied from [this] with a new x value. |
| 139 Uint32x4 withFlagX(bool x); |
| 140 /// Returns a new [Uint32x4] copied from [this] with a new y value. |
| 141 Uint32x4 withFlagY(bool y); |
| 142 /// Returns a new [Uint32x4] copied from [this] with a new z value. |
| 143 Uint32x4 withFlagZ(bool z); |
| 144 /// Returns a new [Uint32x4] copied from [this] with a new w value. |
| 145 Uint32x4 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 Float32x4 select(Float32x4 trueValue, |
| 151 Float32x4 falseValue); |
| 152 |
| 153 /// Returns a bit-wise copy of [this] as a [Float32x4]. |
| 154 Float32x4 toFloat32x4(); |
| 155 } |
| 156 |
| 157 /** |
| 158 * A fixed-length list of Float32x4 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 Float32x4List implements List<Float32x4>, |
| 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 Float32x4List(int length); |
| 169 |
| 170 /** |
| 171 * Creates a [Float32x4List] _view_ of the specified region in the |
| 172 * specified byte [array]. Changes in the [Float32x4List] 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 "Float32x4" 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 "Float32x4s," or if it is not "Float32x4-aligned." |
| 186 */ |
| 187 external factory Float32x4List.view(ByteArray array, |
| 188 [int start = 0, int length]); |
| 189 } |
OLD | NEW |