User Manual, Developers Guide and API Documentation

Uniform.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002  * This file is part of openWNS (open Wireless Network Simulator)
00003  * _____________________________________________________________________________
00004  *
00005  * Copyright (C) 2004-2007
00006  * Chair of Communication Networks (ComNets)
00007  * Kopernikusstr. 16, D-52074 Aachen, Germany
00008  * phone: ++49-241-80-27910,
00009  * fax: ++49-241-80-22242
00010  * email: info@openwns.org
00011  * www: http://www.openwns.org
00012  * _____________________________________________________________________________
00013  *
00014  * openWNS is free software; you can redistribute it and/or modify it under the
00015  * terms of the GNU Lesser General Public License version 2 as published by the
00016  * Free Software Foundation;
00017  *
00018  * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY
00019  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
00020  * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00021  * details.
00022  *
00023  * You should have received a copy of the GNU Lesser General Public License
00024  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00025  *
00026  ******************************************************************************/
00027 
00028 #include <WNS/distribution/Uniform.hpp>
00029 
00030 using namespace wns::distribution;
00031 
00032 STATIC_FACTORY_REGISTER_WITH_CREATOR(
00033     Uniform,
00034     Distribution,
00035     "Uniform",
00036     wns::PyConfigViewCreator);
00037 STATIC_FACTORY_REGISTER_WITH_CREATOR(
00038     Uniform,
00039     Distribution,
00040     "Uniform",
00041     wns::distribution::RNGConfigCreator);
00042 STATIC_FACTORY_REGISTER_WITH_CREATOR(
00043     StandardUniform,
00044     Distribution,
00045     "StandardUniform",
00046     wns::PyConfigViewCreator);
00047 STATIC_FACTORY_REGISTER_WITH_CREATOR(
00048     StandardUniform,
00049     Distribution,
00050     "StandardUniform",
00051     wns::distribution::RNGConfigCreator);
00052 
00053 Uniform::Uniform(const pyconfig::View& config) :
00054     Distribution(),
00055     low_(config.get<double>("low")),
00056     high_(config.get<double>("high")),
00057     dis_(getRNG(), UniformDist::distribution_type(low_, high_))
00058 {
00059 }
00060 
00061 Uniform::Uniform(wns::rng::RNGen* rng, const pyconfig::View& config) :
00062     Distribution(rng),
00063     low_(config.get<double>("low")),
00064     high_(config.get<double>("high")),
00065     dis_(getRNG(), UniformDist::distribution_type(low_, high_))
00066 {
00067 }
00068 
00069 Uniform::Uniform(double _low, double _high, wns::rng::RNGen* rng) :
00070     Distribution(rng),
00071     low_(_low),
00072     high_(_high),
00073     dis_(getRNG(), UniformDist::distribution_type(low_, high_))
00074 {
00075 }
00076 
00077 Uniform::~Uniform()
00078 {
00079 }
00080 
00081 double
00082 Uniform::operator()()
00083 {
00084     return dis_();
00085 }
00086 
00087 double
00088 Uniform::getMean() const
00089 {
00090     return (low_+high_)/2.0;
00091 }
00092 
00093 std::string
00094 Uniform::paramString() const
00095 {
00096     std::ostringstream tmp;
00097     tmp << "Uniform(" << low_ << ".." <<high_ <<")";
00098     return tmp.str();
00099 }
00100 
00101 /*
00102   Local Variables:
00103   mode: c++
00104   fill-column: 80
00105   c-basic-offset: 8
00106   c-comment-only-line-offset: 0
00107   c-tab-always-indent: t
00108   indent-tabs-mode: t
00109   tab-width: 8
00110   End:
00111 */
00112 

Generated on Sat May 26 03:31:36 2012 for openWNS by  doxygen 1.5.5