CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
CASM_math.hh File Reference
#include "casm/CASM_global_definitions.hh"
#include "casm/container/Array.hh"
#include <boost/math/special_functions/factorials.hpp>
#include <iostream>
#include <cmath>
#include <cstddef>
#include <complex>
#include <string>
#include <sstream>

Go to the source code of this file.

Classes

struct  CASM::FloatCompare
 

Namespaces

 CASM
 Main CASM namespace.
 
 CASM::HungarianMethod_impl
 
 Eigen
 

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 Derived >
bool CASM::almost_zero (const Eigen::MatrixBase< Derived > &val, double tol=TOL)
 Equivalent to almost_zero(double(val.norm()), 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...
 
bool CASM::float_lexicographical_compare (const Eigen::VectorXd &A, const Eigen::VectorXd &B, 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)
 
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...
 
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)
 
Eigen::VectorXd CASM::eigen_vector_from_string (const std::string &tstr, const int &size)
 
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...
 
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)
 
int CASM::mod (int a, int b)
 
double CASM::cuberoot (double number)
 
void CASM::poly_fit (Eigen::VectorXcd &xvec, Eigen::VectorXcd &yvec, Eigen::VectorXcd &coeffs, int degree)
 
Index CASM::which_unique_combination (const Array< Index > &input, const Array< Index >::X2 &unique, const Array< Index >::X2 &ind_equiv)
 
Index CASM::which_unique_combination (const Array< Index > &input, const Array< Index >::X2 &unique)
 
int CASM::lcm (const Array< int > &series)
 Find least common multiple. More...
 
ReturnArray< Array< int > > CASM::get_prime_factors (int target)
 
template<typename IntType >
IntType CASM::multinomial_coeff (const Array< IntType > &exponents)
 
template<typename IntType >
IntType CASM::multinomial_coeff (const Array< IntType > &exponents, const Array< Index > &sublist)
 
template<typename T >
bool CASM::almost_equal (const Array< T > &A, const Array< T > &B, double tol=TOL)
 
template<typename T >
ReturnArray< T > CASM::cum_sum (const Array< T > &arr)
 
template<typename Derived >
double CASM::length (const Eigen::MatrixBase< Derived > &value)
 
template<typename Derived >
ReturnArray< Index > CASM::partition_distinct_values (const Eigen::MatrixBase< Derived > &value, double tol=TOL)
 
double CASM::hungarian_method (const Eigen::MatrixXd &cost_matrix, std::vector< Index > &optimal_assignments, const double _tol)
 
void CASM::HungarianMethod_impl::hungarian_method (const Eigen::MatrixXd &cost_matrix_arg, std::vector< Index > &optimal_assignments, const double _tol)
 
template<typename Derived >
Eigen::Matrix< int,
Derived::RowsAtCompileTime,
Derived::ColsAtCompileTime > 
CASM::scale_to_int (const Eigen::MatrixBase< Derived > &val, double _tol=TOL)
 Take a vector of doubles, and multiply by some factor that turns it into a vector of integers (within a tolerance) More...
 
template<typename Derived1 , typename Derived2 >
bool Eigen::almost_equal (const Eigen::MatrixBase< Derived1 > &val1, const Eigen::MatrixBase< Derived2 > &val2, double tol=CASM::TOL)
 
template<typename Derived >
bool Eigen::is_symmetric (const Eigen::MatrixBase< Derived > &test_mat, double test_tol=CASM::TOL)
 
template<typename Derived >
bool Eigen::is_persymmetric (const Eigen::MatrixBase< Derived > &test_mat, double test_tol=CASM::TOL)
 
template<typename Derived >
bool Eigen::is_bisymmetric (const Eigen::MatrixBase< Derived > &test_mat, double test_tol=CASM::TOL)