# HG changeset patch # User Gustavo J. A. M. Carneiro # Date 1233593444 0 # Node ID 6f5e5208a94b183b4254fde89f0c20ed4ce98d23 # Parent e57268650c9ad225d735a7e200fc608afb2ff5a8 Deserialize Normal/Gaussian random variables diff -r e57268650c9a -r 6f5e5208a94b src/core/random-variable.cc --- a/src/core/random-variable.cc Mon Feb 02 15:22:34 2009 +0000 +++ b/src/core/random-variable.cc Mon Feb 02 16:50:44 2009 +0000 @@ -1679,6 +1679,45 @@ var = UniformVariable (a, b); } } + else if (type == "Normal" || type == "Gaussian") + { + if (value.size () == 0) + { + var = NormalVariable (); + } + else + { + tmp = value.find (":"); + if (tmp == value.npos) + { + NS_FATAL_ERROR ("bad Normal/Gaussian value: " << value); + } + std::string::size_type tmp2; + std::string sub = value.substr (tmp + 1, value.npos); + tmp2 = sub.find (":"); + if (tmp2 == value.npos) + { + istringstream issA (value.substr (0, tmp)); + istringstream issB (sub); + double a, b; + issA >> a; + issB >> b; + var = NormalVariable (a, b); + } + else + { + istringstream issA (value.substr (0, tmp)); + istringstream issB (sub.substr (0, tmp2)); + istringstream issC (sub.substr (tmp2 + 1, value.npos)); + double a, b, c; + issA >> a; + issB >> b; + issC >> c; + std::cerr << "NormalVariable ("<