Browse Source

Add a sign() function for real numbers.

wip/image-kernel
Sam Hocevar 4 years ago
parent
commit
37d6d2f18a
2 changed files with 6 additions and 0 deletions
  1. +1
    -0
      include/lol/private/types/real.h
  2. +5
    -0
      include/lol/private/types/real.ipp

+ 1
- 0
include/lol/private/types/real.h View File

@@ -157,6 +157,7 @@ public:
template<typename U> friend real_t<U> fract(real_t<U> const &x); template<typename U> friend real_t<U> fract(real_t<U> const &x);
template<typename U> friend real_t<U> degrees(real_t<U> const &x); template<typename U> friend real_t<U> degrees(real_t<U> const &x);
template<typename U> friend real_t<U> radians(real_t<U> const &x); template<typename U> friend real_t<U> radians(real_t<U> const &x);
template<typename U> friend int sign(real_t<U> const &x);


// Additional functions // Additional functions
template<typename U> friend real_t<U> franke(real_t<U> const &x, template<typename U> friend real_t<U> franke(real_t<U> const &x,


+ 5
- 0
include/lol/private/types/real.ipp View File

@@ -1007,6 +1007,11 @@ template<typename T> real_t<T> radians(real_t<T> const &x)
return x * mul; return x * mul;
} }


template<typename T> int sign(real_t<T> const &x)
{
return x.is_zero() ? 0 : x.is_negative() ? -1 : 1;
}

template<typename T> real_t<T> fast_log(real_t<T> const &x) template<typename T> real_t<T> fast_log(real_t<T> const &x)
{ {
/* This fast log method is tuned to work on the [1..2] range and /* This fast log method is tuned to work on the [1..2] range and


Loading…
Cancel
Save