Go to the documentation of this file.00001
00002 #ifndef vpdl_mixture_of_h_
00003 #define vpdl_mixture_of_h_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <vpdl/vpdl_multi_cmp_dist.h>
00016 #include <vpdl/vpdt/vpdt_access.h>
00017 #include <vpdl/vpdt/vpdt_dist_traits.h>
00018 #include <vpdl/vpdt/vpdt_mixture_of.h>
00019 #include <vpdl/vpdt/vpdt_probability.h>
00020
00021
00022
00023
00024
00025
00026
00027
00028 template<class dist_t>
00029 class vpdl_mixture_of
00030 : public vpdl_multi_cmp_dist<typename vpdt_dist_traits<dist_t>::scalar_type,
00031 vpdt_dist_traits<dist_t>::dimension>
00032 {
00033 vpdt_mixture_of<dist_t> impl_;
00034
00035 public:
00036
00037 typedef typename dist_t::field_type field_type;
00038
00039 typedef dist_t component_type;
00040
00041
00042 static const unsigned int n = vpdt_field_traits<field_type>::dimension;
00043
00044 typedef typename dist_t::field_type F;
00045
00046 typedef typename vpdt_field_traits<field_type>::scalar_type T;
00047
00048 typedef typename vpdt_field_traits<field_type>::vector_type vector;
00049
00050 typedef typename vpdt_field_traits<field_type>::matrix_type matrix;
00051
00052
00053 vpdl_mixture_of() {}
00054
00055
00056 virtual ~vpdl_mixture_of() {}
00057
00058
00059 virtual vpdl_distribution<T,n>* clone() const
00060 {
00061 return new vpdl_mixture_of<dist_t>(*this);
00062 }
00063
00064
00065 virtual unsigned int dimension() const { return impl_.dimension(); }
00066
00067
00068 unsigned int num_components() const { return impl_.num_components(); }
00069
00070
00071 const dist_t& distribution(unsigned int index) const
00072 { return impl_.distribution(index); }
00073
00074
00075 dist_t& distribution(unsigned int index) { return impl_.distribution(index); }
00076
00077
00078 T weight(unsigned int index) const { return impl_.weight(index); }
00079
00080
00081 void set_weight(unsigned int index, const T& w) { impl_.set_weight(index,w); }
00082
00083
00084 bool insert(const dist_t& d, const T& wght = T(0))
00085 { return impl_.insert(d,wght); }
00086
00087
00088 bool remove_last() { return impl_.remove_last(); }
00089
00090
00091 T density(const vector& pt) const { return impl_.density(pt); }
00092
00093
00094 T prob_density(const vector& pt) const { return vpdt_prob_density(impl_,pt); }
00095
00096
00097
00098
00099
00100 virtual T gradient_density(const vector& pt, vector& g) const
00101 {
00102 return impl_.gradient_density(pt,g);
00103 }
00104
00105
00106 T box_prob(const vector& min_pt, const vector& max_pt) const
00107 { return vpdt_box_prob(impl_,min_pt,max_pt); }
00108
00109
00110
00111
00112 virtual T cumulative_prob(const vector& pt) const
00113 { return impl_.cumulative_prob(pt); }
00114
00115
00116
00117 virtual void compute_mean(vector& mean) const { impl_.compute_mean(mean); }
00118
00119
00120 virtual void compute_covar(matrix& covar) const { impl_.compute_covar(covar); }
00121
00122
00123
00124
00125 virtual T norm_const() const { return impl_.norm_const(); }
00126
00127
00128 void normalize_weights() { impl_.normalize_weights(); }
00129
00130
00131 void sort() { impl_.sort(); }
00132
00133
00134 void sort(unsigned int idx1, unsigned int idx2) { impl_.sort(idx1, idx2); }
00135
00136
00137
00138
00139
00140
00141
00142
00143 template <class comp_type_>
00144 void sort(comp_type_ comp) { impl_.sort(comp); }
00145
00146
00147 template <class comp_type_>
00148 void sort(comp_type_ comp, unsigned int idx1, unsigned int idx2) { impl_.sort(comp,idx1,idx2); }
00149 };
00150
00151
00152 #endif // vpdl_mixture_of_h_