Utilities#
-
namespace cimod
Functions
-
template<class C_key, class C_value, class Hash>
void insert_or_assign(std::unordered_map<C_key, C_value, Hash> &um, const C_key &key, const C_value &val)# Insert or assign a element of unordered_map (for C++14 or C++11)
- Template Parameters:
C_key –
C_value –
- Parameters:
um –
key –
val –
-
template<typename IndexType>
void FormatPolynomialKey(std::vector<IndexType> *key, const Vartype &vartype)# Format the input key: for example, {2,1,1}–>{1,2} for BINARY variable and {2,1,1}–>{2} for SPIN variable.
- Template Parameters:
IndexType – Used to represent the indices of variables
- Parameters:
key – This may be formatted.
vartype – The model’s type. cimod::Vartype::SPIN or cimod::Vartype::BINARY.
-
cimod::Vartype ToCimodVartype(const std::string &vartype_str)#
Convert vartype from string to cimod::Vartype.
- Parameters:
vartype_str – “SPIN” or “BINARY”
- Returns:
cimod::Vartype::SPIN or cimod::Vartype::BINARY
-
template<typename IntegerType>
void CheckVariables(const std::vector<IntegerType> &configurations, const Vartype &vartype)# Convert vartype from string to cimod::Vartype.
- Template Parameters:
IntegerType – The type of spin/binary configuration
- Parameters:
configurations – The spin/binary configuration
vartype – The model’s type. cimod::Vartype::SPIN or cimod::Vartype::BINARY.
-
template<class C_key, class C_value, class Hash>