bfl_constants.h
Go to the documentation of this file.
00001 // $Id: bfl_constants.h 30606 2009-10-02 10:01:02Z tdelaet $
00002 // Copyright (C) 2003 Klaas Gadeyne <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 __BFL_CONSTANTS_H__
00019 #define __BFL_CONSTANTS_H__
00020 
00021 #define NUMERIC_PRECISION 0.000000001
00022 
00023 #pragma warning( disable : 4996)
00024 
00025 #ifndef M_PI
00026 #define M_PI 3.141592653589793284626433832795
00027 #endif
00028 
00029 // Check if double is probability value (maybe this should be solved
00030 // by a type probability_t or something.  Needs thinking.
00031 #include <iostream>
00032 #include <cmath>
00033 #include <cassert>
00034 
00035 namespace BFL
00036 {
00037   using namespace std;
00039   class Probability
00040   {
00041     public:
00042       Probability(){};
00043       Probability(double p)
00044     {
00045           #ifndef _MSC_VER
00046        assert(std::isfinite(p) != 0);
00047          #endif
00048       assert( p >= 0 );
00049       _prob = p;
00050     };
00051     virtual ~Probability(){};
00052 /*
00053     ostream & operator<< (ostream & stream)
00054     {
00055       stream << this->getValue() << endl;
00056       return stream;
00057     };
00058 
00059   istream & operator>> (istream & stream)
00060     {
00061         double value;
00062         stream >> value;
00063         _prob = Probability(value);
00064         return stream; 
00065     };
00066 */
00067     friend ostream & operator<< (ostream & stream,Probability& prob);
00068 
00069     friend istream & operator>> (istream & stream,Probability& prob);
00070 
00071     double getValue() const { return _prob;} ;
00072 
00073       operator double(){return _prob;};
00074       Probability operator *(Probability p)
00075     { return ((Probability) (this->_prob * (double) p));};
00076       Probability operator /(Probability p)
00077     { return ((Probability) (this->_prob / (double) p));};
00078 
00079 
00080   private:
00081     double _prob;
00082   };
00083 
00084 } // End namespace
00085 
00100 #endif
00101 
00102 


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 Sun Oct 5 2014 22:29:52