mirror of
https://github.com/BlackMATov/vmath.hpp.git
synced 2025-12-15 12:39:47 +07:00
isfinite function
This commit is contained in:
@@ -123,8 +123,9 @@ namespace vmath_hpp
|
||||
|
||||
using ::std::isnan;
|
||||
using ::std::isinf;
|
||||
using ::std::fma;
|
||||
using ::std::isfinite;
|
||||
|
||||
using ::std::fma;
|
||||
using ::std::frexp;
|
||||
using ::std::ldexp;
|
||||
}
|
||||
|
||||
@@ -511,6 +511,11 @@ namespace vmath_hpp
|
||||
return map([](T x) { return isinf(x); }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
vec<bool, Size> isfinite(const vec<T, Size>& xs) {
|
||||
return map([](T x) { return isfinite(x); }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
vec<T, Size> fma(const vec<T, Size>& as, const vec<T, Size>& bs, const vec<T, Size>& cs) {
|
||||
return zip([](T a, T b, T c) { return fma(a, b, c); }, as, bs, cs);
|
||||
|
||||
@@ -99,6 +99,7 @@ TEST_CASE("vmath/fun") {
|
||||
|
||||
REQUIRE_FALSE(isnan(1.f));
|
||||
REQUIRE_FALSE(isinf(1.f));
|
||||
REQUIRE(isfinite(1.f));
|
||||
|
||||
REQUIRE(fma(2.f, 3.f, 4.f) == approx(10.f));
|
||||
|
||||
|
||||
@@ -147,6 +147,7 @@ TEST_CASE("vmath/vec_fun") {
|
||||
|
||||
REQUIRE_FALSE(isnan(vec2f(1.f)).x);
|
||||
REQUIRE_FALSE(isinf(vec2f(1.f)).x);
|
||||
REQUIRE(isfinite(vec2f(1.f)).x);
|
||||
|
||||
REQUIRE_FALSE(fma(vec2f(2.f), vec2f(3.f), vec2f(4.f)).x == Approx(12.f));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user