27 template <
typename tol_type,
bool IsIntegral>
30 template <
typename tol_type>
34 tol_type
tol()
const {
return 0; }
37 template <
typename tol_type>
40 tol_type
tol() {
return m_tol; }
51 template <
typename value_type>
55 bool operator()(
const value_type &A,
const value_type &B)
const {
60 template <
typename value_type>
63 bool operator()(
const value_type &A,
const value_type &B)
const {
83 int round(
double val);
88 T
min(
const T &A,
const T &B) {
95 T
max(
const T &A,
const T &B) {
102 template <typename T, typename std::enable_if<std::is_floating_point<T>::value,
103 T>::type * =
nullptr>
105 return std::abs(val) < tol;
109 template <typename T, typename std::enable_if<std::is_floating_point<T>::value,
110 T>::type * =
nullptr>
112 return std::abs(val) < tol;
116 template <typename T, typename std::enable_if<std::is_integral<T>::value,
117 T>::type * =
nullptr>
125 template <typename T, typename std::enable_if<!std::is_integral<T>::value,
126 T>::type * =
nullptr>
132 template <typename T, typename std::enable_if<std::is_integral<T>::value,
133 T>::type * =
nullptr>
147 template <typename T, typename std::enable_if<std::is_floating_point<T>::value,
148 T>::type * =
nullptr>
149 bool compare(
const T &A,
const T &B,
double tol) {
161 template <
typename T>
168 template <
class InputIt1,
class InputIt2>
170 InputIt2 first2, InputIt2 last2,
173 return std::lexicographical_compare(first1, last1, first2, last2,
compare);
178 template <typename T, typename std::enable_if<std::is_integral<T>::value,
179 T>::type * =
nullptr>
181 return (T(0) < val) - (val < T(0));
186 template <typename T, typename std::enable_if<std::is_floating_point<T>::value,
187 T>::type * =
nullptr>
190 if (
compare(zeroval, val, compare_tol)) {
194 else if (
compare(val, zeroval, compare_tol)) {
206 template <
typename IntType>
211 if (n < 2 * k) k = n - k;
216 for (IntType i = 1; i < k + 1; i++) {
227 template <
typename IntType>
229 std::vector<IntType> result;
236 while (bigger <= ind) {
240 result.push_back(n - 1);
254 double ran0(
int &idum);
258 int gcf(
int i1,
int i2);
262 int lcm(
int i1,
int i2);
276 template <
typename IntType>
277 IntType
extended_gcf(IntType i1, IntType i2, IntType &p1, IntType &p2) {
280 IntType s1 =
sgn(i1);
281 IntType s2 =
sgn(i2);
283 IntType a = i1, b = i2;
286 IntType tp1(0), tp2(1), quotient;
295 p1 = p1 - quotient * tp1;
297 p2 = p2 - quotient * tp2;
303 return p1 * a + p2 * b;
310 double gaussian(
double a,
double x,
double b,
double c);
357 int mod(
int a,
int b);
Eigen::CwiseUnaryOp< decltype(Local::round_l< typename Derived::Scalar >), const Derived > round(const Eigen::MatrixBase< Derived > &val)
Round Eigen::MatrixXd.
typename std::conditional< std::is_integral< T >::value, IntegralLessThan< T >, FloatingPointLessThan< T > >::type MuchLessThan
bool almost_equal(ClusterInvariants const &A, ClusterInvariants const &B, double tol)
Check if ClusterInvariants are equal.
double gaussian_moment(int expon, double sigma)
IntType extended_gcf(IntType i1, IntType i2, IntType &p1, IntType &p2)
Calculate greatest common factor of two integers, and bezout coefficients.
bool compare(ClusterInvariants const &A, ClusterInvariants const &B, double tol)
Compare ClusterInvariants.
void nearest_rational_number(double val, long &numerator, long &denominator, double tol=TOL)
double cuberoot(double number)
IntType nchoosek(IntType n, IntType k)
void swap(ConfigDoF &A, ConfigDoF &B)
std::string to_sequential_string(Index i, Index max_i, char prepend_char='0')
int lcm(const Array< int > &series)
Find least common multiple.
bool almost_zero(const T &val, double tol=TOL)
If T is not integral, use std::abs(val) < tol;.
int dl_string_dist(const std::string &a, const std::string &b)
Computes the Damerescau-Levenshtein distance – the number of edits (deletions, insertions,...
int float_sgn(T val, double compare_tol=TOL)
bool float_lexicographical_compare(const Eigen::Ref< const Eigen::MatrixXd > &A, const Eigen::Ref< const Eigen::MatrixXd > &B, double tol)
Floating point lexicographical comparison with tol.
T min(const T &A, const T &B)
std::string irrational_to_tex_string(double val, int lim, int max_pow=2)
double gaussian(double a, double x, double b, double c)
INDEX_TYPE Index
For long integer indexing:
int gcf(int i1, int i2)
Find greatest common factor.
std::vector< IntType > index_to_kcombination(IntType ind, IntType k)
T max(const T &A, const T &B)
FloatingPointLessThan(value_type _tol=TOL)
bool operator()(const value_type &A, const value_type &B) const
IfIntegralTol(tol_type _tol)
IntegralLessThan(value_type)
bool operator()(const value_type &A, const value_type &B) const
FloatCompare(double _tol)
bool operator()(const T &A, const T &B) const