set default pointer value to nullptr which is more idiomatic

release/4.3a0
Varun Agrawal 2025-05-16 00:09:31 -04:00
parent 22a36b3d7a
commit 8b6ce55151
3 changed files with 8 additions and 11 deletions

View File

@ -112,7 +112,7 @@ class GTSAM_EXPORT DiscreteBayesNet: public BayesNet<DiscreteConditional> {
* *
* @return a sampled value for all variables. * @return a sampled value for all variables.
*/ */
DiscreteValues sample(std::mt19937_64* rng = &kRandomNumberGenerator) const; DiscreteValues sample(std::mt19937_64* rng = nullptr) const;
/** /**
* @brief do ancestral sampling, given certain variables. * @brief do ancestral sampling, given certain variables.
@ -123,7 +123,7 @@ class GTSAM_EXPORT DiscreteBayesNet: public BayesNet<DiscreteConditional> {
* @return given values extended with sampled value for all other variables. * @return given values extended with sampled value for all other variables.
*/ */
DiscreteValues sample(DiscreteValues given, DiscreteValues sample(DiscreteValues given,
std::mt19937_64* rng = &kRandomNumberGenerator) const; std::mt19937_64* rng = nullptr) const;
/** /**
* @brief Prune the Bayes net * @brief Prune the Bayes net

View File

@ -210,11 +210,10 @@ class GTSAM_EXPORT DiscreteConditional
* @return sample from conditional * @return sample from conditional
*/ */
virtual size_t sample(const DiscreteValues& parentsValues, virtual size_t sample(const DiscreteValues& parentsValues,
std::mt19937_64* rng = &kRandomNumberGenerator) const; std::mt19937_64* rng = nullptr) const;
/// Single parent version. /// Single parent version.
size_t sample(size_t parent_value, size_t sample(size_t parent_value, std::mt19937_64* rng = nullptr) const;
std::mt19937_64* rng = &kRandomNumberGenerator) const;
/** /**
* Sample from conditional, zero parent version * Sample from conditional, zero parent version
@ -222,7 +221,7 @@ class GTSAM_EXPORT DiscreteConditional
* std::mt19937_64 rng(42); * std::mt19937_64 rng(42);
* auto sample = dc.sample(&rng); * auto sample = dc.sample(&rng);
*/ */
size_t sample(std::mt19937_64* rng = &kRandomNumberGenerator) const; size_t sample(std::mt19937_64* rng = nullptr) const;
/** /**
* @brief Return assignment for single frontal variable that maximizes value. * @brief Return assignment for single frontal variable that maximizes value.
@ -246,7 +245,7 @@ class GTSAM_EXPORT DiscreteConditional
/// Sample in place with optional PRNG, stores result in partial solution /// Sample in place with optional PRNG, stores result in partial solution
void sampleInPlace(DiscreteValues* parentsValues, void sampleInPlace(DiscreteValues* parentsValues,
std::mt19937_64* rng = &kRandomNumberGenerator) const; std::mt19937_64* rng = nullptr) const;
/// Return all assignments for frontal variables. /// Return all assignments for frontal variables.
std::vector<DiscreteValues> frontalAssignments() const; std::vector<DiscreteValues> frontalAssignments() const;

View File

@ -125,7 +125,6 @@ class GTSAM_EXPORT TableDistribution : public DiscreteConditional {
/// Create new factor by maximizing over all values with the same separator. /// Create new factor by maximizing over all values with the same separator.
DiscreteFactor::shared_ptr max(const Ordering& keys) const override; DiscreteFactor::shared_ptr max(const Ordering& keys) const override;
/// Multiply by scalar s /// Multiply by scalar s
DiscreteFactor::shared_ptr operator*(double s) const override; DiscreteFactor::shared_ptr operator*(double s) const override;
@ -146,9 +145,8 @@ class GTSAM_EXPORT TableDistribution : public DiscreteConditional {
* @param rng Pseudo random number generator * @param rng Pseudo random number generator
* @return sample from conditional * @return sample from conditional
*/ */
virtual size_t sample( virtual size_t sample(const DiscreteValues& parentsValues,
const DiscreteValues& parentsValues, std::mt19937_64* rng = nullptr) const override;
std::mt19937_64* rng = &kRandomNumberGenerator) const override;
/// @} /// @}
/// @name Advanced Interface /// @name Advanced Interface