![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
About aGrUM utilities. More...
Topics | |
| Math | |
| All the maths you'll need. | |
| Configuration | |
| About aGrUM configuration. | |
| Smart Pointers | |
| RefPtr are a replacement for the usual pointers: they keep track of the number of "smart" pointers pointing to a given element. | |
| template<typename T1, typename T2> | |
| using | gum::forbidden_type = typename std::enable_if< !std::is_same< T1, T2 >::value, int >::type |
| Forbidden_type<T1,T2> return the "int" type if T1 and T2 are of the same type, else nothing. | |
| bool | gum::Memcmp (const void *const in_, const void *const out_, unsigned long size) |
| Cross-platform replacement for memcmp. | |
| void | gum::_atexit_ () |
| Used for debug purpose. | |
| template<typename T1, typename T2> | |
| ostream & | std::operator<< (ostream &stream, const pair< T1, T2 > &val) |
| 'std::cout<<' operator for pairs. | |
| template<typename T0, typename... T> | |
| std::ostream & | std::operator<< (std::ostream &os, const std::tuple< T0, T... > &t) |
| 'std::cout<<' operator for vectors. | |
| template<typename T> | |
| ostream & | std::operator<< (ostream &stream, const vector< T > &val) |
| 'std::cout<<' operator for vectors. | |
| template<typename T> | |
| bool | std::hasUniqueElts (std::vector< T > const &x) |
| Idx | gum::randomValue (const Size max=2) |
| Returns a random Idx between 0 and max-1 included. | |
| double | gum::randomProba () |
| Returns a random double between 0 and 1 included (i.e. | |
| template<typename GUM_SCALAR> | |
| std::vector< GUM_SCALAR > | gum::randomDistribution (Size n) |
| Return a random discrete distribution. | |
| unsigned int | gum::randomGeneratorSeed () |
| Returns the aGrUM's seed used by the std::generators. | |
| unsigned int | gum::currentRandomGeneratorValue () |
| returns the current generator's value | |
| void | gum::initRandom (unsigned int seed=0) |
| Initialize random generator seed. | |
| std::mt19937 & | gum::randomGenerator () |
| define a random_engine with correct seed | |
| std::string | gum::getUniqueFileName () |
| Returns a path to a unique file name. | |
| bool | gum::endsWith (std::string const &value, std::string const &ending) |
| Returns true if value ends with ending. | |
| std::vector< std::string > | gum::split (const std::string &orig, const std::string &delimiter) |
| Split str using the delimiter. | |
| std::string | gum::replace (const std::string &s, const std::string &val, const std::string &new_val) |
| not usable for gcc 4.8 std::vector<std::string> split( const std::string& orig,
const std::string& delimiter ) { | |
| bool | gum::isIntegerWithResult (const std::string &val, int *res) |
| return true is a string contains an integer value | |
| bool | gum::isNumericalWithResult (const std::string &val, double *res) |
| return true is a string contains a numerical (double) value | |
| std::string | gum::toLower (std::string str) |
| Returns the lowercase version of str. | |
| bool | gum::isInteger (const std::string &val) |
| return true is a string contains an integer value | |
| bool | gum::isNumerical (const std::string &val) |
| return true is a string contains a numerical (double) value | |
| void | gum::ltrim (std::string &s) |
| trim from start (in place) | |
| void | gum::rtrim (std::string &s) |
| trim from end (in place) | |
| void | gum::trim (std::string &s) |
| trim from both ends (in place) | |
| std::string | gum::trim_copy (const std::string &s) |
| trim from both ends (copying) | |
| std::string | gum::remove_newline (const std::string &s) |
| remove all newlines in a string | |
| template<typename T> | |
| std::string | gum::compact_tostr (T value) |
| Returns a path to a unique file name. | |
About aGrUM utilities.
| using gum::forbidden_type = typename std::enable_if< !std::is_same< T1, T2 >::value, int >::type |
Forbidden_type<T1,T2> return the "int" type if T1 and T2 are of the same type, else nothing.
Use it as a guard in template specification :
| T1 | The type to test for. |
| T2 | The expected type. |
Definition at line 143 of file utils_misc.h.
| void gum::_atexit_ | ( | ) |
Used for debug purpose.
Definition at line 67 of file utils_misc.cpp.
|
inline |
Returns a path to a unique file name.
Definition at line 161 of file utils_string.h.
| INLINE unsigned int gum::currentRandomGeneratorValue | ( | ) |
returns the current generator's value
Definition at line 85 of file utils_random_inl.h.
References gum::_rand_namespace_::generator().
| bool gum::endsWith | ( | std::string const & | value, |
| std::string const & | ending ) |
Returns true if value ends with ending.
Definition at line 83 of file utils_string.cpp.
Referenced by gum::prm::o3prm::O3NameSolver< GUM_SCALAR >::resolveClass(), gum::prm::o3prm::O3NameSolver< GUM_SCALAR >::resolveClassElement(), gum::prm::o3prm::O3NameSolver< GUM_SCALAR >::resolveInterface(), gum::prm::o3prm::O3NameSolver< GUM_SCALAR >::resolveSlotType(), and gum::prm::o3prm::O3NameSolver< GUM_SCALAR >::resolveType().
| std::string gum::getUniqueFileName | ( | ) |
Returns a path to a unique file name.
Definition at line 63 of file utils_string.cpp.
References randomValue().
Referenced by gum::credal::CredalNet< GUM_SCALAR >::_H2Vlrs_().
| bool std::hasUniqueElts | ( | std::vector< T > const & | x | ) |
check if a vector consists in unique values (no duplicate).
| T | The vector's elements type. |
| x | the vector |
Definition at line 108 of file utils_misc_tpl.h.
| INLINE void gum::initRandom | ( | unsigned int | seed = 0 | ) |
Initialize random generator seed.
Definition at line 77 of file utils_random_inl.h.
References gum::_rand_namespace_::generator().
| INLINE bool gum::isInteger | ( | const std::string & | val | ) |
return true is a string contains an integer value
| s | A string |
Definition at line 95 of file utils_string_inl.h.
References isIntegerWithResult().
Referenced by fastVariable().
| bool gum::isIntegerWithResult | ( | const std::string & | val, |
| int * | res ) |
return true is a string contains an integer value
| s | A string |
Definition at line 124 of file utils_string.cpp.
Referenced by isInteger().
| INLINE bool gum::isNumerical | ( | const std::string & | val | ) |
return true is a string contains a numerical (double) value
| s | A string |
Definition at line 98 of file utils_string_inl.h.
References isNumericalWithResult().
Referenced by fastVariable().
return true is a string contains a numerical (double) value
| s | A string * |
Definition at line 139 of file utils_string.cpp.
Referenced by isNumerical().
| INLINE void gum::ltrim | ( | std::string & | s | ) |
trim from start (in place)
| s | A string |
Definition at line 65 of file utils_string_inl.h.
Referenced by trim().
| bool gum::Memcmp | ( | const void *const | in_, |
| const void *const | out_, | ||
| unsigned long | size ) |
Cross-platform replacement for memcmp.
| in_ | A pointer to the block of memory to copy. |
| out_ | A pointer to the block of memory receiving copy. |
| size | Number of bytes to copy. |
Definition at line 57 of file utils_misc.cpp.
| ostream & std::operator<< | ( | ostream & | stream, |
| const pair< T1, T2 > & | val ) |
'std::cout<<' operator for pairs.
| T1 | The pair's first's type. |
| T2 | The pair's second's type. |
| stream | The stream to print to. |
| val | The pair to print to stream. |
Definition at line 78 of file utils_misc_tpl.h.
| ostream & std::operator<< | ( | ostream & | stream, |
| const vector< T > & | val ) |
'std::cout<<' operator for vectors.
| T | The vector's elements type. |
| stream | The stream to print to. |
| val | The std::vector to print to stream. |
Definition at line 62 of file utils_misc_tpl.h.
| std::ostream & std::operator<< | ( | std::ostream & | os, |
| const std::tuple< T0, T... > & | t ) |
'std::cout<<' operator for vectors.
| stream | The stream to print to. |
| t | The std::tuple |
| val | The std::vector to print to stream. |
Definition at line 100 of file utils_misc_tpl.h.
References std::_auxiliary_print_tuple_< N >::print().
| std::vector< GUM_SCALAR > gum::randomDistribution | ( | Size | n | ) |
Return a random discrete distribution.
| n | The number of modalities for the ditribution. |
| GUM_SCALAR | The type used for representing probabilities. |
Definition at line 54 of file utils_random_tpl.h.
References randomProba().
Referenced by gum::Tensor< GUM_SCALAR >::randomCPT(), and gum::Tensor< GUM_SCALAR >::randomDistribution().
| INLINE std::mt19937 & gum::randomGenerator | ( | ) |
define a random_engine with correct seed
Definition at line 96 of file utils_random_inl.h.
References gum::_rand_namespace_::generator().
Referenced by gum::MultiDimFunctionGraphGenerator::_generateVarPos_(), gum::Dirichlet::operator()(), gum::Dirichlet::operator()(), and gum::learning::BNDatabaseGenerator< GUM_SCALAR >::setRandomVarOrder().
| INLINE unsigned int gum::randomGeneratorSeed | ( | ) |
Returns the aGrUM's seed used by the std::generators.
Definition at line 89 of file utils_random_inl.h.
| INLINE double gum::randomProba | ( | ) |
Returns a random double between 0 and 1 included (i.e.
a proba).
Definition at line 71 of file utils_random_inl.h.
References gum::_rand_namespace_::generator().
Referenced by gum::MultiDimFunctionGraphGenerator::_createLeaf_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateClassDag_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateClassDag_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateSystem_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateSystem_(), gum::MCBayesNetGenerator< GUM_SCALAR, SimpleCPTGenerator, SimpleCPTDisturber >::disturbReducCPT(), gum::Tensor< GUM_SCALAR >::draw(), gum::learning::BNDatabaseGenerator< GUM_SCALAR >::drawSamples(), gum::MultiDimFunctionGraphGenerator::generate(), gum::SimpleBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::generateBN(), gum::InfluenceDiagramGenerator< GUM_SCALAR >::generateID(), gum::SimpleUTGenerator::generateUT(), gum::SimpleUTGenerator::generateUT(), gum::FMDPSimulator::perform(), gum::Tensor< GUM_SCALAR >::random(), randomDistribution(), and gum::E_GreedyDecider::stateOptimalPolicy().
Returns a random Idx between 0 and max-1 included.
Definition at line 65 of file utils_random_inl.h.
References gum::_rand_namespace_::generator().
Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_chooseCloseNodes_(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_createPartTree_(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_createTree_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateClass_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateClassDag_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateClassDag_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateClasses_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateCluster_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateSystem_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateSystem_(), gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::_verticesSampling_(), gum::IBayesNetGenerator< GUM_SCALAR, SimpleCPTGenerator >::fillCPT(), gum::MultiDimFunctionGraphGenerator::generate(), gum::SimpleBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::generateBN(), gum::InfluenceDiagramGenerator< GUM_SCALAR >::generateID(), getUniqueFileName(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInferenceByRandomOrder_(), gum::GibbsOperator< GUM_SCALAR >::nextSample(), gum::AbstractSimulator::randomState_(), gum::SDYNA::takeAction(), and gum::IncrementalGraphLearner< AttributeSelection, isScalar >::updateNode_().
| INLINE std::string gum::remove_newline | ( | const std::string & | s | ) |
remove all newlines in a string
| s | A string |
Definition at line 87 of file utils_string_inl.h.
Referenced by gum::BayesNet< GUM_SCALAR >::fastPrototype(), and gum::InfluenceDiagram< GUM_SCALAR >::fastPrototype().
| std::string gum::replace | ( | const std::string & | s, |
| const std::string & | val, | ||
| const std::string & | new_val ) |
not usable for gcc 4.8 std::vector<std::string> split( const std::string& orig, const std::string& delimiter ) {
Replace val by new_val in s.
std::regex rgx( delimiter );
std::sregex_token_iterator first{begin( orig ), end( orig ), rgx, -1}, last;
return {first, last}; }
| s | A string. |
| val | The value to replace in s. |
| new_val | The new value to replace val in s. |
Definition at line 112 of file utils_string.cpp.
Referenced by gum::prm::o3prm::O3prmReader< GUM_SCALAR >::_clean_().
| INLINE void gum::rtrim | ( | std::string & | s | ) |
trim from end (in place)
| s | A string |
Definition at line 72 of file utils_string_inl.h.
Referenced by trim().
| std::vector< std::string > gum::split | ( | const std::string & | orig, |
| const std::string & | delimiter ) |
Split str using the delimiter.
| orig | searched string |
| delimiter | string |
Definition at line 88 of file utils_string.cpp.
Referenced by gum::BayesNet< GUM_SCALAR >::fastPrototype(), gum::InfluenceDiagram< GUM_SCALAR >::fastPrototype(), and fastVariable().
| INLINE std::string gum::toLower | ( | std::string | str | ) |
Returns the lowercase version of str.
Definition at line 58 of file utils_string_inl.h.
Referenced by gum::AggregatorDecomposition< GUM_SCALAR >::addAggregator_(), and gum::prm::PRMAggregate< GUM_SCALAR >::str2enum().
| INLINE void gum::trim | ( | std::string & | s | ) |
trim from both ends (in place)
| s | A string |
Definition at line 80 of file utils_string_inl.h.
References ltrim(), and rtrim().
Referenced by fastVariable(), and trim_copy().
| INLINE std::string gum::trim_copy | ( | const std::string & | s | ) |
trim from both ends (copying)
| s | A string |
Definition at line 102 of file utils_string_inl.h.
References trim().