lean2/src/util/numerics/double.cpp
Leonardo de Moura 15f0899efb refactor(*): replace LEAN_THREAD_LOCAL with MK_THREAD_LOCAL_GET, the new macro uses the Boost thread_local_ptr instead of 'thread_local' directive
Motivation: clang++ on OSX does not support 'thread_local'.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-06-07 10:18:36 -07:00

31 lines
814 B
C++

/*
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Soonho Kong
*/
#include <cmath>
#include "util/thread.h"
#include "util/numerics/numeric_traits.h"
#include "util/numerics/double.h"
namespace lean {
MK_THREAD_LOCAL_GET_DEF(mpfr_rnd_t, get_g_rnd);
void set_double_rnd(bool plus_inf) {
get_g_rnd() = plus_inf ? MPFR_RNDU : MPFR_RNDD;
}
mpfr_rnd_t get_double_rnd() {
return get_g_rnd();
}
void double_power(double & v, unsigned k) { v = std::pow(v, k); }
void double_abs(double & v) { v = std::abs(v); }
void double_ceil(double & v) { v = std::ceil(v); }
void double_floor(double & v) { v = std::floor(v); }
static double g_zero = 0.0;
double const & numeric_traits<double>::zero() {
return g_zero;
}
};