Contents

# 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.
Standard Arithmetic Operators
Operation
Operators
Generic Syntax
+
+=
R = A + B;
R += A;
Subtraction
-
-=
R = A - B;
R -= A;
Multiplication
*
*=
R = A * B;
R *= A;
Division
/
/=
R = A / B;
R /= A;
Operation
Operators
Generic Syntax
Square Root
sqrt
R = sqrt(A);
Reciprocal
(Newton-Raphson)
rcp
rcp_nr
R = rcp(A);
R = rcp_nr(A);
Reciprocal Square Root
(Newton-Raphson)
rsqrt
rsqrt_nr
R = rsqrt(A);
R = rsqrt_nr(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
Standard Arithmetic Operations for Fvec Classes
This table lists standard arithmetic operator syntax and intrinsics.
Operation
Returns
Example Syntax Usage
Intrinsic

4 floats
F32vec4 R = F32vec4 A + F32vec4 B;
F32vec4 R += F32vec4 A;
2 doubles
F64vec2 R = F64vec2 A + F32vec2 B;
F64vec2 R += F64vec2 A;
1 float
F32vec1 R = F32vec1 A + F32vec1 B;
F32vec1 R += F32vec1 A;
Subtraction

4 floats
F32vec4 R = F32vec4 A - F32vec4 B;
F32vec4 R -= F32vec4 A;
_mm_sub_ps
2 doubles
F64vec2 R - F64vec2 A + F32vec2 B;
F64vec2 R -= F64vec2 A;
_mm_sub_pd
1 float
F32vec1 R = F32vec1 A - F32vec1 B;
F32vec1 R -= F32vec1 A;
_mm_sub_ss
Multiplication

4 floats
F32vec4 R = F32vec4 A * F32vec4 B;
F32vec4 R *= F32vec4 A;
_mm_mul_ps
2 doubles
F64vec2 R = F64vec2 A * F364vec2 B;
F64vec2 R *= F64vec2 A;
_mm_mul_pd
1 float
F32vec1 R = F32vec1 A * F32vec1 B;
F32vec1 R *= F32vec1 A;
_mm_mul_ss
Division

4 floats
F32vec4 R = F32vec4 A / F32vec4 B;
F32vec4 R /= F32vec4 A;
_mm_div_ps
2 doubles
F64vec2 R = F64vec2 A / F64vec2 B;
F64vec2 R /= F64vec2 A;
_mm_div_pd
1 float
F32vec1 R = F32vec1 A / F32vec1 B;
F32vec1 R /= F32vec1 A;
_mm_div_ss

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.
R
Operators
A
F32vec4
F64vec2
F32vec1
R0:=
sqrt
rcp
rsqrt
rcp_nr
rsqrt_nr
A0
X
R1:=
sqrt
rcp
rsqrt
rcp_nr
rsqrt_nr
A1
N/A
R2:=
sqrt
rcp
rsqrt
rcp_nr
rsqrt_nr
A2
N/A
N/A
R3:=
sqrt
rcp
rsqrt
rcp_nr
rsqrt_nr
A3
N/A
N/A
f :=

(A0 + A1 + A2 + A3)

N/A
N/A
d :=

(A0 + A1)

N/A
N/A
Advanced Arithmetic Operations for Fvec Classes
The following table show examples for advanced arithmetic operators.
Operation
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
_mm_mul_ps
_mm_rcp_ps
2 doubles
F64vec2 R = rcp_nr(F64vec2 A);
_mm_sub_pd
_mm_mul_pd
_mm_rcp_pd
1 float
F32vec1 R = rcp_nr(F32vec1 A);
_mm_sub_ss
_mm_mul_ss
_mm_rcp_ss
Reciprocal Square Root Newton Raphson
4 float
F32vec4 R = rsqrt_nr(F32vec4 A);
_mm_sub_pd
_mm_mul_pd
_mm_rsqrt_ps
2 doubles
F64vec2 R = rsqrt_nr(F64vec2 A);
_mm_sub_pd
_mm_mul_pd
_mm_rsqrt_pd
1 float
F32vec1 R = rsqrt_nr(F32vec1 A);
_mm_sub_ss
_mm_mul_ss
_mm_rsqrt_ss
1 float