Browse Source

ufiodsfiodsifods

legacy
Sam Hocevar 7 years ago
parent
commit
60ee86f908
2 changed files with 8 additions and 3 deletions
  1. +4
    -3
      src/lol/math/real.h
  2. +4
    -0
      src/math/real.cpp

+ 4
- 3
src/lol/math/real.h View File

@@ -109,7 +109,6 @@ public:
template<int K> friend Real<K> frexp(Real<K> const &x, int *exp); template<int K> friend Real<K> frexp(Real<K> const &x, int *exp);
template<int K> friend Real<K> ldexp(Real<K> const &x, int exp); template<int K> friend Real<K> ldexp(Real<K> const &x, int exp);
template<int K> friend Real<K> modf(Real<K> const &x, Real<K> *iptr); template<int K> friend Real<K> modf(Real<K> const &x, Real<K> *iptr);
template<int K> friend Real<K> ulp(Real<K> const &x);
template<int K> friend Real<K> nextafter(Real<K> const &x, Real<K> const &y); template<int K> friend Real<K> nextafter(Real<K> const &x, Real<K> const &y);


/* Power functions */ /* Power functions */
@@ -200,11 +199,15 @@ public:
static Real<N> const& R_SQRT3(); static Real<N> const& R_SQRT3();
static Real<N> const& R_SQRT1_2(); static Real<N> const& R_SQRT1_2();


static Real<N> const& R_MIN();
static Real<N> const& R_MAX();

/* XXX: changing this requires tuning real::fres (the number of /* XXX: changing this requires tuning real::fres (the number of
* Newton-Raphson iterations) and real::print (the number of printed * Newton-Raphson iterations) and real::print (the number of printed
* digits) */ * digits) */
static int const BIGITS = N; static int const BIGITS = N;
static int const BIGIT_BITS = 32; static int const BIGIT_BITS = 32;
static int const TOTAL_BITS = BIGITS * BIGIT_BITS;


private: private:
uint32_t *m_mantissa; uint32_t *m_mantissa;
@@ -274,7 +277,6 @@ template<int K> Real<K> log10(Real<K> const &x);
template<int K> Real<K> frexp(Real<K> const &x, int *exp); template<int K> Real<K> frexp(Real<K> const &x, int *exp);
template<int K> Real<K> ldexp(Real<K> const &x, int exp); template<int K> Real<K> ldexp(Real<K> const &x, int exp);
template<int K> Real<K> modf(Real<K> const &x, Real<K> *iptr); template<int K> Real<K> modf(Real<K> const &x, Real<K> *iptr);
template<int K> Real<K> ulp(Real<K> const &x);
template<int K> Real<K> nextafter(Real<K> const &x, Real<K> const &y); template<int K> Real<K> nextafter(Real<K> const &x, Real<K> const &y);
template<int K> Real<K> inverse(Real<K> const &x); template<int K> Real<K> inverse(Real<K> const &x);
template<int K> Real<K> sqrt(Real<K> const &x); template<int K> Real<K> sqrt(Real<K> const &x);
@@ -314,7 +316,6 @@ template<> real log10(real const &x);
template<> real frexp(real const &x, int *exp); template<> real frexp(real const &x, int *exp);
template<> real ldexp(real const &x, int exp); template<> real ldexp(real const &x, int exp);
template<> real modf(real const &x, real *iptr); template<> real modf(real const &x, real *iptr);
template<> real ulp(real const &x);
template<> real nextafter(real const &x, real const &y); template<> real nextafter(real const &x, real const &y);
template<> real inverse(real const &x); template<> real inverse(real const &x);
template<> real sqrt(real const &x); template<> real sqrt(real const &x);


+ 4
- 0
src/math/real.cpp View File

@@ -34,6 +34,7 @@ namespace lol


static real fast_log(real const &x); static real fast_log(real const &x);
static real fast_pi(); static real fast_pi();
static real fast_min();


#define LOL_CONSTANT_GETTER(name, value) \ #define LOL_CONSTANT_GETTER(name, value) \
template<> real const& real::name() \ template<> real const& real::name() \
@@ -48,6 +49,9 @@ LOL_CONSTANT_GETTER(R_2, (real)2.0);
LOL_CONSTANT_GETTER(R_3, (real)3.0); LOL_CONSTANT_GETTER(R_3, (real)3.0);
LOL_CONSTANT_GETTER(R_10, (real)10.0); LOL_CONSTANT_GETTER(R_10, (real)10.0);


LOL_CONSTANT_GETTER(R_MAX, ldexp(R_1(), (1 << 30));
LOL_CONSTANT_GETTER(R_MIN, ldexp(R_1(), 1 - (1 << 30));

LOL_CONSTANT_GETTER(R_LN2, fast_log(R_2())); LOL_CONSTANT_GETTER(R_LN2, fast_log(R_2()));
LOL_CONSTANT_GETTER(R_LN10, log(R_10())); LOL_CONSTANT_GETTER(R_LN10, log(R_10()));
LOL_CONSTANT_GETTER(R_LOG2E, inverse(R_LN2())); LOL_CONSTANT_GETTER(R_LOG2E, inverse(R_LN2()));


Loading…
Cancel
Save