Bayesian Filtering Library Generated from SVN r
|
00001 // $Id: discreteconditionalpdf.h 29890 2009-02-02 10:22:01Z tdelaet $ 00002 // Copyright (C) 2002 Klaas Gadeyne <first dot last at gmail dot com> 00003 // 2008 Tinne De Laet <first dot last at mech dot kuleuven dot be> 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU Lesser General Public License as published by 00007 // the Free Software Foundation; either version 2.1 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with this program; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 // 00019 00020 #ifndef __DISCRETE_CONDITIONAL_PDF__ 00021 #define __DISCRETE_CONDITIONAL_PDF__ 00022 00023 #include "conditionalpdf.h" 00024 00025 namespace BFL 00026 { 00027 00029 00053 class DiscreteConditionalPdf : public ConditionalPdf<int, int> 00054 { 00055 protected: 00057 unsigned int _num_states; 00058 00060 00063 double * _probability_p; 00065 int * _cond_arg_dims_p; 00066 00068 int _total_dimension; 00069 00071 int IndexGet(const int& input, const std::vector<int>& condargs) const; 00072 00073 // variables to prevent memory allocation on the heap during call of 00074 //SampleFrom 00075 mutable std::vector<double> _probs; 00076 mutable std::vector<double> _valuelist; 00077 00078 public: 00080 00090 DiscreteConditionalPdf(int num_states=1, 00091 int num_conditional_arguments=1, 00092 int cond_arg_dimensions[] = NULL); 00094 DiscreteConditionalPdf(const DiscreteConditionalPdf & pdf); 00096 virtual ~DiscreteConditionalPdf(); 00097 00099 virtual DiscreteConditionalPdf* Clone() const; 00100 00102 unsigned int NumStatesGet()const; 00103 00104 // Redefine all pure virtuals! 00105 Probability ProbabilityGet(const int& input) const; 00106 virtual bool SampleFrom (Sample<int>& one_sample, int method, void * args) const; 00107 virtual bool SampleFrom (vector<Sample<int> >& list_samples, int num_samples, int method, void * args) const; 00108 00110 void ProbabilitySet(const double& prob, const int& input, const std::vector<int>& condargs) const; 00111 00112 00113 }; 00114 00115 } // End namespace BFL 00116 00117 #endif // __DISCRETE_CONDITIONAL_PDF__