Utility functions¶
-
template<typename ...
Ts>
autocart_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.
- Return
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 Parameters
Ts: The template pack for the arbitry containers.
- Parameters
vals: The pack of containers.
-
template<class
Hamiltonian, classParams, classCallable>
voidRegularLatticeLoop(RegistryDB ®, 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 HamiltonianParams: the type of the parameter spaceCallable: the type of the filter
- Parameters
reg: the registryoutbasedir: the base directory of the simulation outputhp: the Hamiltonian parametersfilter: the filter
Utility classes¶
-
template<class
RNG>
classRNGCache¶ 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>RNGCache(Args&&... args)¶ Constructor call.
We pass on all arguments to the RNG.
- Parameters
args: the parameters of the RNG.
-
~RNGCache()¶ Frees the memory of the cache.
-
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
- Return
a random integer
- Parameters
range:
-
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)
- Return
a random double from the interval [min, max)
- Parameters
max: the maximum floating point number to returnmin: the minimum floating point number to return
-
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.
-
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.
- Return
a vector of unsigned 64bit Integers that contain the state.
-
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
-
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_tN>
std::array<T, N>operator+(std::array<T, N> arg1, std::array<T, N> arg2)¶ Add two StateVectors elementwise: c=a+b.
- Return
- \[ \vec{c} = \vec{a} + \vec{b} \]
- Parameters
arg1: aarg2: b
-
template<class
T, std::size_tN>
std::array<T, N>operator-(std::array<T, N> arg1, std::array<T, N> arg2)¶ Subtract two StateVectors elementwise: c=a-b.
- Return
- \[ \vec{c} = \vec{a} - \vec{b} \]
- Parameters
arg1: aarg2: b
-
double
mult(const double &a, const double &b)¶ mult is a component-wise multiplication.
This is used e.g. in the Metropolis algorithm.
- See
Metropolis
- Return
- \[ c = a * b \]
- Parameters
a:b:
-
double
mult(const double &a, const int &b)¶ mult is a component-wise multiplication.
This is used e.g. in the Metropolis algorithm.
- See
Metropolis
- Return
- \[ c = a * b \]
- Parameters
a:b:
-
template<class
VecType, classT, std::size_tN>
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
Metropolis
- Return
- \[ c_i = a_i * b_i \]
- Parameters
a:b:
-
template<class
T, std::size_tN>
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
Metropolis
- Return
- \[ c_i = a * b_i \]
- Parameters
a:b:
-
template<class
T, std::size_tN>
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
Metropolis
- Return
- \[ c_i = a * b_i \]
- Parameters
a:b:
-
double
dot(const double &a, const double &b)¶ The dot/inner product.
- Return
- \[ c=a*b \]
- Parameters
a:b:
-
template<class
T, std::size_tN>
Tdot(const std::array<T, N> &a, const std::array<T, N> &b)¶ The dot/inner product.
- Return
- \[ c=\sum_i a_i b_i \]
- Parameters
a:b:
-
template<class
StateVector>
voidreflect(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
- Return
the modified, reflected vector.
- 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.
-
template<class
Container>
voidnormalize(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_tN>
std::ostream &operator<<(std::ostream &os, const std::array<T, N> &vec)¶ Dump array to stream.
- Return
A stream that now contains a textual representation of the array.
- Template Parameters
T: the type of the array elements.N: the length of the array.
- Parameters
os: the ouput streamvec: the array that we want to write to the screen.
System Tools¶
Functions
-
bool
fileexists(const std::string &fn)¶ Check if file exists.
This checks wether the file can be opened
- Return
true if it can be opened, else false
- Parameters
fn: the filename
-
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.
- Exceptions
std::runtime_error: If an unrecoverable error occurs. If the path exists nothing happens.