Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix Issue 10445 - add .min, .max, etc. properties for vector types
- Loading branch information
1 parent
cce47a2
commit ff88025
Showing
3 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Add .min, .max, etc. properties for vector types. | ||
|
||
For integral vector types, add the `.min` and `.max` properties. | ||
|
||
For floating point vector types, add the `.min`, `.max`, `.min_normal`, | ||
`.nan`, `.infinity`, and `.epsilon` properties. | ||
|
||
The value of those properties is the value corresponsing to the vector | ||
element type broadcast to the vector type. I.e.: | ||
|
||
--- | ||
import core.simd; | ||
|
||
static assert(float4.max == cast(float4)float.max); | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
*/ | ||
|
||
import core.simd; | ||
|
||
int main() | ||
{ | ||
version (D_SIMD) | ||
{ | ||
{ | ||
auto m = ubyte16.max; | ||
auto n = cast(ubyte16)ubyte.max; | ||
assert(m.array == n.array); | ||
} | ||
|
||
{ | ||
auto m = ubyte16.min; | ||
auto n = cast(ubyte16)ubyte.min; | ||
assert(m.array == n.array); | ||
} | ||
|
||
{ | ||
auto m = float4.max; | ||
auto n = cast(float4)float.max; | ||
assert(m.array == n.array); | ||
} | ||
|
||
{ | ||
auto m = float4.min_normal; | ||
auto n = cast(float4)float.min_normal; | ||
assert(m.array == n.array); | ||
} | ||
|
||
{ | ||
auto m = float4.epsilon; | ||
auto n = cast(float4)float.epsilon; | ||
assert(m.array == n.array); | ||
} | ||
|
||
{ | ||
auto m = float4.infinity; | ||
auto n = cast(float4)float.infinity; | ||
assert(m.array == n.array); | ||
} | ||
|
||
{ | ||
auto m = float4.nan; | ||
auto n = cast(float4)float.nan; | ||
assert(m.array != n.array); | ||
} | ||
} | ||
return 0; | ||
} |