Harlinn.Windows 0.1
|
#include <VectorMath.h>
Public Types | |
using | TupleType = TupleT |
using | Traits = typename TupleType::Traits |
using | ArrayType = typename TupleType::ArrayType |
using | value_type = typename Traits::Type |
using | size_type = size_t |
using | Simd = typename TupleType::Simd |
using | SIMDType = typename Traits::SIMDType |
Public Member Functions | |
TupleSimd () noexcept | |
Sets the elements of simd to zero. | |
TupleSimd (SIMDType values) noexcept | |
Assigns the elements of values to simd . | |
template<SimdType S> requires std::is_same_v<Traits, typename S::Traits> || ( std::is_same_v<typename Traits::Type, typename S::Traits::Type> && ( Size > S::Size ) ) | |
TupleSimd (const S &other) noexcept | |
Assigns the elements of other.simd to simd . | |
template<SimdType S> requires std::is_same_v<typename Traits::Type, typename S::Traits::Type> && ( Size < S::Size ) | |
TupleSimd (const S &other) noexcept | |
Assigns the first S::Size elements of other.simd to simd , while initializing the remaining elements to zero. | |
TupleSimd (const TupleType &other) noexcept | |
Loads other.values into simd . | |
TupleSimd (const ArrayType &values) noexcept | |
Loads values into simd . | |
TupleSimd (value_type x, value_type y) noexcept | |
Assigns x to the first element, and y to the second element, of simd ; while initializing the remaining elements to zero. | |
TupleSimd (value_type x, value_type y, value_type z) noexcept | |
Assigns x to the first element, y to the second element, and z to the third element, of simd ; while initializing the remaining elements to zero. | |
TupleSimd (value_type x, value_type y, value_type z, value_type w) noexcept | |
Assigns x to the first element, y to the second element, z to the third element, and w to the fourth element, of simd ; while initializing the remaining elements to zero. | |
TupleSimd (value_type x) noexcept | |
Assigns x to the first two elements of simd . | |
TupleSimd (value_type x) noexcept | |
Assigns x to the first three elements of simd . | |
TupleSimd (value_type x) noexcept | |
Assigns x to the first four elements of simd . | |
TupleSimd (value_type x) noexcept | |
Assigns x to the first eight elements of simd . | |
TupleType | Values () const noexcept |
Returns an instance of the Tuple2 , Tuple3 or Tuple4 derived type initialized using the Size first elements of simd . | |
TupleSimd | operator- () const noexcept |
Returns a TupleSimd with each element of simd negated. | |
bool | operator== (const TupleSimd &other) const noexcept |
Returns true if each element of simd is equal to the corresponding element of other.simd , otherwise false . | |
bool | operator!= (const TupleSimd &other) const noexcept |
Returns true if any element of simd is not equal to the corresponding element of other.simd , otherwise false . | |
bool | operator== (const value_type value) const noexcept |
Returns true if each element of simd is equal to value , otherwise false . | |
bool | operator!= (const value_type value) const noexcept |
Returns true if any element of simd is not equal to value , otherwise false . | |
template<Math::TupleType T> requires std::is_same_v<Traits, typename T::Traits> | |
bool | operator== (const T &other) const noexcept |
Returns true if each element of simd is equal to the corresponding element of other.values , otherwise false . | |
template<Math::TupleType T> requires std::is_same_v<Traits, typename T::Traits> | |
bool | operator!= (const T &other) const noexcept |
Returns true if any element of simd is not equal to the corresponding element of other.values , otherwise false . | |
bool | AnyEqual (const value_type value) const noexcept |
Returns true if any element of simd is equal to value , otherwise false . | |
bool | AnyNotEqual (const value_type value) const noexcept |
Returns true if any element of simd is not equal to value , otherwise false . | |
operator bool () const noexcept | |
Returns true if any element of simd is not equal to zero, otherwise false . | |
template<Math::TupleType T> requires std::is_same_v<Traits, typename T::Traits> | |
TupleSimd & | operator+= (const T &other) noexcept |
Adds each element of other.values to the corresponding element of simd . | |
TupleSimd & | operator+= (const TupleSimd &other) noexcept |
Adds each element of other.simd to the corresponding element of simd . | |
TupleSimd & | operator+= (const value_type value) noexcept |
Adds value to each element of simd . | |
template<Math::TupleType T> requires std::is_same_v<Traits, typename T::Traits> | |
TupleSimd & | operator-= (const T &other) noexcept |
Subtracts each element of other.values from the corresponding element of simd . | |
TupleSimd & | operator-= (const TupleSimd &other) noexcept |
Subtracts each element of other.simd from the corresponding element of simd . | |
TupleSimd & | operator-= (const value_type value) noexcept |
Subtracts value from each element of simd . | |
template<Math::TupleType T> requires std::is_same_v<Traits, typename T::Traits> | |
TupleSimd & | operator*= (const T &other) noexcept |
Multiplies each element of simd with the corresponding element of other.values . | |
TupleSimd & | operator*= (const TupleSimd &other) noexcept |
Multiplies each element of simd with the corresponding element of other.simd . | |
TupleSimd & | operator*= (const value_type value) noexcept |
Multiplies each element of simd with value . | |
template<Math::TupleType T> requires std::is_same_v<Traits, typename T::Traits> | |
TupleSimd & | operator/= (const T &other) noexcept |
Multiplies each element of simd with the corresponding element of other.values . | |
TupleSimd & | operator/= (const TupleSimd &other) noexcept |
Divides each element of simd by the corresponding element of other.simd . | |
TupleSimd & | operator/= (const value_type value) noexcept |
Divides each element of simd by value . | |
void | Assign (const TupleSimd &other) noexcept |
Assigns each element of other.simd to the corresponding element of simd . | |
void | Assign (const value_type value) noexcept |
Assigns value to the first Size elements of simd . | |
template<Math::TupleType T> requires std::is_same_v<Traits, typename T::Traits> | |
void | Assign (const T &other) noexcept |
Assigns each element of other.values to the corresponding element of simd . | |
void | Assign (SIMDType values) noexcept |
Assigns each element of values to the corresponding element of simd . | |
std::string | ToString () const |
Static Public Member Functions | |
static TupleSimd | Backward () noexcept |
Returns true if at least one of the elements of simd ` is NaN, otherwise false . /. | |
Public Attributes | |
SIMDType | simd |
Static Public Attributes | |
static constexpr size_type | Size = TupleType::Size |
static constexpr size_type | Capacity = Traits::SIMDTypeCapacity |
Friends | |
std::ostream & | operator<< (std::ostream &stream, const TupleSimd &t) |
Holds the SIMD value for a Tuple2, Tuple3 or Tuple4.
Most operations on a particular Tuple2, Tuple3 or Tuple4 derived type are implemented using TupleSimd.
The implementation passes TupleSimd objects by reference, since passing the TupleSimd objects by value degraded the performance of pbrto by approximately 10 %.
using Harlinn::Math::TupleSimd< TupleT >::ArrayType = typename TupleType::ArrayType |
using Harlinn::Math::TupleSimd< TupleT >::Simd = typename TupleType::Simd |
using Harlinn::Math::TupleSimd< TupleT >::SIMDType = typename Traits::SIMDType |
using Harlinn::Math::TupleSimd< TupleT >::size_type = size_t |
using Harlinn::Math::TupleSimd< TupleT >::Traits = typename TupleType::Traits |
using Harlinn::Math::TupleSimd< TupleT >::TupleType = TupleT |
using Harlinn::Math::TupleSimd< TupleT >::value_type = typename Traits::Type |
|
inlinenoexcept |
Sets the elements of simd
to zero.
|
inlinenoexcept |
Assigns the elements of values
to simd
.
|
inlinenoexcept |
Assigns the elements of other.simd
to simd
.
|
inlinenoexcept |
Assigns the first S::Size
elements of other.simd
to simd
, while initializing the remaining elements to zero.
|
inlinenoexcept |
Loads other.values
into simd
.
|
inlinenoexcept |
Loads values
into simd
.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlineexplicitnoexcept |
Assigns x
to the first two elements of simd
.
|
inlineexplicitnoexcept |
Assigns x
to the first three elements of simd
.
|
inlineexplicitnoexcept |
Assigns x
to the first four elements of simd
.
|
inlineexplicitnoexcept |
Assigns x
to the first eight elements of simd
.
|
inlinenoexcept |
Returns true
if any element of simd
is equal to value
, otherwise false
.
|
inlinenoexcept |
Returns true
if any element of simd
is not equal to value
, otherwise false
.
|
inlinenoexcept |
Assigns each element of other.values
to the corresponding element of simd
.
|
inlinenoexcept |
Assigns each element of other.simd
to the corresponding element of simd
.
other |
|
inlinenoexcept |
Assigns value
to the first Size
elements of simd
.
|
inlinenoexcept |
Assigns each element of values
to the corresponding element of simd
.
|
inlinestaticnoexcept |
Returns true
if at least one of the elements of simd
` is NaN, otherwise false
. /.
bool HasNaN( ) const noexcept { return Traits::HasNaN( simd ); }
/
/ Replicates the first element of simd
to all the elements of the result. / TupleSimd X( ) const { return Traits::Trim( Traits::At<0>( simd ) ); } /
/ Extracts the first element of simd
. / value_type x( ) const { return Traits::Extract<0>( simd ); } /
/ Assigns the first element of src
to the first element of simd
. / void SetX( SIMDType src ) { simd = Traits::Permute<4, 1, 2, 3>( simd, src ); } /
/ Assigns the first element of src.simd
to the first element of simd
. / void SetX( const TupleSimd& src ) { SetX( src.simd ); } /
/ Assigns value
to the first element of simd
. / void SetX( const value_type value ) { SetX( Traits::Fill<Size>( value ) ); } /
/ Sets the first element of simd
to its absolute value. / void AbsX( ) { simd = Traits::AbsX( simd ); } /
/ Copies the TupleSimd
setting the first element to its absolute value. / TupleSimd WithAbsX( ) const { return Traits::AbsX( simd ); } /
/ Sets the first element of simd
to its negated value. / void NegateX( ) { simd = Traits::NegateX( simd ); } /
/ Copies the TupleSimd
setting the first element to its negated value. / TupleSimd WithNegatedX( ) const { return Traits::NegateX( simd ); }
/
/ Replicates the second element of simd
to all the elements of the result. / TupleSimd Y( ) const { return Traits::Trim( Traits::At<1>( simd ) ); } /
/ Extracts the second element of simd
. / value_type y( ) const { return Traits::Extract<1>( simd ); } /
/ Assigns the second element of src
to the second element of simd
. / void SetY( SIMDType src ) { simd = Traits::Permute<0, 5, 2, 3>( simd, src ); } /
/ Assigns the second element of src.simd
to the second element of simd
. / void SetY( const TupleSimd& src ) { SetY( src.simd ); } /
/ Assigns value
to the second element of simd
. / void SetY( const value_type value ) { SetY( Traits::Fill<Size>( value ) ); } /
/ Sets the second element of simd
to its absolute value. / void AbsY( ) { simd = Traits::AbsY( simd ); } /
/ Copies the TupleSimd
setting the second element to its absolute value. / TupleSimd WithAbsY( ) const noexcept { return Traits::AbsY( simd ); } /
/ Sets the second element of simd
to its negated value. / void NegateY( ) { simd = Traits::NegateY( simd ); } /
/ Copies the TupleSimd
setting the second element to its negated value. / TupleSimd WithNegatedY( ) const { return Traits::NegateY( simd ); }
/
/ Sets the first and second elements of simd
to their absolute values. / void AbsXY( ) { simd = Traits::AbsXY( simd ); } /
/ Copies the TupleSimd
setting the first and second elements to their absolute values. / TupleSimd WithAbsXY( ) const noexcept { return Traits::AbsXY( simd ); } /
/ Sets the first and second elements of simd
to their negated values. / void NegateXY( ) { simd = Traits::NegateXY( simd ); } /
/ Copies the TupleSimd
setting the first and second elements to their negated values. / TupleSimd WithNegatedXY( ) const { return Traits::NegateXY( simd ); }
/
/ Replicates the third element of simd
to all the elements of the result. / TupleSimd Z( ) const requires ( Size > 2 ) { return Traits::Trim( Traits::At<2>( simd ) ); } /
/ Extracts the third element of simd
. / value_type z( ) const requires ( Size > 2 ) { return Traits::Extract<2>( simd ); } /
/ Assigns the third element of src
to the third element of simd
. / void SetZ( SIMDType src ) requires ( Size > 2 ) { simd = Traits::Permute<0, 1, 6, 3>( simd, src ); } /
/ Assigns the third element of src.simd
to the third element of simd
. / void SetZ( const TupleSimd& src ) requires ( Size > 2 ) { SetZ( src.simd ); } /
/ Assigns value
to the third element of simd
. / void SetZ( const value_type value ) requires ( Size > 2 ) { SetZ( Traits::Fill<Size>( value ) ); } /
/ Sets the third element of simd
to its absolute value. / void AbsZ( ) requires ( Size > 2 ) { simd = Traits::AbsZ( simd ); } /
/ Copies the TupleSimd
setting the third element to its absolute value. / TupleSimd WithAbsZ( ) const noexcept requires ( Size > 2 ) { return Traits::AbsZ( simd ); } /
/ Sets the third element of simd
to its negated value. / void NegateZ( ) requires ( Size > 2 ) { simd = Traits::NegateZ( simd ); } /
/ Copies the TupleSimd
setting the third element to its negated value. / TupleSimd WithNegatedZ( ) const requires ( Size > 2 ) { return Traits::NegateZ( simd ); }
/
/ Assigns the first, second and third elements of src
to the first, second and third elements of simd
. / void SetXYZ( SIMDType src ) requires ( Size > 2 ) { simd = Traits::Permute<0, 1, 2, 7>( src, simd ); } /
/ Assigns the first, second and third elements of src.simd
to the first, second and third elements of simd
. / void SetXYZ( const TupleSimd& src ) { SetXYZ( src.simd ); }
/
/ Assigns x
to the first element of simd
, y
to the second element of simd
, and z
to the third element of simd
. / void SetXYZ( const value_type x, const value_type y, const value_type z ) { SetXYZ( Traits::Set( z, y, x ) ); }
/
/ Replicates the fourth element of simd
to all the elements of the result. / TupleSimd W( ) const requires ( Size > 3 ) { return Traits::Trim( Traits::At<3>( simd ) ); } /
/ Extracts the fourth element of simd
. / value_type w( ) const requires ( Size > 3 ) { return Traits::Extract<3>( simd ); }
/
/ Assigns the fourth element of src
to the fourth element of simd
. / void SetW( SIMDType src ) requires ( Size > 3 ) { simd = Traits::Permute<0, 1, 2, 7>( simd, src ); } /
/ Assigns the fourth element of src.simd
to the fourth element of simd
. / void SetW( const TupleSimd& src ) requires ( Size > 3 ) { SetW( src.simd ); } /
/ Assigns value
to the fourth element of simd
. / void SetW( const value_type value ) requires ( Size > 3 ) { SetW( Traits::Fill<Size>( value ) ); }
/
/ Sets the fourth element of simd
to its absolute value. / void AbsW( ) requires ( Size > 3 ) { simd = Traits::AbsW( simd ); } /
/ Copies the TupleSimd
setting the fourth element to its absolute value. / TupleSimd WithAbsW( ) const noexcept requires ( Size > 3 ) { return Traits::AbsW( simd ); } /
/ Sets the fourth element of simd
to its negated value. / void NegateW( ) requires ( Size > 3 ) { simd = Traits::NegateW( simd ); } /
/ Copies the TupleSimd
setting the fourth element to its negated value. / TupleSimd WithNegatedW( ) const requires ( Size > 3 ) { return Traits::NegateW( simd ); }
/
/ Returns the element at index idx
in simd
. / value_type operator[]( size_t idx ) const { if constexpr ( Size == 1 ) { return Traits::Extract<0>( simd ); } else if constexpr ( Size == 2 ) { switch ( idx ) { case 0: return Traits::Extract<0>( simd ); case 1: return Traits::Extract<1>( simd ); } } else if constexpr ( Size == 3 ) { switch ( idx ) { case 0: return Traits::Extract<0>( simd ); case 1: return Traits::Extract<1>( simd ); case 2: return Traits::Extract<2>( simd ); } } else if constexpr ( Size == 4 ) { switch ( idx ) { case 0: return Traits::Extract<0>( simd ); case 1: return Traits::Extract<1>( simd ); case 2: return Traits::Extract<2>( simd ); case 3: return Traits::Extract<3>( simd ); } } else if constexpr ( Size == 5 ) { switch ( idx ) { case 0: return Traits::Extract<0>( simd ); case 1: return Traits::Extract<1>( simd ); case 2: return Traits::Extract<2>( simd ); case 3: return Traits::Extract<3>( simd ); case 4: return Traits::Extract<4>( simd ); } } else if constexpr ( Size == 6 ) { switch ( idx ) { case 0: return Traits::Extract<0>( simd ); case 1: return Traits::Extract<1>( simd ); case 2: return Traits::Extract<2>( simd ); case 3: return Traits::Extract<3>( simd ); case 4: return Traits::Extract<4>( simd ); case 5: return Traits::Extract<5>( simd ); } } else if constexpr ( Size == 7 ) { switch ( idx ) { case 0: return Traits::Extract<0>( simd ); case 1: return Traits::Extract<1>( simd ); case 2: return Traits::Extract<2>( simd ); case 3: return Traits::Extract<3>( simd ); case 4: return Traits::Extract<4>( simd ); case 5: return Traits::Extract<5>( simd ); case 6: return Traits::Extract<6>( simd ); } } else if constexpr ( Size == 8 ) { switch ( idx ) { case 0: return Traits::Extract<0>( simd ); case 1: return Traits::Extract<1>( simd ); case 2: return Traits::Extract<2>( simd ); case 3: return Traits::Extract<3>( simd ); case 4: return Traits::Extract<4>( simd ); case 5: return Traits::Extract<5>( simd ); case 6: return Traits::Extract<6>( simd ); case 7: return Traits::Extract<7>( simd ); } } return operator[]( idx% Size ); }
/
/ Returns a TupleSimd
with all elements set to zero. / static TupleSimd Zero( ) noexcept { return TupleSimd( Traits::Zero( ) ); } /
/ Returns a TupleSimd
with all elements set to one. / static TupleSimd One( ) noexcept { return TupleSimd( Traits::Fill<Size>( static_cast< value_type >( 1 ) ) ); }
/
/ Returns a TupleSimd
the first element set to 1, and the other elements set to 0. / static TupleSimd UnitX( ) noexcept { return TupleSimd( Traits::Set( static_cast< value_type >( 1 ) ) ); } /
/ Returns a TupleSimd
the second element set to 1, and the other elements set to 0. / static TupleSimd UnitY( ) noexcept { return TupleSimd( Traits::Set( static_cast< value_type >( 1 ), static_cast< value_type >( 0 ) ) ); }
/
/ Returns a TupleSimd
the third element set to 1, and the other elements set to 0. / static TupleSimd UnitZ( ) noexcept requires ( Size >= 3 ) { return TupleSimd( Traits::Set( static_cast< value_type >( 1 ), static_cast< value_type >( 0 ), static_cast< value_type >( 0 ) ) ); }
/
/ Returns a TupleSimd
the fourth element set to 1, and the other elements set to 0. / static TupleSimd UnitW( ) noexcept requires ( Size >= 4 ) { return TupleSimd( Traits::Set( static_cast< value_type >( 1 ), static_cast< value_type >( 0 ), static_cast< value_type >( 0 ), static_cast< value_type >( 0 ) ) ); }
/
/ Returns a TupleSimd
containing the unit vector for the up direction. / static TupleSimd Up( ) noexcept requires ( Size >= 3 ) { return TupleSimd( Traits::Set( static_cast< value_type >( 1 ), static_cast< value_type >( 0 ) ) ); } /
/ Returns a TupleSimd
containing the unit vector for the down direction. / static TupleSimd Down( ) noexcept requires ( Size >= 3 ) { return TupleSimd( Traits::Set( static_cast< value_type >( -1 ), static_cast< value_type >( 0 ) ) ); } /
/ Returns a TupleSimd
containing the unit vector for the right direction. / static TupleSimd Right( ) noexcept requires ( Size >= 3 ) { return TupleSimd( Traits::Set( static_cast< value_type >( 1 ) ) ); }
/
/ Returns a TupleSimd
containing the unit vector for the left direction. / static TupleSimd Left( ) noexcept requires ( Size >= 3 ) { return TupleSimd( Traits::Set( static_cast< value_type >( -1 ) ) ); }
/
/ Returns a TupleSimd
containing the unit vector for the forward direction. / static TupleSimd Forward( ) noexcept requires ( Size >= 3 ) { return TupleSimd( Traits::Set( static_cast< value_type >( -1 ), static_cast< value_type >( 0 ), static_cast< value_type >( 0 ) ) ); }
/
/ Returns a TupleSimd
containing the unit vector for the backward direction.
|
inlineexplicitnoexcept |
Returns true
if any element of simd
is not equal to zero, otherwise false
.
|
inlinenoexcept |
Returns true
if any element of simd
is not equal to the corresponding element of other.values
, otherwise false
.
|
inlinenoexcept |
Returns true
if any element of simd
is not equal to the corresponding element of other.simd
, otherwise false
.
|
inlinenoexcept |
Returns true
if any element of simd
is not equal to value
, otherwise false
.
|
inlinenoexcept |
Multiplies each element of simd
with the corresponding element of other.values
.
|
inlinenoexcept |
Multiplies each element of simd
with the corresponding element of other.simd
.
|
inlinenoexcept |
Multiplies each element of simd
with value
.
|
inlinenoexcept |
Adds each element of other.values
to the corresponding element of simd
.
|
inlinenoexcept |
Adds each element of other.simd
to the corresponding element of simd
.
|
inlinenoexcept |
Adds value
to each element of simd
.
|
inlinenoexcept |
Returns a TupleSimd
with each element of simd
negated.
|
inlinenoexcept |
Subtracts each element of other.values
from the corresponding element of simd
.
|
inlinenoexcept |
Subtracts each element of other.simd
from the corresponding element of simd
.
|
inlinenoexcept |
Subtracts value
from each element of simd
.
|
inlinenoexcept |
Multiplies each element of simd
with the corresponding element of other.values
.
|
inlinenoexcept |
Divides each element of simd
by the corresponding element of other.simd
.
|
inlinenoexcept |
Divides each element of simd
by value
.
|
inlinenoexcept |
Returns true
if each element of simd
is equal to the corresponding element of other.values
, otherwise false
.
|
inlinenoexcept |
Returns true
if each element of simd
is equal to the corresponding element of other.simd
, otherwise false
.
|
inlinenoexcept |
Returns true
if each element of simd
is equal to value
, otherwise false
.
|
inline |
|
inlinenoexcept |
|
friend |
|
staticconstexpr |
SIMDType Harlinn::Math::TupleSimd< TupleT >::simd |
|
staticconstexpr |