mirror of
https://github.com/BlackMATov/vmath.hpp.git
synced 2025-12-13 20:17:58 +07:00
remove isnan, isinf, isfinite, modf, frexp and ldexp functions
This commit is contained in:
45
README.md
45
README.md
@@ -947,9 +947,6 @@ T fract(T x) noexcept;
|
||||
template < floating_point T >
|
||||
T fmod(T x, T y) noexcept;
|
||||
|
||||
template < floating_point T >
|
||||
T modf(T x, T* y) noexcept;
|
||||
|
||||
template < floating_point T >
|
||||
T copysign(T x, T s) noexcept;
|
||||
|
||||
@@ -977,23 +974,8 @@ constexpr T step(T edge, T x) noexcept;
|
||||
template < floating_point T >
|
||||
constexpr T smoothstep(T edge0, T edge1, T x) noexcept;
|
||||
|
||||
template < arithmetic T >
|
||||
bool isnan(T x) noexcept;
|
||||
|
||||
template < arithmetic T >
|
||||
bool isinf(T x) noexcept;
|
||||
|
||||
template < arithmetic T >
|
||||
bool isfinite(T x) noexcept;
|
||||
|
||||
template < floating_point T >
|
||||
T fma(T x, T y, T z) noexcept;
|
||||
|
||||
template < floating_point T >
|
||||
T frexp(T x, int* exp) noexcept;
|
||||
|
||||
template < floating_point T >
|
||||
T ldexp(T x, int exp) noexcept;
|
||||
```
|
||||
|
||||
#### Vector
|
||||
@@ -1032,9 +1014,6 @@ vec<T, Size> fmod(const vec<T, Size>& xs, T y);
|
||||
template < typename T, size_t Size >
|
||||
vec<T, Size> fmod(const vec<T, Size>& xs, const vec<T, Size>& ys);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
vec<T, Size> modf(const vec<T, Size>& xs, vec<T, Size>* is);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
vec<T, Size> copysign(const vec<T, Size>& xs, T s);
|
||||
|
||||
@@ -1098,23 +1077,8 @@ constexpr vec<T, Size> smoothstep(T edge0, T edge1, const vec<T, Size>& xs);
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<T, Size> smoothstep(const vec<T, Size>& edges0, const vec<T, Size>& edges1, const vec<T, Size>& xs);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
vec<bool, Size> isnan(const vec<T, Size>& xs);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
vec<bool, Size> isinf(const vec<T, Size>& xs);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
vec<bool, Size> isfinite(const vec<T, Size>& xs);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
vec<T, Size> fma(const vec<T, Size>& as, const vec<T, Size>& bs, const vec<T, Size>& cs);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
vec<T, Size> frexp(const vec<T, Size>& xs, vec<int, Size>* exps);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
vec<T, Size> ldexp(const vec<T, Size>& xs, const vec<int, Size>& exps);
|
||||
```
|
||||
|
||||
#### Quaternion
|
||||
@@ -1131,15 +1095,6 @@ qua<T> nlerp(const qua<T>& unit_xs, const qua<T>& unit_ys, T a);
|
||||
|
||||
template < typename T >
|
||||
qua<T> slerp(const qua<T>& unit_xs, const qua<T>& unit_ys, T a);
|
||||
|
||||
template < typename T >
|
||||
vec<bool, 4> isnan(const qua<T>& xs);
|
||||
|
||||
template < typename T >
|
||||
vec<bool, 4> isinf(const qua<T>& xs);
|
||||
|
||||
template < typename T >
|
||||
vec<bool, 4> isfinite(const qua<T>& xs);
|
||||
```
|
||||
|
||||
### Angle and Trigonometric Functions
|
||||
|
||||
@@ -80,12 +80,6 @@ namespace vmath_hpp
|
||||
return std::fmod(x, y);
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_floating_point_v<T>, T>
|
||||
modf(T x, T* y) noexcept {
|
||||
return std::modf(x, y);
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_floating_point_v<T>, T>
|
||||
copysign(T x, T s) noexcept {
|
||||
@@ -141,41 +135,11 @@ namespace vmath_hpp
|
||||
return t * t * (T(3) - T(2) * t);
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_arithmetic_v<T>, bool>
|
||||
isnan(T x) noexcept {
|
||||
return std::isnan(x);
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_arithmetic_v<T>, bool>
|
||||
isinf(T x) noexcept {
|
||||
return std::isinf(x);
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_arithmetic_v<T>, bool>
|
||||
isfinite(T x) noexcept {
|
||||
return std::isfinite(x);
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_floating_point_v<T>, T>
|
||||
fma(T x, T y, T z) noexcept {
|
||||
return std::fma(x, y, z);
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_floating_point_v<T>, T>
|
||||
frexp(T x, int* exp) noexcept {
|
||||
return std::frexp(x, exp);
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_floating_point_v<T>, T>
|
||||
ldexp(T x, int exp) noexcept {
|
||||
return std::ldexp(x, exp);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -196,21 +196,6 @@ namespace vmath_hpp
|
||||
return normalize(lerp(unit_xs, unit_ys, xs_scale, ys_scale));
|
||||
}
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] vec<bool, 4> isnan(const qua<T>& xs) {
|
||||
return isnan(vec{xs});
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] vec<bool, 4> isinf(const qua<T>& xs) {
|
||||
return isinf(vec{xs});
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] vec<bool, 4> isfinite(const qua<T>& xs) {
|
||||
return isfinite(vec{xs});
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -556,20 +556,6 @@ namespace vmath_hpp
|
||||
return map_join([](T x, T y) { return fmod(x, y); }, xs, ys);
|
||||
}
|
||||
|
||||
namespace impl
|
||||
{
|
||||
template < typename T, std::size_t Size, std::size_t... Is >
|
||||
VMATH_HPP_FORCE_INLINE
|
||||
vec<T, Size> modf_impl(const vec<T, Size>& xs, vec<T, Size>* is, std::index_sequence<Is...>) {
|
||||
return { modf(xs[Is], &(*is)[Is])... };
|
||||
}
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
vec<T, Size> modf(const vec<T, Size>& xs, vec<T, Size>* is) {
|
||||
return impl::modf_impl(xs, is, std::make_index_sequence<Size>{});
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] vec<T, Size> copysign(const vec<T, Size>& xs, T s) {
|
||||
return map_join([s](T x) { return copysign(x, s); }, xs);
|
||||
@@ -684,44 +670,10 @@ namespace vmath_hpp
|
||||
return map_join([](T edge0, T edge1, T x) { return smoothstep(edge0, edge1, x); }, edges0, edges1, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] vec<bool, Size> isnan(const vec<T, Size>& xs) {
|
||||
return map_join([](T x) { return isnan(x); }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] vec<bool, Size> isinf(const vec<T, Size>& xs) {
|
||||
return map_join([](T x) { return isinf(x); }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] vec<bool, Size> isfinite(const vec<T, Size>& xs) {
|
||||
return map_join([](T x) { return isfinite(x); }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] vec<T, Size> fma(const vec<T, Size>& as, const vec<T, Size>& bs, const vec<T, Size>& cs) {
|
||||
return map_join([](T a, T b, T c) { return fma(a, b, c); }, as, bs, cs);
|
||||
}
|
||||
|
||||
namespace impl
|
||||
{
|
||||
template < typename T, std::size_t Size, std::size_t... Is >
|
||||
VMATH_HPP_FORCE_INLINE
|
||||
vec<T, Size> frexp_impl(const vec<T, Size>& xs, vec<int, Size>* exps, std::index_sequence<Is...>) {
|
||||
return { frexp(xs[Is], &(*exps)[Is])... };
|
||||
}
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
vec<T, Size> frexp(const vec<T, Size>& xs, vec<int, Size>* exps) {
|
||||
return impl::frexp_impl(xs, exps, std::make_index_sequence<Size>{});
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] vec<T, Size> ldexp(const vec<T, Size>& xs, const vec<int, Size>& exps) {
|
||||
return map_join([](T x, int exp) { return ldexp(x, exp); }, xs, exps);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -77,12 +77,6 @@ TEST_CASE("vmath/fun") {
|
||||
|
||||
CHECK(fmod(1.7f, 1.2f) == uapprox(0.5f));
|
||||
|
||||
{
|
||||
float out_i{};
|
||||
CHECK(modf(1.7f, &out_i) == uapprox(0.7f));
|
||||
CHECK(out_i == uapprox(1.f));
|
||||
}
|
||||
|
||||
STATIC_CHECK(min(0.f, 1.f) == uapprox(0.f));
|
||||
STATIC_CHECK(max(0.f, 1.f) == uapprox(1.f));
|
||||
|
||||
@@ -106,19 +100,7 @@ TEST_CASE("vmath/fun") {
|
||||
STATIC_CHECK(step(0.5f, 0.6f) == uapprox(1.f));
|
||||
STATIC_CHECK(smoothstep(0.f, 1.f, 0.1f) == uapprox(0.028f));
|
||||
|
||||
CHECK_FALSE(vmath_hpp::isnan(1.f));
|
||||
CHECK_FALSE(vmath_hpp::isinf(1.f));
|
||||
CHECK(vmath_hpp::isfinite(1.f));
|
||||
|
||||
CHECK(fma(2.f, 3.f, 4.f) == uapprox(10.f));
|
||||
|
||||
{
|
||||
int out_exp{};
|
||||
CHECK(frexp(1.7f, &out_exp) == uapprox(0.85f));
|
||||
CHECK(out_exp == 1);
|
||||
}
|
||||
|
||||
CHECK(ldexp(0.85f, 1) == uapprox(1.7f));
|
||||
}
|
||||
|
||||
SUBCASE("Geometric Functions") {
|
||||
|
||||
@@ -128,12 +128,6 @@ TEST_CASE("vmath/qua_fun") {
|
||||
qrotate_z(radians(290.f)),
|
||||
slerp(qrotate_z(radians(220.f)), qrotate_z(radians(0.f)), 0.5f))));
|
||||
}
|
||||
|
||||
{
|
||||
CHECK_FALSE(any(isnan(qfloat(1,1,1,1))));
|
||||
CHECK_FALSE(any(isinf(qfloat(1,1,1,1))));
|
||||
CHECK(all(isfinite(qfloat(1,1,1,1))));
|
||||
}
|
||||
}
|
||||
|
||||
SUBCASE("Geometric Functions") {
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace vmath_tests
|
||||
|
||||
template < typename T >
|
||||
constexpr bool operator==(const vec<T, 2>& l, const uapprox2<T>& r) {
|
||||
return all(approx(l, r.value,r.epsilon));
|
||||
return all(approx(l, r.value, r.epsilon));
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
|
||||
@@ -201,12 +201,6 @@ TEST_CASE("vmath/vec_fun") {
|
||||
CHECK(fmod(float2(1.7f), 1.2f) == uapprox2(0.5f));
|
||||
CHECK(fmod(float2(1.7f), float2(1.2f)) == uapprox2(0.5f));
|
||||
|
||||
{
|
||||
float2 out_i{};
|
||||
CHECK(modf(float2(1.7f), &out_i) == uapprox2(0.7f));
|
||||
CHECK(out_i.x == uapprox(1.f));
|
||||
}
|
||||
|
||||
STATIC_CHECK(min(int2(1,2)) == 1);
|
||||
STATIC_CHECK(min(int2(1,2), 1) == int2(1,1));
|
||||
STATIC_CHECK(min(1, int2(1,2)) == int2(1,1));
|
||||
@@ -246,19 +240,7 @@ TEST_CASE("vmath/vec_fun") {
|
||||
STATIC_CHECK(smoothstep(0.f, 1.f, float2(0.1f)) == uapprox2(0.028f));
|
||||
STATIC_CHECK(smoothstep(float2(0.f), float2(1.f), float2(0.1f)) == uapprox2(0.028f));
|
||||
|
||||
CHECK_FALSE(isnan(float2(1.f)).x);
|
||||
CHECK_FALSE(isinf(float2(1.f)).x);
|
||||
CHECK(isfinite(float2(1.f)).x);
|
||||
|
||||
CHECK_FALSE(fma(float2(2.f), float2(3.f), float2(4.f)).x == uapprox(12.f));
|
||||
|
||||
{
|
||||
int2 out_exp{};
|
||||
CHECK(frexp(float2(1.7f), &out_exp).x == uapprox(0.85f));
|
||||
CHECK(out_exp == int2(1));
|
||||
}
|
||||
|
||||
CHECK(ldexp(float2(0.85f), int2(1)).x == uapprox(1.7f));
|
||||
}
|
||||
|
||||
SUBCASE("Geometric Functions") {
|
||||
|
||||
Reference in New Issue
Block a user