User Manual, Developers Guide and API Documentation

Norm.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/Norm.hpp>
00029 
00030 #include <WNS/module/Base.hpp>
00031 
00032 using namespace wns::distribution;
00033 
00034 STATIC_FACTORY_REGISTER_WITH_CREATOR(
00035     Norm,
00036     Distribution,
00037     "Norm",
00038     wns::PyConfigViewCreator);
00039 STATIC_FACTORY_REGISTER_WITH_CREATOR(
00040     Norm,
00041     Distribution,
00042     "Norm",
00043     wns::distribution::RNGConfigCreator);
00044 
00045 Norm::Norm(double mean, double variance, wns::rng::RNGen* rng) :
00046     Distribution(rng),
00047     mean_(mean),
00048     variance_(variance),
00049     dis_(getRNG(), NormalDist::distribution_type(mean_, sqrt(variance_)))
00050 {
00051 }
00052 
00053 Norm::Norm(const pyconfig::View& config) :
00054     Distribution(),
00055     mean_(config.get<double>("mean")),
00056     variance_(config.get<double>("variance")),
00057     dis_(getRNG(), NormalDist::distribution_type(mean_, sqrt(variance_)))
00058 {
00059 }
00060 
00061 Norm::Norm(wns::rng::RNGen* rng, const pyconfig::View& config) :
00062     Distribution(rng),
00063     mean_(config.get<double>("mean")),
00064     variance_(config.get<double>("variance")),
00065     dis_(getRNG(), NormalDist::distribution_type(mean_, sqrt(variance_)))
00066 {
00067 }
00068 
00069 Norm::~Norm()
00070 {
00071 }
00072 
00073 
00074 double
00075 Norm::operator()()
00076 {
00077     return dis_();
00078 }
00079 
00080 double
00081 Norm::getMean() const
00082 {
00083     return mean_;
00084 }
00085 
00086 std::string
00087 Norm::paramString() const
00088 {
00089     std::ostringstream tmp;
00090     tmp << "Norm(mean=" << this->getMean() << ",v=" << variance_ << ")";
00091     return tmp.str();
00092 }
00093 
00094 /*
00095   Local Variables:
00096   mode: c++
00097   fill-column: 80
00098   c-basic-offset: 8
00099   c-comment-only-line-offset: 0
00100   c-tab-always-indent: t
00101   indent-tabs-mode: t
00102   tab-width: 8
00103   End:
00104 */
00105 

Generated on Fri May 25 03:31:37 2012 for openWNS by  doxygen 1.5.5