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. | |
kasperl
2013/02/21 11:28:15
Are these comments (addition operator, etc.) reall
Cutch
2013/02/21 18:45:16
Probably not. I copied these comments from double.
| |
17 Simd128Float32x4 operator+(Simd128Float32x4 other); | |
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); | |
kasperl
2013/02/21 11:28:15
Maybe get rid of 'Than' and 'ThanOr' to make these
Cutch
2013/02/21 18:45:16
I think maskLess and maskGreaterEqual reads better
| |
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. | |
kasperl
2013/02/21 11:28:15
Is that the plan? Maybe that is the right thing. T
Cutch
2013/02/21 18:45:16
Yep.
| |
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(Simd128 other); | |
kasperl
2013/02/21 11:28:15
What's the type of other supposed to be for min an
Cutch
2013/02/21 18:45:16
Typo, it should be Simd128Float32x4 and this is no
| |
78 | |
79 /// Returns the lane-wise maximum value in [this] or [other]. | |
80 Simd128Float32x4 max(Simd128 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 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, Simd128Float32x4 falseValu e); | |
kasperl
2013/02/21 11:28:15
Long line.
Cutch
2013/02/21 18:45:16
Done.
| |
151 | |
152 /// Returns a bit-wise of [this] as a [Simd128Float32x4]. | |
kasperl
2013/02/21 11:28:15
bit-wise what? copy?
Cutch
2013/02/21 18:45:16
copy and Done.
| |
153 Simd128Float32x4 toSimd128Float32x4(); | |
154 } | |
155 | |
156 /** | |
157 * A fixed-length list of Simd128Float32x4 numbers that is viewable as a | |
158 * [ByteArray]. For long lists, this | |
kasperl
2013/02/21 11:28:15
reflow
Cutch
2013/02/21 18:45:16
Done.
| |
159 * implementation will be considerably more space- and time-efficient than | |
160 * the default [List] implementation. | |
161 */ | |
162 abstract class Simd128Float32x4List implements List<Simd128Float32x4>, | |
kasperl
2013/02/21 11:28:15
Maybe just get rid of the Float32x4 part? Simd128L
Cutch
2013/02/21 18:45:16
I'm starting to think Float32x4List but I'm not su
| |
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 [Simd128Float32List] _view_ of the specified region in the | |
172 * specified byte [array]. Changes in the [Simd128Float32List] will be visible | |
173 * in the byte array and vice versa. If the [start] index of the region is | |
174 * not specified, | |
kasperl
2013/02/21 11:28:15
reflow
Cutch
2013/02/21 18:45:16
Done.
| |
175 * it defaults to zero (the first byte in the byte array). If the length is | |
176 * not specified, it defaults to null, which indicates that the view extends | |
177 * to the end of the byte array. | |
178 * | |
179 * Throws [ArgumentError] if the length of the specified region | |
180 * is not divisible by 16 (the size of a "Simd128Float32" in bytes), or if the | |
181 * [start] of the region is not divisible by 16. If, however, [array] | |
182 * is a view of another byte array, this constructor will throw | |
183 * [ArgumentError] if the implicit starting position in the | |
184 * "ultimately backing" byte array is not divisible by 16. In plain terms, | |
185 * this constructor throws [ArgumentError] if the specified | |
186 * region does not contain an integral number of "Simd128Float32s," or if it | |
187 * is not "Simd128Float32-aligned." | |
188 */ | |
189 external factory Simd128Float32x4List.view(ByteArray array, | |
190 [int start = 0, int length]); | |
191 } | |
OLD | NEW |