10 #ifndef INCLUDED_FROM_NUMBERS_H
11 static_assert(
false,
"This file may only be included indirectly by numbers.h");
17 #include <type_traits>
28 return std::fpclassify(n) == FP_ZERO;
40 if constexpr (std::is_same<decltype(std::isnan(d)),
bool>::value) {
42 }
else if constexpr (std::is_same<decltype(std::isnan(d)),
int>::value) {
43 return std::isnan(d) != 0;
47 if constexpr (std::is_same<decltype(std::isinf(d)),
bool>::value) {
49 }
else if constexpr (std::is_same<decltype(std::isinf(d)),
int>::value) {
50 return std::isinf(d) != 0;
60 return std::fpclassify(std::modf(d, &tmp)) == FP_ZERO;
68 return sizeof(unsigned) * 8;
84 template<
typename Integer>
103 inline typename std::enable_if<std::is_arithmetic<typename remove_all<T>::type>::value, std::string>::type
toString(
const T& n,
bool ) {
104 return std::to_string(n);
127 inline double abs(
double n) {
153 inline double sin(
double in) {
157 inline double cos(
double in) {
161 inline double acos(
double in) {
165 inline double sqrt(
double in) {
177 inline double log(
double in) {
191 template<
typename Number>
193 static_assert(std::is_fundamental<Number>::value,
"Only works on native types.");
196 if (
sizeof(Number) == 2) {
198 }
else if (
sizeof(Number) == 4) {
200 }
else if (
sizeof(Number) == 8) {
203 assert(iterations > 0);
206 for (
uint i = 0; i < iterations; i++) {
207 res |= res >> (1u << i);
carl is the main namespace for the library.
T rationalize(const PreventConversion< mpq_class > &)
Interval< Number > acos(const Interval< Number > &i)
Interval< Number > ceil(const Interval< Number > &_in)
Method which returns the next larger integer of the passed number or the number itself,...
std::string toString(Relation r)
Interval< Number > abs(const Interval< Number > &_in)
Method which returns the absolute value of the passed number.
bool is_positive(const cln::cl_I &n)
Interval< Number > floor(const Interval< Number > &_in)
Method which returns the next smaller integer of this number or the number itself,...
Interval< Number > quotient(const Interval< Number > &_lhs, const Interval< Number > &_rhs)
Implements the division with remainder.
double pow(double in, uint exp)
cln::cl_I mod(const cln::cl_I &a, const cln::cl_I &b)
Calculate the remainder of the integer division.
double floor(double n)
Basic Operators.
Number highestPower(const Number &n)
Returns the highest power of two below n.
Interval< Number > exp(const Interval< Number > &i)
cln::cl_RA log10(const cln::cl_RA &n)
bool is_zero(const Interval< Number > &i)
Check if this interval is a point-interval containing 0.
Integer to_int(const Interval< Number > &_floatInterval)
Casts the Interval to an arbitrary integer type which has a constructor for a native int.
Interval< Number > cos(const Interval< Number > &i)
Interval< Number > sqrt(const Interval< Number > &i)
uint to_int< uint >(const cln::cl_I &n)
void divide(const cln::cl_I ÷nd, const cln::cl_I &divisor, cln::cl_I "ient, cln::cl_I &remainder)
Interval< Number > div(const Interval< Number > &_lhs, const Interval< Number > &_rhs)
Implements the division which assumes that there is no remainder.
Interval< Number > log(const Interval< Number > &i)
bool is_integer(const Interval< Number > &n)
bool is_negative(const cln::cl_I &n)
double to_double(const cln::cl_RA &n)
Converts the given fraction to a double.
Interval< Number > sin(const Interval< Number > &i)
std::pair< cln::cl_RA, cln::cl_RA > sqrt_safe(const cln::cl_RA &a)
Calculate the square root of a fraction.
sint to_int< sint >(const cln::cl_I &n)
std::size_t bitsize(const cln::cl_I &n)
Get the bit size of the representation of a integer.
cln::cl_I remainder(const cln::cl_I &a, const cln::cl_I &b)
Calculate the remainder of the integer division.
Interval< Number > pow(const Interval< Number > &i, Integer exp)