Visible to Intel only — GUID: GUID-F390FEC4-9F7C-4779-AD6C-6CA40CF49CE2
Visible to Intel only — GUID: GUID-F390FEC4-9F7C-4779-AD6C-6CA40CF49CE2
Arithmetic Operators
The following table lists the arithmetic operators of the Fvec classes and generic syntax. The operators have been divided into standard and advanced operations, which are described in more detail later in this section.
Fvec Arithmetic Operators
Category |
Operation |
Operators |
Generic Syntax |
---|---|---|---|
Standard |
Addition |
+ |
R = A + B; |
|
Subtraction |
- |
R = A - B; |
|
Multiplication |
* |
R = A * B; |
|
Division |
/ |
R = A / B; |
Advanced |
Square Root |
sqrt |
R = sqrt(A); |
|
Reciprocal |
rcp |
R = rcp(A); |
|
Reciprocal Square Root |
rsqrt |
R = rsqrt(A); |
Standard Arithmetic Operator Usage
The following two tables show the return values for each class of the standard arithmetic operators, which use the syntax styles described earlier in the Return Value Notation section.
Standard Arithmetic Return Value Mapping
R | A | Operators | B | F32vec4 | F64vec2 | F32vec1 | |||
---|---|---|---|---|---|---|---|---|---|
R0:= |
A0 |
+ |
- |
* |
/ |
B0 |
X |
X |
X |
R1:= |
A1 |
+ |
- |
* |
/ |
B1 |
X |
X |
N/A |
R2:= |
A2 |
+ |
- |
* |
/ |
B2 |
X |
N/A |
N/A |
R3:= |
A3 |
+ |
- |
* |
/ |
B3 |
X |
N/A |
N/A |
Arithmetic with Assignment Return Value Mapping
R | Operators | A | F32vec4 | F64vec2 | F32vec1 | |||
---|---|---|---|---|---|---|---|---|
R0:= |
+= |
-= |
*= |
/= |
A0 |
X |
X |
X |
R1:= |
+= |
-= |
*= |
/= |
A1 |
X |
X |
N/A |
R2:= |
+= |
-= |
*= |
/= |
A2 |
X |
N/A |
N/A |
R3:= |
+= |
-= |
*= |
/= |
A3 |
X |
N/A |
N/A |
This table lists standard arithmetic operator syntax and intrinsics.
Standard Arithmetic Operations for Fvec Classes
Operation |
Returns |
Example Syntax Usage |
Intrinsic |
---|---|---|---|
Addition |
4 floats |
F32vec4 R = F32vec4 A + F32vec4 B; |
_mm_add_ps |
|
2 doubles |
F64vec2 R = F64vec2 A + F32vec2 B; |
_mm_add_pd |
|
1 float |
F32vec1 R = F32vec1 A + F32vec1 B; |
_mm_add_ss |
Subtraction |
4 floats |
F32vec4 R = F32vec4 A - F32vec4 B; |
_mm_sub_ps |
|
2 doubles |
F64vec2 R - F64vec2 A + F32vec2 B; |
_mm_sub_pd |
|
1 float |
F32vec1 R = F32vec1 A - F32vec1 B; |
_mm_sub_ss |
Multiplication |
4 floats |
F32vec4 R = F32vec4 A * F32vec4 B; |
_mm_mul_ps |
|
2 doubles |
F64vec2 R = F64vec2 A * F364vec2 B; |
_mm_mul_pd |
|
1 float |
F32vec1 R = F32vec1 A * F32vec1 B; |
_mm_mul_ss |
Division |
4 floats |
F32vec4 R = F32vec4 A / F32vec4 B; |
_mm_div_ps |
|
2 doubles |
F64vec2 R = F64vec2 A / F64vec2 B; |
_mm_div_pd |
|
1 float |
F32vec1 R = F32vec1 A / F32vec1 B; |
_mm_div_ss |
Advanced Arithmetic Operator Usage
The following table shows the return values classes of the advanced arithmetic operators, which use the syntax styles described earlier in the Return Value Notation section.
Advanced Arithmetic Return Value Mapping
R | Operators | A | F32vec4 | F64vec2 | F32vec1 | ||||
---|---|---|---|---|---|---|---|---|---|
R0:= |
sqrt |
rcp |
rsqrt |
rcp_nr |
rsqrt_nr |
A0 |
X |
X |
X |
R1:= |
sqrt |
rcp |
rsqrt |
rcp_nr |
rsqrt_nr |
A1 |
X |
X |
N/A |
R2:= |
sqrt |
rcp |
rsqrt |
rcp_nr |
rsqrt_nr |
A2 |
X |
N/A |
N/A |
R3:= |
sqrt |
rcp |
rsqrt |
rcp_nr |
rsqrt_nr |
A3 |
X |
N/A |
N/A |
f := |
add_horizontal |
|
|
(A0 + A1 + A2 + A3) |
|
|
X |
N/A |
N/A |
d := |
add_horizontal |
|
|
(A0 + A1) |
|
|
N/A |
X |
N/A |
This table shows examples for advanced arithmetic operators.
Advanced Arithmetic Operations for Fvec Classes
Returns |
Example Syntax Usage |
Intrinsic |
---|---|---|
Square Root | ||
4 floats |
F32vec4 R = sqrt(F32vec4 A); |
_mm_sqrt_ps |
2 doubles |
F64vec2 R = sqrt(F64vec2 A); |
_mm_sqrt_pd |
1 float |
F32vec1 R = sqrt(F32vec1 A); |
_mm_sqrt_ss |
Reciprocal | ||
---|---|---|
4 floats |
F32vec4 R = rcp(F32vec4 A); |
_mm_rcp_ps |
2 doubles |
F64vec2 R = rcp(F64vec2 A); |
_mm_rcp_pd |
1 float |
F32vec1 R = rcp(F32vec1 A); |
_mm_rcp_ss |
Reciprocal Square Root | ||
---|---|---|
4 floats |
F32vec4 R = rsqrt(F32vec4 A); |
_mm_rsqrt_ps |
2 doubles |
F64vec2 R = rsqrt(F64vec2 A); |
_mm_rsqrt_pd |
1 float |
F32vec1 R = rsqrt(F32vec1 A); |
_mm_rsqrt_ss |
Reciprocal Newton Raphson | ||
---|---|---|
4 floats |
F32vec4 R = rcp_nr(F32vec4 A); |
_mm_sub_ps |
2 doubles |
F64vec2 R = rcp_nr(F64vec2 A); |
_mm_sub_pd |
1 float |
F32vec1 R = rcp_nr(F32vec1 A); |
_mm_sub_ss |
Reciprocal Square Root Newton Raphson | ||
---|---|---|
4 float |
F32vec4 R = rsqrt_nr(F32vec4 A); |
_mm_sub_pd |
2 doubles |
F64vec2 R = rsqrt_nr(F64vec2 A); |
_mm_sub_pd |
1 float |
F32vec1 R = rsqrt_nr(F32vec1 A); |
_mm_sub_ss |
Horizontal Add | ||
---|---|---|
1 float |
float f = add_horizontal(F32vec4 A); |
_mm_add_ss |
1 double |
double d = add_horizontal(F64vec2 A); |
_mm_add_sd |