| 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, Float32x4 falseValue); | |
| 151 | |
| 152 /// Returns a bit-wise copy of [this] as a [Float32x4]. | |
| 153 Float32x4 toFloat32x4(); | |
| 154 } | |
| 155 | |
| 156 /** | |
| 157 * A fixed-length list of Float32x4 numbers that is viewable as a | |
| 158 * [ByteArray]. For long lists, this implementation will be considerably more | |
| 159 * space- and time-efficient than the default [List] implementation. | |
| 160 */ | |
| 161 abstract class Float32x4List implements List<Float32x4>, | |
| 162 ByteArrayViewable { | |
| 163 /** | |
| 164 * Creates a [Simd128Float32List] of the specified length (in elements), | |
| 165 * all of whose elements are initially zero. | |
| 166 */ | |
| 167 external factory Float32x4List(int length); | |
| 168 | |
| 169 /** | |
| 170 * Creates a [Float32x4List] _view_ of the specified region in the | |
| 171 * specified byte [array]. Changes in the [Float32x4List] will be | |
| 172 * visible in the byte array and vice versa. If the [start] index of the | |
| 173 * region is not specified, it defaults to zero (the first byte in the byte | |
| 174 * array). If the length is not specified, it defaults to null, which | |
| 175 * indicates that the view extends to the end of the byte array. | |
| 176 * | |
| 177 * Throws [ArgumentError] if the length of the specified region is not | |
| 178 * divisible by 16 (the size of a "Float32x4" in bytes), or if the | |
| 179 * [start] of the region is not divisible by 16. If, however, [array] is a | |
| 180 * view of another byte array, this constructor will throw [ArgumentError] | |
| 181 * if the implicit starting position in the "ultimately backing" byte array | |
| 182 * is not divisible by 16. In plain terms, this constructor throws | |
| 183 * [ArgumentError] if the specified region does not contain an integral | |
| 184 * number of "Float32x4s," or if it is not "Float32x4-aligned." | |
| 185 */ | |
| 186 external factory Float32x4List.view(ByteArray array, | |
| 187 [int start = 0, int length]); | |
| 188 } | |
| OLD | NEW |