79 #include <unordered_map>
89 #include "../storage/stream.h"
90 #include "../geometry/point.h"
95 typedef unsigned long long ull;
96 typedef unsigned long long llong;
98 const static double PI = 3.1415926535897932385;
100 static bool _quiet =
false;
106 template<
typename REAL>
inline REAL
clamp( REAL x, REAL l, REAL r )
108 return (x < l) ? l : ( (x > r) ? r : x );
111 template<
typename REAL>
inline REAL
sgn( REAL x )
116 template<u
int N>
inline double powr(
const double x ) {
117 return powr<2>( powr<N/2>( x ) ) * powr<N%2>(x);
120 template<>
inline double powr<2>(
const double x ) {
124 template<>
inline double powr<1>(
const double x ) {
130 (std::fabs(x-y) < std::numeric_limits<T>::epsilon() * std::fabs(x+y)) ||
134 template<
typename T>
inline T frexp10(
T arg,
int &exp) {
136 else exp = 1 +
static_cast<int>(std::floor(std::log10(std::fabs(arg))));
137 return arg * std::pow(10, -(exp));
140 template<
typename T>
inline T frexp10(
T arg,
long &exp) {
142 else exp = 1 +
static_cast<long>(std::floor(std::log10(std::fabs(arg))));
143 return arg * std::pow(10, -(exp));
147 return std::numeric_limits<T>::epsilon() * std::fabs(x);
151 template<>
inline double powr<0>( __attribute__((unused))
const double x ) {
153 template<>
inline double powr<0>(
const double x ) {
158 template<
typename T, u
int D>
161 for(
uint i=0; i<D; ++i ) stream << p[i];
165 template<
typename T, u
int D>
168 for(
uint i=0; i<D; ++i ) stream >> p[i];
172 template<
typename T1,
typename T2,
typename T3>
189 return i != another.
i ||
j != another.
j ||
k != another.
k;
195 return i < another.
i || (
i == another.
i && (
j < another.
j || (
j == another.
j &&
k < another.
k ) ) );
u u u u u u min
Definition: dim.h:289
double powr< 0 >(const double x)
Definition: util.h:153
bool almost_equal(T x, T y)
Definition: util.h:128
T frexp10(T arg, int &exp)
Definition: util.h:134
T threshold(T x)
Definition: util.h:146
istream & operator>>(istream &stream, smalluint &sml)
Definition: comm_tcp.h:103
double powr< 1 >(const double x)
Definition: util.h:124
ostream & operator<<(ostream &stream, const smalluint &sml)
Definition: comm_tcp.h:127
double powr< 2 >(const double x)
Definition: util.h:120
double powr(const double x)
Definition: util.h:116
unsigned long long llong
Definition: util.h:96
unsigned long long ull
Definition: util.h:95
REAL clamp(REAL x, REAL l, REAL r)
Definition: util.h:106
REAL sgn(REAL x)
Definition: util.h:111
unsigned int uint
Definition: util.h:94
void set_quiet(bool q)
Definition: util.h:102
bool operator==(const triple &another) const
Definition: util.h:191
bool operator!=(const triple &another) const
Definition: util.h:188
T2 j
Definition: util.h:175
T3 k
Definition: util.h:176
triple(const triple &another)
Definition: util.h:179
triple(T1 _i, T2 _j, T3 _k)
Definition: util.h:178
triple()
Definition: util.h:177
T1 i
Definition: util.h:174
bool operator<(const triple &another) const
Definition: util.h:194
triple & operator=(const triple &another)
Definition: util.h:181