- Started unit tests for the common math functions
This commit is contained in:
@@ -301,7 +301,7 @@ namespace fennec
|
||||
/// \param x input value
|
||||
template<typename genType>
|
||||
constexpr genType abs(genType x)
|
||||
{ return std::abs(x); }
|
||||
{ return ::abs(x); }
|
||||
|
||||
|
||||
// Vector Specializations ----------------------------------------------------------------------------------------------
|
||||
@@ -324,7 +324,7 @@ constexpr vector<genType, i...> abs(const vector<genType, i...>& x)
|
||||
/// \param x input value
|
||||
template<typename genType>
|
||||
constexpr genType sign(genType x)
|
||||
{ return (x < 0 ? -1 : (x > 0 ? +1 : 0)); }
|
||||
{ return (x < 0 ? -1 : 1) * static_cast<genType>(x != 0); }
|
||||
|
||||
|
||||
// Vector Specializations ----------------------------------------------------------------------------------------------
|
||||
@@ -427,7 +427,7 @@ constexpr vector<genType, i...> round(const vector<genType, i...>& x)
|
||||
/// \param x input value
|
||||
template<typename genType>
|
||||
constexpr genType roundEven(genType x)
|
||||
{ return x - floor(x) == 0.5f ? floor(x) + (static_cast<int>(floor(x)) % 2) : round(x); }
|
||||
{ return ::roundeven(x); }
|
||||
|
||||
|
||||
// Vector Specializations ----------------------------------------------------------------------------------------------
|
||||
@@ -505,18 +505,18 @@ constexpr vector<genType, i...> fract(const vector<genType, i...>& x)
|
||||
/// \param y divisor
|
||||
template<typename genType>
|
||||
constexpr genType mod(genType x, genType y)
|
||||
{ return x - y * fennec::floor(x); }
|
||||
{ return x - y * fennec::floor(x / y); }
|
||||
|
||||
|
||||
// Vector Specializations ----------------------------------------------------------------------------------------------
|
||||
|
||||
template<typename genType, size_t...i>
|
||||
constexpr vector<genType, i...> mod(const vector<genType, i...>& x, genType y)
|
||||
{ return x - y * fennec::floor(x); }
|
||||
{ return x - y * fennec::floor(x / y); }
|
||||
|
||||
template<typename genType, size_t...i>
|
||||
constexpr vector<genType, i...> mod(const vector<genType, i...>& x, const vector<genType, i...>& y)
|
||||
{ return x - y * fennec::floor(x); }
|
||||
{ return x - y * fennec::floor(x / y); }
|
||||
|
||||
|
||||
|
||||
@@ -533,7 +533,7 @@ constexpr vector<genType, i...> mod(const vector<genType, i...>& x, const vector
|
||||
/// \param i integral out
|
||||
template<typename genType>
|
||||
constexpr genType modf(genType x, genType& i)
|
||||
{ return ::modf(x, &i); }
|
||||
{ i = fennec::floor(x); return fennec::fract(x); }
|
||||
|
||||
|
||||
// Vector Specializations ----------------------------------------------------------------------------------------------
|
||||
@@ -600,7 +600,7 @@ constexpr vector<genBType, i...> isinf(const vector<genType, i...>& x)
|
||||
///
|
||||
/// \copydetails fennec::floatBitsToUint(fennec::genFType)
|
||||
template<typename genType, typename genIType = int_t> requires(is_floating_point_v<genType> and is_integral_v<genIType> and is_signed_v<genIType> and sizeof(genType) == sizeof(genIType))
|
||||
constexpr genIType floatBitsToInt(genIType x)
|
||||
constexpr genIType floatBitsToInt(genType x)
|
||||
{ return fennec::bit_cast<genIType>(x); }
|
||||
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user