Go to the documentation of this file.00001
00002 #ifndef vpdl_gaussian_h_
00003 #define vpdl_gaussian_h_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <vpdl/vpdl_gaussian_base.h>
00016 #include <vpdl/vpdt/vpdt_gaussian.h>
00017 #include <vpdl/vpdt/vpdt_probability.h>
00018 #include <vpdl/vpdt/vpdt_log_probability.h>
00019 #include <vcl_limits.h>
00020
00021
00022 template<class T, unsigned int n=0>
00023 class vpdl_gaussian : public vpdl_gaussian_base<T,n>
00024 {
00025 public:
00026
00027 typedef typename vpdt_field_default<T,n>::type vector;
00028
00029 typedef typename vpdt_field_traits<vector>::matrix_type matrix;
00030
00031 typedef matrix covar_type;
00032
00033
00034
00035
00036 vpdl_gaussian(unsigned int var_dim = n)
00037 : impl_(var_dim) {}
00038
00039
00040 vpdl_gaussian(const vector& mean_val, const covar_type& covar)
00041 : impl_(mean_val,covar) {}
00042
00043
00044 virtual ~vpdl_gaussian() {}
00045
00046
00047 virtual vpdl_distribution<T,n>* clone() const
00048 {
00049 return new vpdl_gaussian<T,n>(*this);
00050 }
00051
00052
00053 virtual unsigned int dimension() const { return impl_.dimension(); }
00054
00055
00056 virtual T density(const vector& pt) const
00057 {
00058 return impl_.density(pt);
00059 }
00060
00061
00062 virtual T prob_density(const vector& pt) const
00063 {
00064 return vpdt_prob_density(impl_,pt);
00065 }
00066
00067
00068 virtual T log_prob_density(const vector& pt) const
00069 {
00070 return vpdt_log_prob_density(impl_,pt);
00071 };
00072
00073
00074
00075
00076
00077 virtual T gradient_density(const vector& pt, vector& g) const
00078 {
00079 return impl_.gradient_density(pt,g);
00080 }
00081
00082
00083
00084
00085 virtual T norm_const() const
00086 {
00087 return impl_.norm_const();
00088 }
00089
00090
00091
00092 T sqr_mahal_dist(const vector& pt) const
00093 {
00094 return impl_.sqr_mahal_dist(pt);
00095 }
00096
00097
00098
00099
00100 virtual T cumulative_prob(const vector& pt) const
00101 {
00102 return impl_.cumulative_prob(pt);
00103 }
00104
00105
00106 virtual const vector& mean() const { return impl_.mean; }
00107
00108
00109 virtual void set_mean(const vector& mean_val) { impl_.mean = mean_val; }
00110
00111
00112 virtual void compute_mean(vector& mean_val) const { mean_val = impl_.mean; }
00113
00114
00115 covar_type covariance() const
00116 {
00117 covar_type M;
00118 impl_.compute_covar(M);
00119 return M;
00120 }
00121
00122
00123 void set_covariance(const covar_type& covar)
00124 {
00125 impl_.covar.set_matrix(covar);
00126 }
00127
00128
00129 virtual void compute_covar(matrix& covar) const
00130 {
00131 impl_.compute_covar(covar);
00132 }
00133
00134
00135 const matrix& covar_eigenvecs() const { return impl_.covar.eigenvectors(); }
00136
00137
00138 const vector& covar_eigenvals() const { return impl_.covar.eigenvalues(); }
00139
00140
00141 void set_covar_eigenvecs(const matrix& m) { impl_.covar.set_eigenvectors(m); }
00142
00143
00144 void set_covar_eigenvals(const vector& v) { impl_.covar.set_eigenvalues(v); }
00145
00146 protected:
00147
00148 vpdt_gaussian<vector> impl_;
00149 };
00150
00151 #endif // vpdl_gaussian_h_