Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef PDF_H
00031 #define PDF_H
00032
00033 #include <vector>
00034 #include <iostream>
00035 #include "../wrappers/matrix/vector_wrapper.h"
00036 #include "../wrappers/matrix/matrix_wrapper.h"
00037 #include "../sample/sample.h"
00038 #include "../bfl_err.h"
00039 #include "../bfl_constants.h"
00040
00041
00042 namespace BFL
00043 {
00044 using namespace std;
00045
00046
00047 #define DEFAULT 0 // Default sampling method, must be valid for every PDF!!
00048 #define BOXMULLER 1
00049 #define CHOLESKY 2
00050 #define RIPLEY 3 // For efficient sampling from discrete/mcpdfs
00051
00053 template <typename T> class Pdf
00054 {
00055
00056 public:
00058
00060 Pdf(unsigned int dimension=0);
00061
00062
00063
00065 virtual ~Pdf();
00066
00068 virtual Pdf<T>* Clone() const = 0;
00069
00071
00087 virtual bool SampleFrom (vector<Sample<T> >& list_samples,
00088 const unsigned int num_samples,
00089 int method = DEFAULT,
00090 void * args = NULL) const;
00091
00093
00103 virtual bool SampleFrom (Sample<T>& one_sample,
00104 int method = DEFAULT,
00105 void * args = NULL) const;
00106
00108
00111 virtual Probability ProbabilityGet(const T& input) const;
00112
00114
00116 unsigned int DimensionGet() const;
00117
00119
00121 virtual void DimensionSet(unsigned int dim);
00122
00124
00132 virtual T ExpectedValueGet() const;
00133
00135
00141 virtual MatrixWrapper::SymmetricMatrix CovarianceGet() const;
00142
00143 private:
00145 unsigned int _dimension;
00146
00147 };
00148
00149 template<typename T>
00150 Pdf<T>::Pdf(unsigned int dim)
00151 {
00152 assert((int)dim >= 0);
00153
00154 _dimension = dim;
00155 #ifdef __CONSTRUCTOR__
00156 cout << "Pdf constructor" << endl;
00157 #endif
00158 }
00159
00160 template<typename T>
00161 Pdf<T>::~Pdf()
00162 {
00163 #ifdef __DESTRUCTOR__
00164 cout << "Pdf destructor" << endl;
00165 #endif
00166 }
00167
00168 template<typename T> inline unsigned int
00169 Pdf<T>::DimensionGet () const
00170 {
00171 return _dimension;
00172 }
00173
00174 template<typename T> void
00175 Pdf<T>::DimensionSet ( unsigned int dim )
00176 {
00177 assert((int)dim >= 0);
00178 _dimension = dim;
00179 }
00180
00181 template<typename T> bool
00182 Pdf<T>::SampleFrom (vector<Sample<T> >& list_samples,
00183 const unsigned int num_samples,
00184 int method,
00185 void * args) const
00186 {
00187 list_samples.resize(num_samples);
00188 typename vector<Sample<T> >::iterator sample_it;
00189 for (sample_it = list_samples.begin(); sample_it != list_samples.end() ; sample_it++)
00190 if (!this->SampleFrom(*sample_it, method,args))
00191 return false;
00192
00193 return true;
00194 }
00195
00196 template<typename T> bool
00197 Pdf<T>::SampleFrom (Sample<T>& one_sample,
00198 int method,
00199 void * args) const
00200 {
00201 cerr << "Error Pdf<T>: The SampleFrom function was called, but you didn't implement it!\n";
00202 exit(-BFL_ERRMISUSE);
00203 return false;
00204 }
00205
00206 template<typename T> Probability
00207 Pdf<T>::ProbabilityGet (const T& input) const
00208 {
00209 cerr << "Error Pdf<T>: The ProbabilityGet function was called, but you didn't implement it!\n";
00210 exit(-BFL_ERRMISUSE);
00211 return 1;
00212 }
00213
00214 template<typename T> T
00215 Pdf<T>::ExpectedValueGet () const
00216 {
00217 cerr << "Error Pdf<T>: The ExpectedValueGet function was called, but you didn't implement it!\n";
00218 exit(-BFL_ERRMISUSE);
00219 T t;
00220 return t;
00221 }
00222
00223
00224 template<typename T> MatrixWrapper::SymmetricMatrix
00225 Pdf<T>::CovarianceGet () const
00226 {
00227 cerr << "Error Pdf<T>: The CovarianceGet function was called, but you didn't implement it!\n";
00228 exit(-BFL_ERRMISUSE);
00229 MatrixWrapper::SymmetricMatrix m;
00230 return m;
00231 }
00232
00233
00234
00235 }
00236 #endif
bfl
Author(s): Klaas Gadeyne, Wim Meeussen, Tinne Delaet and many others. See web page for a full contributor list. ROS package maintained by Wim Meeussen.
autogenerated on Fri Aug 28 2015 10:10:21