Go to the documentation of this file.00001
00002 #ifndef vpdfl_pdf_base_h
00003 #define vpdfl_pdf_base_h
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007
00008
00009
00010
00011
00012
00013 #include <vsl/vsl_binary_io.h>
00014 #include <vnl/io/vnl_io_vector.h>
00015 #include <vcl_string.h>
00016
00017
00018
00019 class vpdfl_sampler_base;
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 class vpdfl_pdf_base
00030 {
00031 vnl_vector<double> mean_;
00032 vnl_vector<double> var_;
00033 protected:
00034 void set_mean(const vnl_vector<double>& m) { mean_ = m; }
00035 void set_variance(const vnl_vector<double>& v) { var_ = v; }
00036 public:
00037
00038
00039 vpdfl_pdf_base();
00040
00041
00042 virtual ~vpdfl_pdf_base();
00043
00044
00045 const vnl_vector<double>& mean() const { return mean_; }
00046
00047
00048 const vnl_vector<double>& variance() const { return var_; }
00049
00050
00051 int n_dims() const { return mean_.size(); }
00052
00053
00054 virtual int n_peaks() const { return 1; }
00055
00056
00057 virtual const vnl_vector<double>& peak(int) const { return mean_; }
00058
00059
00060 virtual double log_p(const vnl_vector<double>& x) const =0;
00061
00062
00063 virtual double operator()(const vnl_vector<double>& x) const;
00064
00065
00066
00067 virtual void gradient(vnl_vector<double>& g,
00068 const vnl_vector<double>& x, double& p) const =0;
00069
00070
00071
00072
00073
00074 virtual void gradient_logp(vnl_vector<double>& g,
00075 const vnl_vector<double>& x) const;
00076
00077
00078
00079 virtual vpdfl_sampler_base* new_sampler()const=0 ;
00080
00081
00082 virtual double log_prob_thresh(double pass_proportion)const;
00083
00084
00085
00086
00087
00088
00089 virtual void nearest_plausible(vnl_vector<double>& x, double log_p_min)const =0;
00090
00091
00092
00093
00094 virtual bool is_valid_pdf() const;
00095
00096
00097 short version_no() const;
00098
00099
00100 virtual vcl_string is_a() const;
00101
00102
00103 virtual bool is_class(vcl_string const& s) const;
00104
00105
00106 virtual vpdfl_pdf_base* clone() const = 0;
00107
00108
00109 virtual void print_summary(vcl_ostream& os) const = 0;
00110
00111
00112 virtual void b_write(vsl_b_ostream& bfs) const = 0;
00113
00114
00115 virtual void b_read(vsl_b_istream& bfs) = 0;
00116 };
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 void vsl_add_to_binary_loader(const vpdfl_pdf_base& b);
00128
00129
00130 void vsl_b_write(vsl_b_ostream& bfs, const vpdfl_pdf_base& b);
00131
00132
00133 void vsl_b_read(vsl_b_istream& bfs, vpdfl_pdf_base& b);
00134
00135
00136 void vsl_print_summary(vcl_ostream& os,const vpdfl_pdf_base& b);
00137
00138
00139 void vsl_print_summary(vcl_ostream& os,const vpdfl_pdf_base* b);
00140
00141
00142 vcl_ostream& operator<<(vcl_ostream& os,const vpdfl_pdf_base& b);
00143
00144
00145 vcl_ostream& operator<<(vcl_ostream& os,const vpdfl_pdf_base* b);
00146
00147 #endif // vpdfl_pdf_base_h