CASM  1.1.0
A Clusters Approach to Statistical Mechanics
CASM_math.hh File Reference
#include "casm/global/definitions.hh"
#include <cassert>
#include <cmath>
#include <complex>
#include <vector>

Go to the source code of this file.

Classes

struct  CASM::CASM_TMP::IfIntegralTol< tol_type, true >
 
struct  CASM::CASM_TMP::IfIntegralTol< tol_type, false >
 
struct  CASM::CASM_TMP::IntegralLessThan< value_type >
 
struct  CASM::CASM_TMP::FloatingPointLessThan< value_type >
 
struct  CASM::FloatCompare
 

Namespaces

 CASM
 Main CASM namespace.
 
 CASM::CASM_TMP
 

Typedefs

template<typename T >
using CASM::CASM_TMP::TypedTol = IfIntegralTol< T, std::is_integral< T >::value >
 
template<typename T >
using CASM::CASM_TMP::MuchLessThan = typename std::conditional< std::is_integral< T >::value, IntegralLessThan< T >, FloatingPointLessThan< T > >::type
 

Functions

int CASM::round (double val)
 
template<typename T >
CASM::min (const T &A, const T &B)
 
template<typename T >
CASM::max (const T &A, const T &B)
 
template<typename T , typename std::enable_if< std::is_floating_point< T >::value, T >::type * = nullptr>
bool CASM::almost_zero (const T &val, double tol=TOL)
 If T is not integral, use std::abs(val) < tol;. More...
 
template<typename T , typename std::enable_if< std::is_floating_point< T >::value, T >::type * = nullptr>
bool CASM::almost_zero (const std::complex< T > &val, double tol=TOL)
 If std::complex<T>, use std::abs(val) < tol;. More...
 
template<typename T , typename std::enable_if<!std::is_integral< T >::value, T >::type * = nullptr>
bool CASM::almost_equal (const T &val1, const T &val2, double tol=TOL)
 If T is not integral, use almost_zero(val1 - val2, tol);. More...
 
template<typename T , typename std::enable_if< std::is_floating_point< T >::value, T >::type * = nullptr>
bool CASM::compare (const T &A, const T &B, double tol)
 Floating point comparison with tol, return A < B. More...
 
template<class InputIt1 , class InputIt2 >
bool CASM::float_lexicographical_compare (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, double tol)
 Floating point lexicographical comparison with tol. More...
 
template<typename T , typename std::enable_if< std::is_integral< T >::value, T >::type * = nullptr>
int CASM::sgn (T val)
 
template<typename T , typename std::enable_if< std::is_floating_point< T >::value, T >::type * = nullptr>
int CASM::float_sgn (T val, double compare_tol=TOL)
 
template<typename IntType >
IntType CASM::nchoosek (IntType n, IntType k)
 
template<typename IntType >
std::vector< IntType > CASM::index_to_kcombination (IntType ind, IntType k)
 
int CASM::dl_string_dist (const std::string &a, const std::string &b)
 Computes the Damerescau-Levenshtein distance – the number of edits (deletions, insertions, transpositions) to go from string 'a' to string 'b'. More...
 
double CASM::ran0 (int &idum)
 
int CASM::gcf (int i1, int i2)
 Find greatest common factor. More...
 
int CASM::lcm (int i1, int i2)
 Find least common multiple. More...
 
template<typename IntType >
IntType CASM::extended_gcf (IntType i1, IntType i2, IntType &p1, IntType &p2)
 Calculate greatest common factor of two integers, and bezout coefficients. More...
 
double CASM::gaussian (double a, double x, double b, double c)
 
double CASM::gaussian_moment (int expon, double sigma)
 
double CASM::gaussian_moment (int expon, double sigma, double x0)
 
void CASM::nearest_rational_number (double val, long &numerator, long &denominator, double tol=TOL)
 
std::string CASM::irrational_to_tex_string (double val, int lim, int max_pow=2)
 
std::string CASM::to_sequential_string (Index i, Index max_i, char prepend_char='0')
 
int CASM::mod (int a, int b)
 
double CASM::cuberoot (double number)