isfinite function

This commit is contained in:
BlackMATov
2020-11-25 18:47:44 +07:00
parent 7cf4059e32
commit e589c03c53
4 changed files with 9 additions and 1 deletions

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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));

View File

@@ -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));