cp-includes

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub rsalesc/cp-includes

:warning: geometry/GeometryEpsilon.cpp

Depends on

Required by

Code

#ifndef _LIB_GEOMETRY_EPSILON
#define _LIB_GEOMETRY_EPSILON
#include "../Epsilon.cpp"
#include <bits/stdc++.h>

#define GEOMETRY_EPSILON(T, x)                                                 \
  template <>                                                                  \
  lib::Epsilon<T> *lib::geo::GeometryEpsilon<T>::eps =                         \
      new lib::Epsilon<T>((x));

#define GEOMETRY_COMPARE0(T, x) GeometryEpsilon<T>()((x))
#define GEOMETRY_COMPARE(T, x, y) GeometryEpsilon<T>()((x), (y))

namespace lib {
using namespace std;
namespace geo {
template <typename T> struct GeometryEpsilon {
  static Epsilon<T> *eps;
  template <typename G> int operator()(G a, G b = 0) const {
    return (*eps)(a, b);
  }
};

GEOMETRY_EPSILON(int, 0);
GEOMETRY_EPSILON(long, 0);
GEOMETRY_EPSILON(long long, 0);
} // namespace geo
} // namespace lib

#endif
#line 1 "geometry/GeometryEpsilon.cpp"


#line 1 "Epsilon.cpp"


#include <bits/stdc++.h>

namespace lib {
using namespace std;

template <typename T = double> struct Epsilon {
  T eps;
  constexpr Epsilon(T eps = 1e-9) : eps(eps) {}

  template <typename G,
            typename enable_if<is_floating_point<G>::value>::type * = nullptr>
  int operator()(G a, G b = 0) const {
    return a + eps < b ? -1 : (b + eps < a ? 1 : 0);
  }

  template <typename G,
            typename enable_if<!is_floating_point<G>::value>::type * = nullptr>
  int operator()(G a, G b = 0) const {
    return a < b ? -1 : (a > b ? 1 : 0);
  }

  template <typename G,
            typename enable_if<is_floating_point<G>::value>::type * = nullptr>
  bool null(G a) const {
    return (*this)(a) == 0;
  }

  template <typename G,
            typename enable_if<!is_floating_point<G>::value>::type * = nullptr>
  bool null(G a) const {
    return a == 0;
  }
};
} // namespace lib


#line 5 "geometry/GeometryEpsilon.cpp"

#define GEOMETRY_EPSILON(T, x)                                                 \
  template <>                                                                  \
  lib::Epsilon<T> *lib::geo::GeometryEpsilon<T>::eps =                         \
      new lib::Epsilon<T>((x));

#define GEOMETRY_COMPARE0(T, x) GeometryEpsilon<T>()((x))
#define GEOMETRY_COMPARE(T, x, y) GeometryEpsilon<T>()((x), (y))

namespace lib {
using namespace std;
namespace geo {
template <typename T> struct GeometryEpsilon {
  static Epsilon<T> *eps;
  template <typename G> int operator()(G a, G b = 0) const {
    return (*eps)(a, b);
  }
};

GEOMETRY_EPSILON(int, 0);
GEOMETRY_EPSILON(long, 0);
GEOMETRY_EPSILON(long long, 0);
} // namespace geo
} // namespace lib
Back to top page