Utility functions

template<typename ...Ts>
auto cart_prod(Ts... vals)

This creates a cartesian product of an arbitrary number of input containers.

They need to conform to the basic STL Interface. They should expose value_type and provide iterators.

Template Parameters:

Ts – The template pack for the arbitry containers.

Parameters:

vals – The pack of containers.

Returns:

A vector of tuples. Each tuple contains an entry from the cartesian product. FIXME: unclear what happens if one of the parameters themselves is supposed to be a tuple.

template<class Hamiltonian, class Params, class Callable>
void RegularLatticeLoop(RegistryDB &reg, std::string configfile, std::string name, const std::string outbasedir, const std::vector<Params> &hp, Callable filter)

Helper to execute a series of simulations on regular hypercubic lattices.

Template Parameters:
  • Hamiltonian – the type of the Hamiltonian

  • Params – the type of the parameter space

  • Callable – the type of the filter

Parameters:
  • reg – the registry

  • outbasedir – the base directory of the simulation output

  • hp – the Hamiltonian parameters

  • filter – the filter

Utility classes

template<class RNG>
class RNGCache

A cache for generated random values.

This implements a cache for random values. If the cache is empty we refill it with new random values from a user defined RNG. Also RNGName how to get a proper name for I/O.

Template Parameters:

RNG – The RNG that the user wishes to use.

Public Functions

template<class ...Args>
inline RNGCache(Args&&... args)

Constructor call.

We pass on all arguments to the RNG.

Parameters:

args – the parameters of the RNG.

inline ~RNGCache()

Frees the memory of the cache.

inline uint64_t integer(uint64_t range) noexcept

Get a random uniform integer from [0, range].

By a cmake switch the debiasing of integers can be enabled. https://arxiv.org/abs/1805.10941

Parameters:

range

Returns:

a random integer

inline auto integer() noexcept

Get a random uniform Integer from [0, max()].

Returns:

a random integer

inline auto real(double max = 1.0, double min = 0.0) noexcept

Get a random uniform float in the range (min, max).

If no arguments are specified this gives a double from [0,1)

Parameters:
  • max – the maximum floating point number to return

  • min – the minimum floating point number to return

Returns:

a random double from the interval [min, max)

inline void fillcache() noexcept

Fill the cache.

Can also be used to flush the cache, i.e reset the cache after initally setting the state of the RNG.

inline std::vector<u_int64_t> dumpstate()

Dump the internal state of the RNG in a manner that it can be fully constructed from it.

We assume that the RNG supports the same operations as those from the STL.

Returns:

a vector of unsigned 64bit Integers that contain the state.

inline void setstate(std::vector<u_int64_t> &vec)

Set the state of the RNG.

This sets the internal state of the RNG. The C++11 STL RNGs dump their state as a sequence of unsigned 64bit integers. We assume that we get this state as a vector.

Parameters:

vec – A vector containing a sequence of ints for the internal state of the RNG.

Public Static Functions

static inline constexpr auto max() noexcept

The maximum integer that we support.

Filters

Variables

auto defaultfilter = [](auto p){auto& mp = std::get<1>(p);auto& hp = std::get<2>(p);std::string str_repid = std::to_string(mp.repid);std::string str_beta  = "beta"+std::to_string(std::get<0>(hp));mp.outname = str_beta+"_"+str_repid;return p;}
auto xxzfilter = [](auto p){auto& mp = std::get<1>(p);auto& hp = std::get<2>(p);std::string str_repid = std::to_string(mp.repid);std::string str_beta  = "beta"+std::to_string(std::get<0>(hp));std::string str_extf  = "extf"+std::to_string(std::get<1>(hp));mp.outname = str_beta+"_"+str_extf+"_"+str_repid;return p;}
auto sshfilter = [](auto p){auto& mp = p.first;auto& hp = p.second;std::string str_repid = std::to_string(mp.repid);std::string str_k     = "k"+std::to_string(std::get<2>(hp));std::string str_dtau  = "dtau"+std::to_string(std::get<3>(hp));mp.outname = mp.outname+"_"+str_k+"_"+str_dtau+"_"+str_repid;return p;}

State Vector Math

Elementary state vector calculus.

Functions

template<class T, std::size_t N>
inline std::array<T, N> operator+(std::array<T, N> arg1, std::array<T, N> arg2)

Add two StateVectors elementwise: c=a+b.

Parameters:
  • arg1 – a

  • arg2 – b

Returns:

\[ \vec{c} = \vec{a} + \vec{b} \]

template<class T, std::size_t N>
inline std::array<T, N> operator-(std::array<T, N> arg1, std::array<T, N> arg2)

Subtract two StateVectors elementwise: c=a-b.

Parameters:
  • arg1 – a

  • arg2 – b

Returns:

\[ \vec{c} = \vec{a} - \vec{b} \]

inline double mult(const double &a, const double &b)

mult is a component-wise multiplication.

This is used e.g. in the Metropolis algorithm.

See also

Metropolis

Parameters:
  • a

  • b

Returns:

\[ c = a * b \]

inline double mult(const double &a, const int &b)

mult is a component-wise multiplication.

This is used e.g. in the Metropolis algorithm.

See also

Metropolis

Parameters:
  • a

  • b

Returns:

\[ c = a * b \]

template<class VecType, class T, std::size_t N>
inline std::array<T, N> mult(const VecType &a, const std::array<T, N> &b)

mult is a component-wise multiplication.

This is used e.g. in the Metropolis algorithm.

See also

Metropolis

Parameters:
  • a

  • b

Returns:

\[ c_i = a_i * b_i \]

template<class T, std::size_t N>
inline std::array<T, N> mult(const int &a, const std::array<T, N> &b)

mult is a component-wise multiplication.

This is used e.g. in the Metropolis algorithm.

See also

Metropolis

Parameters:
  • a

  • b

Returns:

\[ c_i = a * b_i \]

template<class T, std::size_t N>
inline std::array<T, N> mult(const double &a, const std::array<T, N> &b)

mult is a component-wise multiplication.

This is used e.g. in the Metropolis algorithm.

See also

Metropolis

Parameters:
  • a

  • b

Returns:

\[ c_i = a * b_i \]

inline double dot(const double &a, const double &b)

The dot/inner product.

Parameters:
  • a

  • b

Returns:

\[ c=a*b \]

template<class T, std::size_t N>
inline T dot(const std::array<T, N> &a, const std::array<T, N> &b)

The dot/inner product.

Parameters:
  • a

  • b

Returns:

\[ c=\sum_i a_i b_i \]

template<class StateVector>
inline void reflect(StateVector &vec, const StateVector mirror)

Reflect a StateVector along a plane.

This takes a State vector and a plane defined by its normal vector and performs a reflection along it

Template Parameters:

StateVector – the Container used for storing the vectors.

Parameters:
  • vec – the state vector that should be reflected.

  • mirror – The normal vector of the plane used for reflecting.

Returns:

the modified, reflected vector.

template<class Container>
inline void normalize(Container &a)

Normalize vector.

This normalizes a vector such that it has unit length.

Template Parameters:

Container – The Container used for storing the vector.

Parameters:

a – the vector to normalize

template<typename T, std::size_t N>
std::ostream &operator<<(std::ostream &os, const std::array<T, N> &vec)

Dump array to stream.

Template Parameters:
  • T – the type of the array elements.

  • N – the length of the array.

Parameters:
  • os – the ouput stream

  • vec – the array that we want to write to the screen.

Returns:

A stream that now contains a textual representation of the array.

System Tools

Functions

inline bool fileexists(const std::string &fn)

Check if file exists.

This checks wether the file can be opened

Parameters:

fn – the filename

Returns:

true if it can be opened, else false

inline void makeDir(const std::string path)

Create Directory.

This creates a directory. If the path exists nothing happens.

Parameters:

path – the path of the directory that should be created.

Throws:

std::runtime_error – If an unrecoverable error occurs. If the path exists nothing happens.