2013-07-19 00:44:05 +00:00
|
|
|
/*
|
2013-07-19 17:29:33 +00:00
|
|
|
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
2013-07-19 00:44:05 +00:00
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
2013-07-19 17:29:33 +00:00
|
|
|
Author: Leonardo de Moura
|
2013-08-06 01:57:09 +00:00
|
|
|
Soonho Kong
|
2013-07-19 00:44:05 +00:00
|
|
|
*/
|
|
|
|
#include <cfenv>
|
|
|
|
#include <cmath>
|
|
|
|
#include "numeric_traits.h"
|
|
|
|
|
|
|
|
namespace lean {
|
|
|
|
|
2013-08-06 01:57:09 +00:00
|
|
|
mpfr_rnd_t numeric_traits<double>::rnd = MPFR_RNDN;
|
|
|
|
mpfr_rnd_t numeric_traits<float>::rnd = MPFR_RNDN;
|
2013-07-19 17:29:33 +00:00
|
|
|
void set_processor_rounding(bool plus_inf) {
|
2013-07-19 00:44:05 +00:00
|
|
|
if (plus_inf)
|
|
|
|
std::fesetround(FE_UPWARD);
|
|
|
|
else
|
|
|
|
std::fesetround(FE_DOWNWARD);
|
|
|
|
}
|
|
|
|
|
|
|
|
void double_power(double & v, unsigned k) {
|
|
|
|
v = std::pow(v, k);
|
|
|
|
}
|
2013-08-06 01:57:09 +00:00
|
|
|
void float_power(float & v, unsigned k) {
|
|
|
|
v = std::pow(v, k);
|
|
|
|
}
|
2013-07-19 00:44:05 +00:00
|
|
|
|
|
|
|
};
|