00001 // $Id: uniform.h tdelaet$ 00002 // Copyright (C) 2007 Tinne De Laet <first dot last at gmail dot com> 00003 // 00004 // This program is free software; you can redistribute it and/or modify 00005 // it under the terms of the GNU Lesser General Public License as published by 00006 // the Free Software Foundation; either version 2.1 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU Lesser General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU Lesser General Public License 00015 // along with this program; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 // 00018 #ifndef UNIFORM_H 00019 #define UNIFORM_H 00020 00021 #include "pdf.h" 00022 00023 namespace BFL 00024 { 00026 class Uniform: public Pdf<MatrixWrapper::ColumnVector> 00027 { 00028 private: 00030 MatrixWrapper::ColumnVector _Lower; 00032 MatrixWrapper::ColumnVector _Higher; 00034 double _Height; //the height of the uniform distribution 00035 00036 // variables to avoid allocation on the heap during resampling 00037 mutable ColumnVector _samples; 00038 00039 public: 00041 00045 Uniform (const MatrixWrapper::ColumnVector& Center, const MatrixWrapper::ColumnVector& Width); 00046 00048 Uniform (int dimension = 0); 00049 00051 00053 virtual ~Uniform(); 00054 00056 friend std::ostream& operator<< (std::ostream& os, const Uniform& u); 00057 00059 virtual Uniform* Clone() const; 00060 00061 // Redefinition of pure virtuals 00062 virtual Probability ProbabilityGet(const MatrixWrapper::ColumnVector& input) const; 00063 bool SampleFrom (vector<Sample<MatrixWrapper::ColumnVector> >& list_samples, 00064 const int num_samples, 00065 int method=DEFAULT, 00066 void * args=NULL) const; 00067 virtual bool SampleFrom (Sample<MatrixWrapper::ColumnVector>& one_sample, int method=DEFAULT, void * args=NULL) const; 00068 00070 00072 virtual MatrixWrapper::ColumnVector CenterGet() const; 00073 00075 00077 virtual MatrixWrapper::ColumnVector WidthGet() const; 00078 00080 00084 void UniformSet (const MatrixWrapper::ColumnVector& center, const MatrixWrapper::ColumnVector& width); 00085 00086 }; 00087 00088 } // end namespace 00089 #endif