![]() |
aGrUM 3.0.0
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<GUM_Numeric 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 (const std::string_view &value, const std::string_view &ending) |
| Returns true if value ends with ending. | |
| std::vector< std::string > | gum::split (std::string_view orig, std::string_view delimiter) |
| Split str using the delimiter. | |
| std::string | gum::replace (std::string_view s, std::string_view val, std::string_view new_val) |
| Replace val by new_val in s. | |
| bool | gum::isIntegerWithResult (std::string_view val, int *res) |
| return true is a string contains an integer value | |
| bool | gum::isNumericalWithResult (std::string_view val, double *res) |
| return true is a string contains a numerical (double) value | |
| std::string | gum::toLower (std::string_view str) |
| Returns the lowercase version of str. | |
| bool | gum::contains (std::string_view s, std::string_view needle) |
| true if needle in s | |
| bool | gum::isInteger (std::string_view val) |
| return true is a string contains an integer value | |
| bool | gum::isNumerical (std::string_view 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 (std::string_view s) |
| trim from both ends (copying) | |
| std::string | gum::remove_newline (std::string_view 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.
| std::string gum::compact_tostr | ( | T | value | ) |
Returns a path to a unique file name.
Definition at line 51 of file utils_string_tpl.h.
| INLINE bool gum::contains | ( | std::string_view | s, |
| std::string_view | needle ) |
true if needle in s
| s | |
| needle | * |
Definition at line 67 of file utils_string_inl.h.
Referenced by gum::MonteCarloSampling< GUM_SCALAR >::draw_(), gum::WeightedSampling< GUM_SCALAR >::draw_(), gum::Set< const gum::Observation * >::hashMap(), gum::Set< Key >::insert(), gum::Tensor< GUM_SCALAR >::KL(), gum::MarginalTargetedInference< GUM_SCALAR >::posterior(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::posterior(), gum::Tensor< GUM_SCALAR >::putFirst(), gum::Tensor< GUM_SCALAR >::reorganize(), and gum::CausalModel< GUM_SCALAR >::toDot().
| INLINE unsigned int gum::currentRandomGeneratorValue | ( | ) |
returns the current generator's value
Definition at line 87 of file utils_random_inl.h.
References gum::_rand_namespace_::generator().
| bool gum::endsWith | ( | const std::string_view & | value, |
| const std::string_view & | ending ) |
Returns true if value ends with ending.
Definition at line 82 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 62 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 109 of file utils_misc_tpl.h.
| INLINE void gum::initRandom | ( | unsigned int | seed = 0 | ) |
Initialize random generator seed.
Definition at line 79 of file utils_random_inl.h.
References gum::_rand_namespace_::generator().
| INLINE bool gum::isInteger | ( | std::string_view | val | ) |
return true is a string contains an integer value
| s | A string |
Definition at line 99 of file utils_string_inl.h.
References isIntegerWithResult().
Referenced by fastVariable().
| bool gum::isIntegerWithResult | ( | std::string_view | val, |
| int * | res ) |
return true is a string contains an integer value
| s | A string |
Definition at line 112 of file utils_string.cpp.
Referenced by isInteger().
| INLINE bool gum::isNumerical | ( | std::string_view | val | ) |
return true is a string contains a numerical (double) value
| s | A string |
Definition at line 102 of file utils_string_inl.h.
References isNumericalWithResult().
Referenced by fastVariable(), and gum::Tensor< GUM_SCALAR >::variance().
return true is a string contains a numerical (double) value
| s | A string * |
Definition at line 126 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 72 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 79 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 63 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 101 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 57 of file utils_random_tpl.h.
References GUM_ERROR, and 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 98 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 91 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 73 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 66 of file utils_random_inl.h.
References gum::_rand_namespace_::generator(), and GUM_ERROR.
Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, SimpleCPTGenerator, SimpleCPTDisturber >::MCBayesNetGenerator(), 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::MCBayesNetGenerator< GUM_SCALAR, SimpleCPTGenerator, SimpleCPTDisturber >::generateBN(), 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_(), and gum::SDYNA::takeAction().
| INLINE std::string gum::remove_newline | ( | std::string_view | s | ) |
remove all newlines in a string
| s | A string |
Definition at line 91 of file utils_string_inl.h.
Referenced by gum::BayesNet< GUM_SCALAR >::fastPrototype(), and gum::InfluenceDiagram< GUM_SCALAR >::fastPrototype().
| std::string gum::replace | ( | std::string_view | s, |
| std::string_view | val, | ||
| std::string_view | new_val ) |
Replace val by new_val in s.
| s | A string. |
| val | The value to replace in s. |
| new_val | The new value to replace val in s. |
Definition at line 100 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 78 of file utils_string_inl.h.
Referenced by trim().
| std::vector< std::string > gum::split | ( | std::string_view | orig, |
| std::string_view | delimiter ) |
Split str using the delimiter.
| orig | searched string |
| delimiter | string |
Definition at line 87 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_view | str | ) |
Returns the lowercase version of str.
Definition at line 60 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 85 of file utils_string_inl.h.
References ltrim(), and rtrim().
Referenced by fastVariable(), and trim_copy().
| INLINE std::string gum::trim_copy | ( | std::string_view | s | ) |
trim from both ends (copying)
| s | A string |
Definition at line 105 of file utils_string_inl.h.
References trim().