📄 diracmixturepdf.hpp
字号:
#ifndef INDII_ML_AUX_DIRACMIXTUREPDF_HPP#define INDII_ML_AUX_DIRACMIXTUREPDF_HPP#include "MixturePdf.hpp"#include "DiracPdf.hpp"namespace indii { namespace ml { namespace aux {/** * Dirac mixture probability density. * * @author Lawrence Murray <lawrence@indii.org> * @version $Rev: 348 $ * @date $Date: 2007-11-16 18:28:44 +0000 (Fri, 16 Nov 2007) $ * * @see MixturePdf for more information regarding the serialization * and parallelisation features of this class. */class DiracMixturePdf : public MixturePdf<DiracPdf> {public: /** * Default constructor. * * Initialises the mixture with zero dimensions. This should * generally only be used when the object is to be restored from a * serialization. Indeed, there is no other way to resize the * mixture to nonzero dimensionality except by subsequently * restoring from a serialization. */ DiracMixturePdf(); /** * Sampling constructor. * * @param o Distribution to approximate. * @param P Number of samples with which to approximate the * distribution. * * Initialises the mixture by drawing @c P equally weighted samples * from the distribution @c o. */ DiracMixturePdf(Pdf& o, const unsigned int P); /** * Constructor. One or more components should be added with * addComponent() after construction. * * @param N Dimensionality of the distribution. */ DiracMixturePdf(const unsigned int N); /** * Destructor. */ virtual ~DiracMixturePdf(); virtual void setDimensions(const unsigned int N, const bool preserve = false); virtual const symmetric_matrix& getCovariance(); /** * Get the covariance of the full distribution. * * @return \f$\Sigma\f$; covariance of the full distribution. */ symmetric_matrix getDistributedCovariance();protected: virtual void dirty();private: /** * Last calculated covariance. */ symmetric_matrix sigma; /** * Last calculated unnormalized covariance. */ symmetric_matrix Zsigma; /** * Is the last calculated covariance up to date? */ bool haveSigma; /** * Calculate covariance from current components. */ void calculateCovariance(); /** * Serialize. */ template<class Archive> void save(Archive& ar, const unsigned int version) const; /** * Restore from serialization. */ template<class Archive> void load(Archive& ar, const unsigned int version); /* * Boost.Serialization requirements. */ BOOST_SERIALIZATION_SPLIT_MEMBER() friend class boost::serialization::access;}; } }}#include "boost/serialization/base_object.hpp"template <class Archive>void indii::ml::aux::DiracMixturePdf::save(Archive& ar, const unsigned int version) const { ar & boost::serialization::base_object<MixturePdf<DiracPdf> >(*this);}template <class Archive>void indii::ml::aux::DiracMixturePdf::load(Archive& ar, const unsigned int version) { ar & boost::serialization::base_object<MixturePdf<DiracPdf> >(*this); sigma.resize(getDimensions(), false); Zsigma.resize(getDimensions(), false); haveSigma = false;}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -