nlib
nn::nlib::simd::Vector4 Class Reference

The class with the collection of functions that perform calculations on four-dimensional vectors. More...

#include "nn/nlib/simd/SimdVector4.h"

Static Public Member Functions

static bool IsNaN (SimdVectorArg vec) noexcept
 Evaluates whether any of the elements of vec are NaN. More...
 
static bool IsInfinite (SimdVectorArg vec) noexcept
 Evaluates whether any of the elements of vec are positive infinity or negative infinity. More...
 
static bool InBound (SimdVectorArg vec, SimdVectorArg bounds) noexcept
 Evaluates whether the elements of vec are inside the bounds of bounds. More...
 
static f128 Dot (SimdVectorArg vec1, SimdVectorArg vec2) noexcept
 Calculates the dot product between four-dimensional vectors. More...
 
template<bool SetLane0, bool SetLane1, bool SetLane2, bool SetLane3>
static f128 DotEx (SimdVectorArg vec1, SimdVectorArg vec2) noexcept
 Calculates the dot product between two four-dimensional vectors and sets the value in the various lanes. More...
 
static f128 Dot2 (SimdVectorArg a, SimdVectorArg b0, SimdVectorArg b1) noexcept
 Calculates the dot products dot(a, b0) and dot(a, b1) between four-dimensional vectors and sets the results in lane 0 and lane 1. More...
 
static f128 Dot3 (SimdVectorArg a, SimdVectorArg b0, SimdVectorArg b1, SimdVectorArg b2) noexcept
 Calculates the dot products dot(a, b0), dot(a, b1), and dot(a, b2) between four-dimensional vectors and sets the results in lanes 0, 1, and 2. More...
 
static f128 Dot4 (SimdVectorArg a, SimdVectorArg b0, SimdVectorArg b1, SimdVectorArg b2, SimdVectorArg b3) noexcept
 Calculates the dot products dot(a, b0), dot(a, b1), dot(a, b2), and dot(a, b3) between four-dimensional vectors and sets the results in lanes 0, 1, 2, and 3. More...
 
static SimdVector Normalize (SimdVectorArg vec) noexcept
 Normalizes a four-dimensional vector. More...
 
static SimdVector NormalizeEst (SimdVectorArg vec) noexcept
 Normalizes a four-dimensional vector with relatively low precision. More...
 
static f128 LengthSq (SimdVectorArg vec) noexcept
 Calculates the square of the length of a four-dimensional vector. More...
 
static f128 Length (SimdVectorArg vec) noexcept
 Calculates the length of a four-dimensional vector. More...
 
static f128 LengthEst (SimdVectorArg vec) noexcept
 Calculates the length of a four-dimensional vector with relatively low precision. More...
 
static f128 RecpLength (SimdVectorArg vec) noexcept
 Calculates the reciprocal of the length of a four-dimensional vector. More...
 
static f128 RecpLengthEst (SimdVectorArg vec) noexcept
 Calculates the reciprocal of the length of a four-dimensional vector with relatively low precision. More...
 
static f128 GetAngle (SimdVectorArg vec1_normalized, SimdVectorArg vec2_normalized) noexcept
 Calculates the angle (in radians) between two normalized four-dimensional vectors. More...
 
static SimdVector Reflect (SimdVectorArg vec, SimdVectorArg normal) noexcept
 Reflects a four-dimensional vector using a four-dimensional normal vector. More...
 
static SimdVector Transform (SimdVectorArg vec, SimdMatrixArg m) noexcept
 Transforms a four-dimensional vector using a matrix. More...
 
Loading and Storing
template<typename MyVector4 >
static SimdVector LoadFloat4 (const MyVector4 *p) noexcept
 Loads a four-dimensional vector from memory. More...
 
template<typename MyVector4 >
static void StoreFloat4 (MyVector4 *p, SimdVectorArg vec) noexcept
 Writes a four-dimensional vector to memory. More...
 
Comparisons
static bool CmpEq (SimdVectorArg vec1, SimdVectorArg vec2) noexcept
 Compares two four-dimensional vectors to see if they are equal. More...
 
static bool CmpLt (SimdVectorArg vec1, SimdVectorArg vec2) noexcept
 Checks to see whether all of the elements of vec1 are smaller than the corresponding elements of vec2. More...
 
static bool CmpLe (SimdVectorArg vec1, SimdVectorArg vec2) noexcept
 Checks to see whether all of the elements of vec1 are equal or less than the corresponding elements of vec2. More...
 
static bool CmpGt (SimdVectorArg vec1, SimdVectorArg vec2) noexcept
 Checks to see whether all of the elements of vec1 are larger than the corresponding elements of vec2. More...
 
static bool CmpGe (SimdVectorArg vec1, SimdVectorArg vec2) noexcept
 Checks to see whether all of the elements of vec1 are equal or greater than the corresponding elements of vec2. More...
 
static bool CmpNe (SimdVectorArg vec1, SimdVectorArg vec2) noexcept
 Compares vec1 and vec2 to see whether they are unequal. More...
 
static bool CmpNearEq (SimdVectorArg vec1, SimdVectorArg vec2, SimdVectorArg eps) noexcept
 Compares vec1 and vec2 to see whether they are nearly equal. More...
 

Detailed Description

The class with the collection of functions that perform calculations on four-dimensional vectors.

Description
In some cases, you can use the functions implemented in the F128 class to perform independent calculations on separate elements.
The class can be used even in environments that do not support SSE or NEON, but with suboptimal performance.
All members of this class are static functions. The class cannot be instantiated.

Definition at line 24 of file SimdVector4.h.

Member Function Documentation

◆ CmpEq()

nn::nlib::simd::Vector4::CmpEq ( SimdVectorArg  vec1,
SimdVectorArg  vec2 
)
inlinestaticnoexcept

Compares two four-dimensional vectors to see if they are equal.

Parameters
[in]vec1A four-dimensional vector.
[in]vec2A four-dimensional vector.
Returns
Returns true if the vector elements are the same, and false otherwise.

Definition at line 30 of file SimdVector4.h.

◆ CmpGe()

nn::nlib::simd::Vector4::CmpGe ( SimdVectorArg  vec1,
SimdVectorArg  vec2 
)
inlinestaticnoexcept

Checks to see whether all of the elements of vec1 are equal or greater than the corresponding elements of vec2.

Parameters
[in]vec1A four-dimensional vector.
[in]vec2A four-dimensional vector.
Returns
Returns true if vec1 is equal or greater than vec2, and false otherwise.

Definition at line 42 of file SimdVector4.h.

◆ CmpGt()

nn::nlib::simd::Vector4::CmpGt ( SimdVectorArg  vec1,
SimdVectorArg  vec2 
)
inlinestaticnoexcept

Checks to see whether all of the elements of vec1 are larger than the corresponding elements of vec2.

Parameters
[in]vec1A four-dimensional vector.
[in]vec2A four-dimensional vector.
Returns
Returns true if vec1 is smaller than vec2, and false otherwise.

Definition at line 39 of file SimdVector4.h.

◆ CmpLe()

nn::nlib::simd::Vector4::CmpLe ( SimdVectorArg  vec1,
SimdVectorArg  vec2 
)
inlinestaticnoexcept

Checks to see whether all of the elements of vec1 are equal or less than the corresponding elements of vec2.

Parameters
[in]vec1A four-dimensional vector.
[in]vec2A four-dimensional vector.
Returns
Returns true if vec1 is equal or less than vec2, and false otherwise.

Definition at line 36 of file SimdVector4.h.

◆ CmpLt()

nn::nlib::simd::Vector4::CmpLt ( SimdVectorArg  vec1,
SimdVectorArg  vec2 
)
inlinestaticnoexcept

Checks to see whether all of the elements of vec1 are smaller than the corresponding elements of vec2.

Parameters
[in]vec1A four-dimensional vector.
[in]vec2A four-dimensional vector.
Returns
Returns true if vec1 is smaller than vec2, and false otherwise.

Definition at line 33 of file SimdVector4.h.

◆ CmpNe()

nn::nlib::simd::Vector4::CmpNe ( SimdVectorArg  vec1,
SimdVectorArg  vec2 
)
inlinestaticnoexcept

Compares vec1 and vec2 to see whether they are unequal.

Parameters
[in]vec1A four-dimensional vector.
[in]vec2A four-dimensional vector.
Returns
Returns true if vec1 is not equal to vec2, and false otherwise.

Definition at line 45 of file SimdVector4.h.

◆ CmpNearEq()

nn::nlib::simd::Vector4::CmpNearEq ( SimdVectorArg  vec1,
SimdVectorArg  vec2,
SimdVectorArg  eps 
)
inlinestaticnoexcept

Compares vec1 and vec2 to see whether they are nearly equal.

Parameters
[in]vec1A four-dimensional vector.
[in]vec2A four-dimensional vector.
[in]epsA tolerance value.
Returns
Returns true if vec1 is nearly equal to vec2, and false otherwise.
Description
The process is similar to the following.
return abs(vec1[0] - vec2[0]) <= eps[0] &&
abs(vec1[1] - vec2[1]) <= eps[1] &&
abs(vec1[2] - vec2[2]) <= eps[2] &&
abs(vec1[3] - vec2[3]) <= eps[3];

Definition at line 49 of file SimdVector4.h.

◆ Dot()

nn::nlib::simd::Vector4::Dot ( SimdVectorArg  vec1,
SimdVectorArg  vec2 
)
staticnoexcept

Calculates the dot product between four-dimensional vectors.

Parameters
[in]vec1A four-dimensional vector.
[in]vec2A four-dimensional vector.
Returns
Stores the dot product in each lane.

◆ Dot2()

nn::nlib::simd::Vector4::Dot2 ( SimdVectorArg  a,
SimdVectorArg  b0,
SimdVectorArg  b1 
)
staticnoexcept

Calculates the dot products dot(a, b0) and dot(a, b1) between four-dimensional vectors and sets the results in lane 0 and lane 1.

Parameters
[in]aA four-dimensional vector.
[in]b0A four-dimensional vector.
[in]b1A four-dimensional vector.
Returns
The result of dot(a, b0) is stored in lane 0, and the result of dot(a, b1) is stored in lane 1.

◆ Dot3()

nn::nlib::simd::Vector4::Dot3 ( SimdVectorArg  a,
SimdVectorArg  b0,
SimdVectorArg  b1,
SimdVectorArg  b2 
)
staticnoexcept

Calculates the dot products dot(a, b0), dot(a, b1), and dot(a, b2) between four-dimensional vectors and sets the results in lanes 0, 1, and 2.

Parameters
[in]aA four-dimensional vector.
[in]b0A four-dimensional vector.
[in]b1A four-dimensional vector.
[in]b2A four-dimensional vector.
Returns
The result of dot(a, b0) is stored in lane 0, the result of dot(a, b1) is stored in lane 1, and the result of dot(a, b2) is stored in lane 2.

◆ Dot4()

nn::nlib::simd::Vector4::Dot4 ( SimdVectorArg  a,
SimdVectorArg  b0,
SimdVectorArg  b1,
SimdVectorArg  b2,
SimdVectorArg  b3 
)
staticnoexcept

Calculates the dot products dot(a, b0), dot(a, b1), dot(a, b2), and dot(a, b3) between four-dimensional vectors and sets the results in lanes 0, 1, 2, and 3.

Parameters
[in]aA four-dimensional vector.
[in]b0A four-dimensional vector.
[in]b1A four-dimensional vector.
[in]b2A four-dimensional vector.
[in]b3A four-dimensional vector.
Returns
The result of dot(a, b0) is stored in lane 0, the result of dot(a, b1) is stored in lane 1, the result of dot(a, b2) is stored in lane 2, and the result of dot(a, b3) is stored in lane 3.

◆ DotEx()

template<bool SetLane0, bool SetLane1, bool SetLane2, bool SetLane3>
nn::nlib::simd::Vector4::DotEx ( SimdVectorArg  vec1,
SimdVectorArg  vec2 
)
staticnoexcept

Calculates the dot product between two four-dimensional vectors and sets the value in the various lanes.

Template Parameters
SetLane0Specify true to store the dot product in lane 0, or false to store 0.f.
SetLane1Specify true to store the dot product in lane 1, or false to store 0.f.
SetLane2Specify true to store the dot product in lane 2, or false to store 0.f.
SetLane3Specify true to store the dot product in lane 3, or false to store 0.f.
Parameters
[in]vec1A four-dimensional vector.
[in]vec2A four-dimensional vector.
Returns
Depending on the values specified for the template parameters, either the dot product or 0.f is stored in each element.
Description
Performs processes similar to those shown in the following pseudocode.
float dot = vec1[0] * vec2[0] + vec1[1] * vec2[1] + vec1[2] * vec2[2] + vec1[3] * vec2[3];
ret[0] = SetLane0 ? dot :0.f;
ret[1] = SetLane1 ?dot :0.f;
ret[2] = SetLane2 ?dot :0.f;
ret[3] = SetLane3 ?dot : 0.f;
return ret;

◆ GetAngle()

nn::nlib::simd::Vector4::GetAngle ( SimdVectorArg  vec1_normalized,
SimdVectorArg  vec2_normalized 
)
staticnoexcept

Calculates the angle (in radians) between two normalized four-dimensional vectors.

Parameters
[in]vec1_normalizedA normalized four-dimensional vector.
[in]vec2_normalizedA normalized four-dimensional vector.
Returns
The angle (in radians) between the four-dimensional vectors is stored in each lane.

◆ InBound()

nn::nlib::simd::Vector4::InBound ( SimdVectorArg  vec,
SimdVectorArg  bounds 
)
inlinestaticnoexcept

Evaluates whether the elements of vec are inside the bounds of bounds.

Parameters
[in]vecA four-dimensional vector.
[in]boundsThe four-dimensional box that defines the bounds.
Returns
Returns true if it is inside the bounds, and false otherwise.
Description
The process is similar to the following.
return abs(vec[0]) <= bounds[0] &&
abs(vec[1]) <= bounds[1] &&
abs(vec[2]) <= bounds[2] &&
abs(vec[3]) <= bounds[3];

Definition at line 58 of file SimdVector4.h.

◆ IsInfinite()

nn::nlib::simd::Vector4::IsInfinite ( SimdVectorArg  vec)
inlinestaticnoexcept

Evaluates whether any of the elements of vec are positive infinity or negative infinity.

Parameters
[in]vecA four-dimensional vector.
Returns
Returns true if vec has any infinite elements, and false otherwise.

Definition at line 55 of file SimdVector4.h.

◆ IsNaN()

nn::nlib::simd::Vector4::IsNaN ( SimdVectorArg  vec)
inlinestaticnoexcept

Evaluates whether any of the elements of vec are NaN.

Parameters
[in]vecA four-dimensional vector.
Returns
Returns true if any of the elements of vec are NaN, and false otherwise.

Definition at line 52 of file SimdVector4.h.

◆ Length()

nn::nlib::simd::Vector4::Length ( SimdVectorArg  vec)
staticnoexcept

Calculates the length of a four-dimensional vector.

Parameters
[in]vecA four-dimensional vector.
Returns
The length is stored in each lane.

◆ LengthEst()

nn::nlib::simd::Vector4::LengthEst ( SimdVectorArg  vec)
staticnoexcept

Calculates the length of a four-dimensional vector with relatively low precision.

Parameters
[in]vecA four-dimensional vector.
Returns
The length is stored in each lane.

◆ LengthSq()

nn::nlib::simd::Vector4::LengthSq ( SimdVectorArg  vec)
staticnoexcept

Calculates the square of the length of a four-dimensional vector.

Parameters
[in]vecA four-dimensional vector.
Returns
The square of the length is stored in each lane.

◆ LoadFloat4()

template<typename MyVector4 >
nn::nlib::simd::Vector4::LoadFloat4 ( const MyVector4 *  p)
staticnoexcept

Loads a four-dimensional vector from memory.

Template Parameters
MyVector4A structure with a contiguous region in memory for the float-type public data members x, y, z, and w.
Parameters
[in]pPointer to where the four-dimensional vector is stored.
Returns
A four-dimensional vector.
Description
MyVector4 is a class like nn::nlib::simd::Float4 in nlib or XMFLOAT4 and XMFLOAT4A in DirectX.

◆ Normalize()

nn::nlib::simd::Vector4::Normalize ( SimdVectorArg  vec)
staticnoexcept

Normalizes a four-dimensional vector.

Parameters
[in]vecA four-dimensional vector.
Returns
The normalized four-dimensional vector.
Description
If vec has infinite length, each element returns a NaN vector. If it has a length of zero, each element returns a 0 vector.

◆ NormalizeEst()

nn::nlib::simd::Vector4::NormalizeEst ( SimdVectorArg  vec)
staticnoexcept

Normalizes a four-dimensional vector with relatively low precision.

Parameters
[in]vecA four-dimensional vector.
Returns
The normalized four-dimensional vector.

◆ RecpLength()

nn::nlib::simd::Vector4::RecpLength ( SimdVectorArg  vec)
staticnoexcept

Calculates the reciprocal of the length of a four-dimensional vector.

Parameters
[in]vecA four-dimensional vector.
Returns
The reciprocal of the length is stored in each lane.

◆ RecpLengthEst()

nn::nlib::simd::Vector4::RecpLengthEst ( SimdVectorArg  vec)
staticnoexcept

Calculates the reciprocal of the length of a four-dimensional vector with relatively low precision.

Parameters
[in]vecA four-dimensional vector.
Returns
The reciprocal of the length is stored in each lane.

◆ Reflect()

nn::nlib::simd::Vector4::Reflect ( SimdVectorArg  vec,
SimdVectorArg  normal 
)
staticnoexcept

Reflects a four-dimensional vector using a four-dimensional normal vector.

Parameters
[in]vecThe four-dimensional vector to reflect.
[in]normalThe four-dimensional normal vector (unit vector).
Returns
Returns the reflected four-dimensional vector.

◆ StoreFloat4()

template<typename MyVector4 >
nn::nlib::simd::Vector4::StoreFloat4 ( MyVector4 *  p,
SimdVectorArg  vec 
)
staticnoexcept

Writes a four-dimensional vector to memory.

Template Parameters
MyVector4A structure with a contiguous region in memory for the float-type public data members x, y, z, and w.
Parameters
[in,out]pPointer to where the four-dimensional vector is stored.
[in]vecA four-dimensional vector.
Description
MyVector4 is a class like XMFLOAT4 and XMFLOAT4A in DirectX.

◆ Transform()

nn::nlib::simd::Vector4::Transform ( SimdVectorArg  vec,
SimdMatrixArg  m 
)
staticnoexcept

Transforms a four-dimensional vector using a matrix.

Parameters
[in]vecA four-dimensional vector.
[in]mThe transform matrix.
Returns
The transformed three-dimensional vector.

The documentation for this class was generated from the following files: