--- a/src/antenna/model/angles.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/antenna/model/angles.cc Sat Sep 01 20:57:21 2012 +0200
@@ -73,14 +73,14 @@
Angles::Angles (Vector v)
- : phi (atan2 (v.y, v.x)),
- theta (acos (v.z / sqrt (v.x*v.x + v.y*v.y + v.z*v.z)))
+ : phi (std::atan2 (v.y, v.x)),
+ theta (std::acos (v.z / sqrt (v.x*v.x + v.y*v.y + v.z*v.z)))
{
}
Angles::Angles (Vector v, Vector o)
- : phi (atan2 (v.y - o.y, v.x - o.x)),
- theta (acos ((v.z - o.z) / CalculateDistance (v, o)))
+ : phi (std::atan2 (v.y - o.y, v.x - o.x)),
+ theta (std::acos ((v.z - o.z) / CalculateDistance (v, o)))
{
}
--- a/src/antenna/model/cosine-antenna-model.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/antenna/model/cosine-antenna-model.cc Sat Sep 01 20:57:21 2012 +0200
@@ -66,7 +66,7 @@
{
NS_LOG_FUNCTION (this << beamwidthDegrees);
m_beamwidthRadians = DegreesToRadians (beamwidthDegrees);
- m_exponent = -3.0 / (20*log10 (cos (m_beamwidthRadians / 4.0)));
+ m_exponent = -3.0 / (20 * std::log10 (std::cos (m_beamwidthRadians / 4.0)));
NS_LOG_LOGIC (this << " m_exponent = " << m_exponent);
}
@@ -109,7 +109,7 @@
NS_LOG_LOGIC ("phi = " << phi );
// element factor: amplitude gain of a single antenna element in linear units
- double ef = pow (cos (phi / 2.0), m_exponent);
+ double ef = std::pow (std::cos (phi / 2.0), m_exponent);
// the array factor is not considered. Note that if we did consider
// the array factor, the actual beamwidth would change, and in
@@ -117,7 +117,7 @@
// user. Hence it is not desirable to use the array factor, for the
// ease of use of this model.
- double gainDb = 20*log10 (ef);
+ double gainDb = 20 * std::log10 (ef);
NS_LOG_LOGIC ("gain = " << gainDb << " + " << m_maxGain << " dB");
return gainDb + m_maxGain;
}
--- a/src/antenna/test/test-angles.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/antenna/test/test-angles.cc Sat Sep 01 20:57:21 2012 +0200
@@ -147,10 +147,10 @@
AddTestCase (new OneVectorConstructorTestCase (Vector (0, -1, 1), Angles (-M_PI_2, M_PI_4)));
AddTestCase (new OneVectorConstructorTestCase (Vector (0, -1, -1), Angles (-M_PI_2, 3*M_PI_4)));
- AddTestCase (new OneVectorConstructorTestCase (Vector (1, 1, sqrt (2)), Angles (M_PI_4, M_PI_4)));
- AddTestCase (new OneVectorConstructorTestCase (Vector (1, 1, -sqrt (2)), Angles (M_PI_4, 3*M_PI_4)));
- AddTestCase (new OneVectorConstructorTestCase (Vector (1, -1, sqrt (2)), Angles (-M_PI_4, M_PI_4)));
- AddTestCase (new OneVectorConstructorTestCase (Vector (-1, 1, sqrt (2)), Angles (3*M_PI_4, M_PI_4)));
+ AddTestCase (new OneVectorConstructorTestCase (Vector (1, 1, std::sqrt (2)), Angles (M_PI_4, M_PI_4)));
+ AddTestCase (new OneVectorConstructorTestCase (Vector (1, 1, -std::sqrt (2)), Angles (M_PI_4, 3*M_PI_4)));
+ AddTestCase (new OneVectorConstructorTestCase (Vector (1, -1, std::sqrt (2)), Angles (-M_PI_4, M_PI_4)));
+ AddTestCase (new OneVectorConstructorTestCase (Vector (-1, 1, std::sqrt (2)), Angles (3*M_PI_4, M_PI_4)));
@@ -182,10 +182,10 @@
AddTestCase (new TwoVectorsConstructorTestCase (Vector (0, -1, 1), Vector (0, 0, 0), Angles (-M_PI_2, M_PI_4)));
AddTestCase (new TwoVectorsConstructorTestCase (Vector (0, -1, -1), Vector (0, 0, 0), Angles (-M_PI_2, 3*M_PI_4)));
- AddTestCase (new TwoVectorsConstructorTestCase (Vector (1, 1, sqrt (2)), Vector (0, 0, 0), Angles (M_PI_4, M_PI_4)));
- AddTestCase (new TwoVectorsConstructorTestCase (Vector (1, 1, -sqrt (2)), Vector (0, 0, 0), Angles (M_PI_4, 3*M_PI_4)));
- AddTestCase (new TwoVectorsConstructorTestCase (Vector (1, -1, sqrt (2)), Vector (0, 0, 0), Angles (-M_PI_4, M_PI_4)));
- AddTestCase (new TwoVectorsConstructorTestCase (Vector (-1, 1, sqrt (2)), Vector (0, 0, 0), Angles (3*M_PI_4, M_PI_4)));
+ AddTestCase (new TwoVectorsConstructorTestCase (Vector (1, 1, std::sqrt (2)), Vector (0, 0, 0), Angles (M_PI_4, M_PI_4)));
+ AddTestCase (new TwoVectorsConstructorTestCase (Vector (1, 1, -std::sqrt (2)), Vector (0, 0, 0), Angles (M_PI_4, 3*M_PI_4)));
+ AddTestCase (new TwoVectorsConstructorTestCase (Vector (1, -1, std::sqrt (2)), Vector (0, 0, 0), Angles (-M_PI_4, M_PI_4)));
+ AddTestCase (new TwoVectorsConstructorTestCase (Vector (-1, 1, std::sqrt (2)), Vector (0, 0, 0), Angles (3*M_PI_4, M_PI_4)));
AddTestCase (new TwoVectorsConstructorTestCase (Vector (3, 2, 2), Vector (2, 2, 2), Angles (0, M_PI_2)));
@@ -202,8 +202,8 @@
AddTestCase (new TwoVectorsConstructorTestCase (Vector (0, -2, -6), Vector (-1, -2, -5), Angles (0, 3*M_PI_4)));
AddTestCase (new TwoVectorsConstructorTestCase (Vector (77, 3, 43), Vector (78, 2, 43), Angles (3*M_PI_4, M_PI_2)));
- AddTestCase (new TwoVectorsConstructorTestCase (Vector (24, -2, -6 -sqrt (2)), Vector (23, -3, -6), Angles (M_PI_4, 3*M_PI_4)));
- AddTestCase (new TwoVectorsConstructorTestCase (Vector (0.5, 11.45, sqrt (2)-1), Vector (-0.5, 12.45, -1), Angles (-M_PI_4, M_PI_4)));
+ AddTestCase (new TwoVectorsConstructorTestCase (Vector (24, -2, -6 -std::sqrt (2)), Vector (23, -3, -6), Angles (M_PI_4, 3*M_PI_4)));
+ AddTestCase (new TwoVectorsConstructorTestCase (Vector (0.5, 11.45, std::sqrt (2)-1), Vector (-0.5, 12.45, -1), Angles (-M_PI_4, M_PI_4)));
};
--- a/src/applications/model/onoff-application.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/applications/model/onoff-application.cc Sat Sep 01 20:57:21 2012 +0200
@@ -43,8 +43,6 @@
NS_LOG_COMPONENT_DEFINE ("OnOffApplication");
-using namespace std;
-
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (OnOffApplication);
@@ -293,7 +291,7 @@
void OnOffApplication::ConnectionFailed (Ptr<Socket>)
{
NS_LOG_FUNCTION_NOARGS ();
- cout << "OnOffApplication, Connection Failed" << endl;
+ std::cout << "OnOffApplication, Connection Failed" << std::endl;
}
} // Namespace ns3
--- a/src/applications/model/packet-sink.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/applications/model/packet-sink.cc Sat Sep 01 20:57:21 2012 +0200
@@ -32,8 +32,6 @@
#include "ns3/udp-socket-factory.h"
#include "packet-sink.h"
-using namespace std;
-
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("PacketSink");
--- a/src/applications/model/udp-client.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/applications/model/udp-client.cc Sat Sep 01 20:57:21 2012 +0200
@@ -30,8 +30,8 @@
#include "ns3/uinteger.h"
#include "udp-client.h"
#include "seq-ts-header.h"
-#include <stdlib.h>
-#include <stdio.h>
+#include <cstdlib>
+#include <cstdio>
namespace ns3 {
--- a/src/applications/model/udp-trace-client.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/applications/model/udp-trace-client.cc Sat Sep 01 20:57:21 2012 +0200
@@ -31,8 +31,8 @@
#include "ns3/string.h"
#include "seq-ts-header.h"
#include "udp-trace-client.h"
-#include <stdlib.h>
-#include <stdio.h>
+#include <cstdlib>
+#include <cstdio>
#include <fstream>
namespace ns3 {
--- a/src/buildings/model/building.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/buildings/model/building.cc Sat Sep 01 20:57:21 2012 +0200
@@ -27,7 +27,7 @@
#include <ns3/uinteger.h>
#include <ns3/log.h>
#include <ns3/assert.h>
-#include <math.h>
+#include <cmath>
NS_LOG_COMPONENT_DEFINE ("Building");
--- a/src/buildings/model/buildings-propagation-loss-model.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/buildings/model/buildings-propagation-loss-model.cc Sat Sep 01 20:57:21 2012 +0200
@@ -137,8 +137,8 @@
BuildingsPropagationLossModel::InternalWallsLoss (Ptr<BuildingsMobilityModel> a, Ptr<BuildingsMobilityModel>b) const
{
// approximate the number of internal walls with the Manhattan distance in "rooms" units
- double dx = abs (a->GetRoomNumberX () - b->GetRoomNumberX ());
- double dy = abs (a->GetRoomNumberY () - b->GetRoomNumberY ());
+ double dx = std::abs (a->GetRoomNumberX () - b->GetRoomNumberX ());
+ double dy = std::abs (a->GetRoomNumberY () - b->GetRoomNumberY ());
return m_lossInternalWall * (dx+dy);
}
@@ -195,7 +195,7 @@
}
else
{
- double sigma = sqrt ((m_shadowingSigmaOutdoor * m_shadowingSigmaOutdoor) + (m_shadowingSigmaExtWalls * m_shadowingSigmaExtWalls));
+ double sigma = std::sqrt ((m_shadowingSigmaOutdoor * m_shadowingSigmaOutdoor) + (m_shadowingSigmaExtWalls * m_shadowingSigmaExtWalls));
return (sigma);
}
}
@@ -206,7 +206,7 @@
}
else
{
- double sigma = sqrt ((m_shadowingSigmaOutdoor * m_shadowingSigmaOutdoor) + (m_shadowingSigmaExtWalls * m_shadowingSigmaExtWalls));
+ double sigma = std::sqrt ((m_shadowingSigmaOutdoor * m_shadowingSigmaOutdoor) + (m_shadowingSigmaExtWalls * m_shadowingSigmaExtWalls));
return (sigma);
}
}
--- a/src/buildings/model/itu-r-1238-propagation-loss-model.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/buildings/model/itu-r-1238-propagation-loss-model.cc Sat Sep 01 20:57:21 2012 +0200
@@ -60,7 +60,7 @@
NS_ASSERT_MSG ((a != 0) && (b != 0), "ItuR1238PropagationLossModel only works with BuildingsMobilityModel");
NS_ASSERT_MSG (a->GetBuilding ()->GetId () == b->GetBuilding ()->GetId (), "ITU-R 1238 applies only to nodes that are in the same building");
double N = 0.0;
- int n = abs (a->GetFloorNumber () - b->GetFloorNumber ());
+ int n = std::abs (a->GetFloorNumber () - b->GetFloorNumber ());
NS_LOG_LOGIC (this << " A floor " << (uint16_t)a->GetFloorNumber () << " B floor " << (uint16_t)b->GetFloorNumber () << " n " << n);
double Lf = 0.0;
Ptr<Building> aBuilding = a->GetBuilding ();
@@ -95,7 +95,7 @@
{
NS_LOG_ERROR (this << " Unkwnon Wall Type");
}
- double loss = 20 * log10 (m_frequency / 1e6 /*MHz*/) + N*log10 (a->GetDistanceFrom (b)) + Lf - 28.0;
+ double loss = 20 * std::log10 (m_frequency / 1e6 /*MHz*/) + N * std::log10 (a->GetDistanceFrom (b)) + Lf - 28.0;
NS_LOG_INFO (this << " Node " << a->GetPosition () << " <-> " << b->GetPosition () << " loss = " << loss << " dB");
return loss;
--- a/src/buildings/model/oh-buildings-propagation-loss-model.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/buildings/model/oh-buildings-propagation-loss-model.cc Sat Sep 01 20:57:21 2012 +0200
@@ -24,7 +24,7 @@
#include "ns3/mobility-model.h"
#include "ns3/double.h"
#include "ns3/pointer.h"
-#include <math.h>
+#include <cmath>
#include "oh-buildings-propagation-loss-model.h"
#include "ns3/buildings-mobility-model.h"
#include "ns3/okumura-hata-propagation-loss-model.h"
--- a/src/buildings/test/buildings-shadowing-test.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/buildings/test/buildings-shadowing-test.cc Sat Sep 01 20:57:21 2012 +0200
@@ -112,13 +112,13 @@
sumSquared += (loss.at (loss.size () - 1) * loss.at (loss.size () - 1));
}
double mean = sum / samples;
- double sigma = sqrt (sumSquared / samples - (mean * mean));
+ double sigma = std::sqrt (sumSquared / samples - (mean * mean));
// test whether the distribution falls in the 99% confidence interval, as expected with a nornal distribution
- double ci = (2.575829303549 * sigma) / sqrt (samples);
+ double ci = (2.575829303549 * sigma) / std::sqrt (samples);
NS_LOG_INFO ("Mean from simulation " << mean << ", sigma " << sigma << ", reference value " << m_sigmaRef << ", CI(99%) " << ci);
- NS_TEST_ASSERT_MSG_EQ_TOL (fabs (mean), 0.0, ci, "Wrong shadowing distribution !");
+ NS_TEST_ASSERT_MSG_EQ_TOL (std::fabs (mean), 0.0, ci, "Wrong shadowing distribution !");
Simulator::Destroy ();
}
--- a/src/config-store/model/config-store.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/config-store/model/config-store.cc Sat Sep 01 20:57:21 2012 +0200
@@ -15,7 +15,7 @@
#include <fstream>
#include <iostream>
#include <unistd.h>
-#include <stdlib.h>
+#include <cstdlib>
NS_LOG_COMPONENT_DEFINE ("ConfigStore");
--- a/src/core/examples/sample-random-variable-stream.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/examples/sample-random-variable-stream.cc Sat Sep 01 20:57:21 2012 +0200
@@ -22,7 +22,6 @@
#include <iostream>
using namespace ns3;
-using namespace std;
/*
* This program can be run from waf such as "./waf --run sample-random-variable-stream"
@@ -60,6 +59,6 @@
Ptr<UniformRandomVariable> uv = CreateObject<UniformRandomVariable> ();
- cout << uv->GetValue () << endl;
+ std::cout << uv->GetValue () << std::endl;
}
--- a/src/core/examples/sample-random-variable.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/examples/sample-random-variable.cc Sat Sep 01 20:57:21 2012 +0200
@@ -20,7 +20,6 @@
#include <iostream>
using namespace ns3;
-using namespace std;
/*
* This program can be run from waf such as "./waf --run sample-random-variable"
@@ -58,6 +57,6 @@
UniformVariable uv;
- cout << uv.GetValue () << endl;
+ std::cout << uv.GetValue () << std::endl;
}
--- a/src/core/model/callback.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/callback.cc Sat Sep 01 20:57:21 2012 +0200
@@ -42,7 +42,7 @@
#if (__GNUC__ >= 3)
-#include <stdlib.h>
+#include <cstdlib>
#include <cxxabi.h>
#include "log.h"
@@ -78,7 +78,7 @@
}
if (demangled) {
- free (demangled);
+ std::free (demangled);
}
return ret;
}
--- a/src/core/model/command-line.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/command-line.cc Sat Sep 01 20:57:21 2012 +0200
@@ -17,14 +17,16 @@
*
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
+
+#include <cstdlib> // for exit
+
#include "command-line.h"
#include "log.h"
#include "config.h"
#include "global-value.h"
#include "type-id.h"
#include "string.h"
-#include <stdlib.h>
-#include <stdarg.h>
+
NS_LOG_COMPONENT_DEFINE ("CommandLine");
@@ -227,37 +229,37 @@
{
// method below never returns.
PrintHelp ();
- exit (0);
+ std::exit (0);
}
else if (name == "PrintGroups")
{
// method below never returns.
PrintGroups ();
- exit (0);
+ std::exit (0);
}
else if (name == "PrintTypeIds")
{
// method below never returns.
PrintTypeIds ();
- exit (0);
+ std::exit (0);
}
else if (name == "PrintGlobals")
{
// method below never returns.
PrintGlobals ();
- exit (0);
+ std::exit (0);
}
else if (name == "PrintGroup")
{
// method below never returns.
PrintGroup (value);
- exit (0);
+ std::exit (0);
}
else if (name == "PrintAttributes")
{
// method below never returns.
PrintAttributes (value);
- exit (0);
+ std::exit (0);
}
else
{
@@ -268,7 +270,7 @@
if (!(*i)->Parse (value))
{
std::cerr << "Invalid argument value: "<<name<<"="<<value << std::endl;
- exit (1);
+ std::exit (1);
}
else
{
@@ -282,7 +284,7 @@
{
std::cerr << "Invalid command-line arguments: --"<<name<<"="<<value<<std::endl;
PrintHelp ();
- exit (1);
+ std::exit (1);
}
}
--- a/src/core/model/default-simulator-impl.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/default-simulator-impl.cc Sat Sep 01 20:57:21 2012 +0200
@@ -28,7 +28,7 @@
#include "assert.h"
#include "log.h"
-#include <math.h>
+#include <cmath>
NS_LOG_COMPONENT_DEFINE ("DefaultSimulatorImpl");
--- a/src/core/model/global-value.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/global-value.cc Sat Sep 01 20:57:21 2012 +0200
@@ -25,7 +25,7 @@
#include "ns3/core-config.h"
#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
+#include <cstdlib>
#endif
namespace ns3 {
--- a/src/core/model/int64x64-128.h Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/int64x64-128.h Sat Sep 01 20:57:21 2012 +0200
@@ -4,7 +4,7 @@
#include "ns3/core-config.h"
#include <stdint.h>
-#include <math.h>
+#include <cmath>
#if defined(HAVE___UINT128_T) && !defined(HAVE_UINT128_T)
typedef __uint128_t uint128_t;
@@ -26,7 +26,7 @@
{
bool is_negative = value < 0;
value = is_negative ? -value : value;
- double hi = floor (value);
+ double hi = std::floor (value);
double lo = (value - hi) * HP128_MAX_64;
_v = (int128_t)hi;
_v <<= 64;
--- a/src/core/model/int64x64-cairo.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/int64x64-cairo.cc Sat Sep 01 20:57:21 2012 +0200
@@ -21,7 +21,7 @@
#include "test.h"
#include "abort.h"
#include "assert.h"
-#include <math.h>
+#include <cmath>
#include <iostream>
namespace ns3 {
--- a/src/core/model/int64x64-cairo.h Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/int64x64-cairo.h Sat Sep 01 20:57:21 2012 +0200
@@ -3,7 +3,8 @@
#define INT64X64_CAIRO_H
#include <stdint.h>
-#include <math.h>
+#include <cmath>
+
#include "cairo-wideint-private.h"
#ifdef __i386__
@@ -24,8 +25,8 @@
inline int64x64_t (double value)
{
#define HPCAIRO_MAX_64 18446744073709551615.0
- double fhi = floor (value);
- int64_t hi = lround (fhi);
+ double fhi = std::floor (value);
+ int64_t hi = std::lround (fhi);
uint64_t lo = (uint64_t)((value - fhi) * HPCAIRO_MAX_64);
_v.hi = hi;
_v.lo = lo;
--- a/src/core/model/int64x64-double.h Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/int64x64-double.h Sat Sep 01 20:57:21 2012 +0200
@@ -3,7 +3,7 @@
#define INT64X64_DOUBLE_H
#include <iostream>
-#include <math.h>
+#include <cmath>
namespace ns3 {
@@ -43,7 +43,7 @@
}
inline int64_t GetHigh (void) const
{
- return (int64_t)floor (_v);
+ return (int64_t)std::floor (_v);
}
inline uint64_t GetLow (void) const
{
--- a/src/core/model/log.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/log.cc Sat Sep 01 20:57:21 2012 +0200
@@ -22,17 +22,16 @@
#include <list>
#include <utility>
#include <iostream>
-#include <string.h>
#include "assert.h"
#include "ns3/core-config.h"
#include "fatal-error.h"
#ifdef HAVE_GETENV
-#include <string.h>
+#include <cstring>
#endif
#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
+#include <cstdlib>
#endif
namespace ns3 {
@@ -390,7 +389,7 @@
{
#ifdef HAVE_GETENV
char *envVar = getenv ("NS_LOG");
- if (envVar == 0 || strlen(envVar) == 0)
+ if (envVar == 0 || std::strlen(envVar) == 0)
{
return;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/model/math.h Sat Sep 01 20:57:21 2012 +0200
@@ -0,0 +1,16 @@
+#ifndef MATH_H
+#define MATH_H
+
+#include <cmath>
+
+#ifdef __FreeBSD__
+
+#if __FreeBSD_version <= 704101 || \
+ (__FreeBSD_version >= 800000 && __FreeBSD_version < 802502) || \
+ (__FreeBSD_version >= 900000 && __FreeBSD_version < 900027)
+#define log2(x) (std::log(x) / M_LN2)
+#endif /* __FreeBSD_version */
+
+#endif /* __FreeBSD__ */
+
+#endif /* MATH_H */
--- a/src/core/model/nstime.h Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/nstime.h Sat Sep 01 20:57:21 2012 +0200
@@ -25,7 +25,7 @@
#include "attribute-helper.h"
#include "int64x64.h"
#include <stdint.h>
-#include <math.h>
+#include <cmath>
#include <ostream>
namespace ns3 {
--- a/src/core/model/object-base.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/object-base.cc Sat Sep 01 20:57:21 2012 +0200
@@ -24,7 +24,7 @@
#include "string.h"
#include "ns3/core-config.h"
#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
+#include <cstdlib>
#endif
NS_LOG_COMPONENT_DEFINE ("ObjectBase");
--- a/src/core/model/object.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/object.cc Sat Sep 01 20:57:21 2012 +0200
@@ -18,6 +18,7 @@
* Authors: Gustavo Carneiro <gjcarneiro@gmail.com>,
* Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
+
#include "object.h"
#include "object-factory.h"
#include "assert.h"
@@ -27,8 +28,10 @@
#include "string.h"
#include <vector>
#include <sstream>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
+
+
NS_LOG_COMPONENT_DEFINE ("Object");
@@ -85,7 +88,7 @@
: m_tid (Object::GetTypeId ()),
m_disposed (false),
m_started (false),
- m_aggregates ((struct Aggregates *) malloc (sizeof (struct Aggregates))),
+ m_aggregates ((struct Aggregates *) std::malloc (sizeof (struct Aggregates))),
m_getObjectCount (0)
{
m_aggregates->n = 1;
@@ -100,7 +103,7 @@
Object *current = m_aggregates->buffer[i];
if (current == this)
{
- memmove (&m_aggregates->buffer[i],
+ std::memmove (&m_aggregates->buffer[i],
&m_aggregates->buffer[i+1],
sizeof (Object *)*(m_aggregates->n - (i+1)));
m_aggregates->n--;
@@ -110,7 +113,7 @@
// delete the aggregate list
if (m_aggregates->n == 0)
{
- free (m_aggregates);
+ std::free (m_aggregates);
}
m_aggregates = 0;
}
@@ -118,7 +121,7 @@
: m_tid (o.m_tid),
m_disposed (false),
m_started (false),
- m_aggregates ((struct Aggregates *) malloc (sizeof (struct Aggregates))),
+ m_aggregates ((struct Aggregates *) std::malloc (sizeof (struct Aggregates))),
m_getObjectCount (0)
{
m_aggregates->n = 1;
@@ -242,11 +245,11 @@
// first create the new aggregate buffer.
uint32_t total = m_aggregates->n + other->m_aggregates->n;
struct Aggregates *aggregates =
- (struct Aggregates *)malloc (sizeof(struct Aggregates)+(total-1)*sizeof(Object*));
+ (struct Aggregates *)std::malloc (sizeof(struct Aggregates)+(total-1)*sizeof(Object*));
aggregates->n = total;
// copy our buffer to the new buffer
- memcpy (&aggregates->buffer[0],
+ std::memcpy (&aggregates->buffer[0],
&m_aggregates->buffer[0],
m_aggregates->n*sizeof(Object*));
@@ -287,8 +290,8 @@
}
// Now that we are done with them, we can free our old aggregate buffers
- free (a);
- free (b);
+ std::free (a);
+ std::free (b);
}
/**
* This function must be implemented in the stack that needs to notify
--- a/src/core/model/random-variable-stream.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/random-variable-stream.cc Sat Sep 01 20:57:21 2012 +0200
@@ -645,13 +645,13 @@
double w = v1 * v1 + v2 * v2;
if (w <= 1.0)
{ // Got good pair
- double y = sqrt ((-2 * log (w)) / w);
- m_next = mean + v2 * y * sqrt (variance);
+ double y = std::sqrt ((-2 * std::log (w)) / w);
+ m_next = mean + v2 * y * std::sqrt (variance);
// if next is in bounds, it is valid
- m_nextValid = fabs (m_next - mean) <= bound;
- double x1 = mean + v1 * y * sqrt (variance);
+ m_nextValid = std::fabs (m_next - mean) <= bound;
+ double x1 = mean + v1 * y * std::sqrt (variance);
// if x1 is in bounds, return it
- if (fabs (x1 - mean) <= bound)
+ if (std::fabs (x1 - mean) <= bound)
{
return x1;
}
@@ -863,7 +863,7 @@
double x, v, u;
double d = alpha - 1.0 / 3.0;
- double c = (1.0 / 3.0) / sqrt (d);
+ double c = (1.0 / 3.0) / std::sqrt (d);
while (1)
{
@@ -890,7 +890,7 @@
{
break;
}
- if (log (u) < 0.5 * x * x + d * (1 - v + log (v)))
+ if (std::log (u) < 0.5 * x * x + d * (1 - v + std::log (v)))
{
break;
}
@@ -940,13 +940,13 @@
double w = v1 * v1 + v2 * v2;
if (w <= 1.0)
{ // Got good pair
- double y = sqrt ((-2 * log (w)) / w);
- m_next = mean + v2 * y * sqrt (variance);
+ double y = std::sqrt ((-2 * std::log (w)) / w);
+ m_next = mean + v2 * y * std::sqrt (variance);
// if next is in bounds, it is valid
- m_nextValid = fabs (m_next - mean) <= bound;
- double x1 = mean + v1 * y * sqrt (variance);
+ m_nextValid = std::fabs (m_next - mean) <= bound;
+ double x1 = mean + v1 * y * std::sqrt (variance);
// if x1 is in bounds, return it
- if (fabs (x1 - mean) <= bound)
+ if (std::fabs (x1 - mean) <= bound)
{
return x1;
}
@@ -1127,11 +1127,11 @@
// Calculate the triangular random variable.
if (u <= (mode - min) / (max - min) )
{
- return min + sqrt (u * (max - min) * (mode - min) );
+ return min + std::sqrt (u * (max - min) * (mode - min) );
}
else
{
- return max - sqrt ( (1 - u) * (max - min) * (max - mode) );
+ return max - std::sqrt ( (1 - u) * (max - min) * (max - mode) );
}
}
--- a/src/core/model/random-variable.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/random-variable.cc Sat Sep 01 20:57:21 2012 +0200
@@ -20,9 +20,8 @@
//
#include <iostream>
-
-#include <math.h>
-#include <stdlib.h>
+#include <cmath>
+#include <cstdlib>
#include <sys/time.h> // for gettimeofday
#include <unistd.h>
#include <iostream>
@@ -38,7 +37,6 @@
#include "rng-stream.h"
#include "fatal-error.h"
-using namespace std;
namespace ns3 {
@@ -545,7 +543,7 @@
RngStream *generator = GetStream ();
while (1)
{
- double r = -m_mean*log (generator->RandU01 ());
+ double r = -m_mean*std::log (generator->RandU01 ());
if (m_bound == 0 || r <= m_bound)
{
return r;
@@ -706,7 +704,7 @@
RngStream *generator = GetStream ();
while (1)
{
- double r = (m_scale * ( 1.0 / pow (generator->RandU01 (), 1.0 / m_shape)));
+ double r = (m_scale * ( 1.0 / std::pow (generator->RandU01 (), 1.0 / m_shape)));
if (m_bound == 0 || r <= m_bound)
{
return r;
@@ -838,7 +836,7 @@
double exponent = 1.0 / m_alpha;
while (1)
{
- double r = m_mean * pow ( -log (generator->RandU01 ()), exponent);
+ double r = m_mean * std::pow ( -std::log (generator->RandU01 ()), exponent);
if (m_bound == 0 || r <= m_bound)
{
return r;
@@ -958,13 +956,13 @@
double w = v1 * v1 + v2 * v2;
if (w <= 1.0)
{ // Got good pair
- double y = sqrt ((-2 * log (w)) / w);
- m_next = m_mean + v2 * y * sqrt (m_variance);
+ double y = std::sqrt ((-2 * std::log (w)) / w);
+ m_next = m_mean + v2 * y * std::sqrt (m_variance);
// if next is in bounds, it is valid
- m_nextValid = fabs (m_next - m_mean) <= m_bound;
- double x1 = m_mean + v1 * y * sqrt (m_variance);
+ m_nextValid = std::fabs (m_next - m_mean) <= m_bound;
+ double x1 = m_mean + v1 * y * std::sqrt (m_variance);
// if x1 is in bounds, return it
- if (fabs (x1 - m_mean) <= m_bound)
+ if (std::fabs (x1 - m_mean) <= m_bound)
{
return x1;
}
@@ -1156,11 +1154,11 @@
ValueCDF& current = emp[i];
if (current.value < prior.value || current.cdf < prior.cdf)
{ // Error
- cerr << "Empirical Dist error,"
- << " current value " << current.value
- << " prior value " << prior.value
- << " current cdf " << current.cdf
- << " prior cdf " << prior.cdf << endl;
+ std::cerr << "Empirical Dist error,"
+ << " current value " << current.value
+ << " prior value " << prior.value
+ << " current cdf " << current.cdf
+ << " prior cdf " << prior.cdf << std::endl;
NS_FATAL_ERROR ("Empirical Dist error");
}
prior = current;
@@ -1226,7 +1224,7 @@
double IntEmpiricalVariableImpl::Interpolate (double c1, double c2,
double v1, double v2, double r)
{ // Interpolate random value in range [v1..v2) based on [c1 .. r .. c2)
- return ceil (v1 + ((v2 - v1) / (c2 - c1)) * (r - c1));
+ return std::ceil (v1 + ((v2 - v1) / (c2 - c1)) * (r - c1));
}
IntEmpiricalVariable::IntEmpiricalVariable ()
@@ -1375,9 +1373,9 @@
}
while (r2 > 1.0 || r2 == 0);
- normal = u * sqrt (-2.0 * log (r2) / r2);
+ normal = u * std::sqrt (-2.0 * std::log (r2) / r2);
- z = exp (m_sigma * normal + m_mu);
+ z = std::exp (m_sigma * normal + m_mu);
return z;
}
@@ -1460,12 +1458,12 @@
if (alpha < 1)
{
double u = generator->RandU01 ();
- return GetValue (1.0 + alpha, beta) * pow (u, 1.0 / alpha);
+ return GetValue (1.0 + alpha, beta) * std::pow (u, 1.0 / alpha);
}
double x, v, u;
double d = alpha - 1.0 / 3.0;
- double c = (1.0 / 3.0) / sqrt (d);
+ double c = (1.0 / 3.0) / std::sqrt (d);
while (1)
{
@@ -1482,7 +1480,7 @@
{
break;
}
- if (log (u) < 0.5 * x * x + d * (1 - v + log (v)))
+ if (std::log (u) < 0.5 * x * x + d * (1 - v + std::log (v)))
{
break;
}
@@ -1672,11 +1670,11 @@
double u = generator->RandU01 ();
if (u <= (m_mode - m_min) / (m_max - m_min) )
{
- return m_min + sqrt (u * (m_max - m_min) * (m_mode - m_min) );
+ return m_min + std::sqrt (u * (m_max - m_min) * (m_mode - m_min) );
}
else
{
- return m_max - sqrt ( (1 - u) * (m_max - m_min) * (m_max - m_mode) );
+ return m_max - std::sqrt ( (1 - u) * (m_max - m_min) * (m_max - m_mode) );
}
}
@@ -1745,7 +1743,7 @@
// calculate the normalization constant c
for (int i = 1; i <= n; i++)
{
- m_c += (1.0 / pow ((double)i,alpha));
+ m_c += (1.0 / std::pow ((double)i, alpha));
}
m_c = 1.0 / m_c;
}
@@ -1759,7 +1757,7 @@
double sum_prob = 0,zipf_value = 0;
for (int i = 1; i <= m_n; i++)
{
- sum_prob += m_c / pow ((double)i,m_alpha);
+ sum_prob += m_c / std::pow ((double)i, m_alpha);
if (sum_prob > u)
{
zipf_value = i;
@@ -1815,14 +1813,14 @@
ZetaVariableImpl::ZetaVariableImpl ()
: m_alpha (3.14),
- m_b (pow (2.0, 2.14))
+ m_b (std::pow (2.0, 2.14))
{
}
ZetaVariableImpl::ZetaVariableImpl (double alpha)
: m_alpha (alpha),
- m_b (pow (2.0, alpha - 1.0))
+ m_b (std::pow (2.0, alpha - 1.0))
{
}
@@ -1844,8 +1842,8 @@
{
u = generator->RandU01 ();
v = generator->RandU01 ();
- X = floor (pow (u, -1.0 / (m_alpha - 1.0)));
- T = pow (1.0 + 1.0 / X, m_alpha - 1.0);
+ X = floor (std::pow (u, -1.0 / (m_alpha - 1.0)));
+ T = std::pow (1.0 + 1.0 / X, m_alpha - 1.0);
test = v * X * (T - 1.0) / (m_b - 1.0);
}
while ( test > (T / m_b) );
@@ -1909,7 +1907,7 @@
value = value.substr (tmp + 1, value.npos);
if (type == "Constant")
{
- istringstream iss (value);
+ std::istringstream iss (value);
double constant;
iss >> constant;
var = ConstantVariable (constant);
@@ -1927,8 +1925,8 @@
{
NS_FATAL_ERROR ("bad Uniform value: " << value);
}
- istringstream issA (value.substr (0, tmp));
- istringstream issB (value.substr (tmp + 1, value.npos));
+ std::istringstream issA (value.substr (0, tmp));
+ std::istringstream issB (value.substr (tmp + 1, value.npos));
double a, b;
issA >> a;
issB >> b;
@@ -1953,8 +1951,8 @@
tmp2 = sub.find (":");
if (tmp2 == value.npos)
{
- istringstream issA (value.substr (0, tmp));
- istringstream issB (sub);
+ std::istringstream issA (value.substr (0, tmp));
+ std::istringstream issB (sub);
double a, b;
issA >> a;
issB >> b;
@@ -1962,9 +1960,9 @@
}
else
{
- istringstream issA (value.substr (0, tmp));
- istringstream issB (sub.substr (0, tmp2));
- istringstream issC (sub.substr (tmp2 + 1, value.npos));
+ std::istringstream issA (value.substr (0, tmp));
+ std::istringstream issB (sub.substr (0, tmp2));
+ std::istringstream issC (sub.substr (tmp2 + 1, value.npos));
double a, b, c;
issA >> a;
issB >> b;
--- a/src/core/model/realtime-simulator-impl.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/realtime-simulator-impl.cc Sat Sep 01 20:57:21 2012 +0200
@@ -33,7 +33,7 @@
#include "enum.h"
-#include <math.h>
+#include <cmath>
NS_LOG_COMPONENT_DEFINE ("RealtimeSimulatorImpl");
--- a/src/core/model/simulator.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/simulator.cc Sat Sep 01 20:57:21 2012 +0200
@@ -31,7 +31,7 @@
#include "assert.h"
#include "log.h"
-#include <math.h>
+#include <cmath>
#include <fstream>
#include <list>
#include <vector>
--- a/src/core/model/system-path.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/system-path.cc Sat Sep 01 20:57:21 2012 +0200
@@ -21,9 +21,9 @@
#include "fatal-error.h"
#include "assert.h"
#include "ns3/core-config.h"
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
+#include <cstdlib>
+#include <cerrno>
+#include <cstring>
#if defined (HAVE_DIRENT_H) and defined (HAVE_SYS_TYPES_H)
#define HAVE_OPENDIR
#include <sys/types.h>
--- a/src/core/model/system-thread.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/system-thread.cc Sat Sep 01 20:57:21 2012 +0200
@@ -21,7 +21,7 @@
#include "fatal-error.h"
#include "system-thread.h"
#include "log.h"
-#include <string.h>
+#include <cstring>
NS_LOG_COMPONENT_DEFINE ("SystemThread");
--- a/src/core/model/test.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/test.cc Sat Sep 01 20:57:21 2012 +0200
@@ -20,8 +20,8 @@
#include "assert.h"
#include "abort.h"
#include "system-path.h"
-#include <math.h>
-#include <string.h>
+#include <cmath>
+#include <cstring>
#include <vector>
#include <list>
@@ -38,14 +38,14 @@
// Find exponent of largest absolute value
//
{
- double max = (fabs (x1) > fabs (x2)) ? x1 : x2;
- (void)frexp (max, &exponent);
+ double max = (std::fabs (x1) > std::fabs (x2)) ? x1 : x2;
+ (void)std::frexp (max, &exponent);
}
//
// Form a neighborhood of size 2 * delta
//
- delta = ldexp (epsilon, exponent);
+ delta = std::ldexp (epsilon, exponent);
difference = x1 - x2;
if (difference > delta || difference < -delta)
--- a/src/core/model/time.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/time.cc Sat Sep 01 20:57:21 2012 +0200
@@ -26,7 +26,7 @@
#include "string.h"
#include "object.h"
#include "config.h"
-#include <math.h>
+#include <cmath>
#include <sstream>
namespace ns3 {
@@ -101,7 +101,7 @@
for (int i = 0; i < Time::LAST; i++)
{
int shift = power[i] - power[(int)unit];
- uint64_t factor = (uint64_t) pow (10, fabs (shift));
+ uint64_t factor = (uint64_t) std::pow (10, std::fabs (shift));
struct Information *info = &resolution->info[i];
info->factor = factor;
if (shift == 0)
--- a/src/core/model/unix-fd-reader.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/unix-fd-reader.cc Sat Sep 01 20:57:21 2012 +0200
@@ -19,8 +19,8 @@
* Author: Tom Goff <thomas.goff@boeing.com>
*/
-#include <errno.h>
-#include <string.h>
+#include <cerrno>
+#include <cstring>
#include <unistd.h>
#include <fcntl.h>
@@ -59,18 +59,18 @@
tmp = pipe (m_evpipe);
if (tmp == -1)
{
- NS_FATAL_ERROR ("pipe() failed: " << strerror (errno));
+ NS_FATAL_ERROR ("pipe() failed: " << std::strerror (errno));
}
// make the read end non-blocking
tmp = fcntl (m_evpipe[0], F_GETFL);
if (tmp == -1)
{
- NS_FATAL_ERROR ("fcntl() failed: " << strerror (errno));
+ NS_FATAL_ERROR ("fcntl() failed: " << std::strerror (errno));
}
if (fcntl (m_evpipe[0], F_SETFL, tmp | O_NONBLOCK) == -1)
{
- NS_FATAL_ERROR ("fcntl() failed: " << strerror (errno));
+ NS_FATAL_ERROR ("fcntl() failed: " << std::strerror (errno));
}
m_fd = fd;
@@ -116,7 +116,7 @@
char zero = 0;
ssize_t len = write (m_evpipe[1], &zero, sizeof (zero));
if (len != sizeof (zero))
- NS_LOG_WARN ("incomplete write(): " << strerror (errno));
+ NS_LOG_WARN ("incomplete write(): " << std::strerror (errno));
}
// join the read thread
@@ -166,7 +166,7 @@
r = select (nfds, &readfds, NULL, NULL, NULL);
if (r == -1 && errno != EINTR)
{
- NS_FATAL_ERROR ("select() failed: " << strerror (errno));
+ NS_FATAL_ERROR ("select() failed: " << std::strerror (errno));
}
if (FD_ISSET (m_evpipe[0], &readfds))
@@ -188,7 +188,7 @@
}
else
{
- NS_FATAL_ERROR ("read() failed: " << strerror (errno));
+ NS_FATAL_ERROR ("read() failed: " << std::strerror (errno));
}
}
}
--- a/src/core/model/unix-system-condition.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/unix-system-condition.cc Sat Sep 01 20:57:21 2012 +0200
@@ -17,12 +17,14 @@
*/
#include <pthread.h>
-#include <errno.h>
+#include <cerrno> // for ETIMEDOUT
#include <sys/time.h>
+
#include "fatal-error.h"
#include "system-condition.h"
#include "log.h"
+
NS_LOG_COMPONENT_DEFINE ("SystemCondition");
namespace ns3 {
--- a/src/core/model/unix-system-mutex.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/unix-system-mutex.cc Sat Sep 01 20:57:21 2012 +0200
@@ -19,12 +19,14 @@
*/
#include <pthread.h>
-#include <string.h>
-#include <errno.h>
+#include <cstring>
+#include <cerrno> // for strerror
+
#include "fatal-error.h"
#include "system-mutex.h"
#include "log.h"
+
NS_LOG_COMPONENT_DEFINE ("SystemMutex");
namespace ns3 {
@@ -79,7 +81,7 @@
{
NS_FATAL_ERROR ("SystemMutexPrivate::Lock()"
"pthread_mutex_lock failed: " << rc << " = \"" <<
- strerror (rc) << "\"");
+ std::strerror (rc) << "\"");
}
}
@@ -93,7 +95,7 @@
{
NS_FATAL_ERROR ("SystemMutexPrivate::Unlock()"
"pthread_mutex_unlock failed: " << rc << " = \"" <<
- strerror (rc) << "\"");
+ std::strerror (rc) << "\"");
}
}
--- a/src/core/model/wall-clock-synchronizer.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/wall-clock-synchronizer.cc Sat Sep 01 20:57:21 2012 +0200
@@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <time.h>
+#include <ctime> // for clock_getres
#include <sys/time.h>
#include "log.h"
--- a/src/core/model/win32-system-wall-clock-ms.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/model/win32-system-wall-clock-ms.cc Sat Sep 01 20:57:21 2012 +0200
@@ -20,7 +20,7 @@
#include "system-wall-clock-ms.h"
-#include <time.h>
+#include <ctime>
namespace ns3 {
@@ -42,7 +42,7 @@
void
SystemWallClockMsPrivate::Start (void)
{
- m_startTime = clock ();
+ m_startTime = std::clock ();
}
int64_t
@@ -77,7 +77,7 @@
static int64_t ticksPerSecond = CLOCKS_PER_SEC;
static double millisecondsPerTick = 1000. / ticksPerSecond;
- clock_t endTime = clock ();
+ clock_t endTime = std::clock ();
double tmp;
--- a/src/core/test/command-line-test-suite.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/test/command-line-test-suite.cc Sat Sep 01 20:57:21 2012 +0200
@@ -24,8 +24,8 @@
#include "ns3/type-id.h"
#include "ns3/test.h"
#include "ns3/string.h"
-#include <stdlib.h>
-#include <stdarg.h>
+#include <cstdlib>
+#include <cstdarg>
namespace ns3 {
--- a/src/core/test/random-variable-stream-test-suite.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/test/random-variable-stream-test-suite.cc Sat Sep 01 20:57:21 2012 +0200
@@ -22,11 +22,10 @@
*/
-#include <math.h>
#include <gsl/gsl_cdf.h>
#include <gsl/gsl_histogram.h>
#include <gsl/gsl_sf_zeta.h>
-#include <time.h>
+#include <ctime>
#include <fstream>
#include <cmath>
--- a/src/core/test/random-variable-test-suite.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/test/random-variable-test-suite.cc Sat Sep 01 20:57:21 2012 +0200
@@ -20,15 +20,14 @@
//
#include <iostream>
-#include <math.h>
+#include <cmath>
+#include <vector>
#include "ns3/test.h"
#include "ns3/assert.h"
#include "ns3/integer.h"
#include "ns3/random-variable.h"
-using namespace std;
-
namespace ns3 {
class BasicRandomNumberTestCase : public TestCase
{
@@ -53,16 +52,16 @@
const double desiredMean = 1.0;
const double desiredStdDev = 1.0;
- double tmp = log (1 + (desiredStdDev / desiredMean) * (desiredStdDev / desiredMean));
- double sigma = sqrt (tmp);
- double mu = log (desiredMean) - 0.5 * tmp;
+ double tmp = std::log (1 + (desiredStdDev / desiredMean) * (desiredStdDev / desiredMean));
+ double sigma = std::sqrt (tmp);
+ double mu = std::log (desiredMean) - 0.5 * tmp;
//
// Test a custom lognormal instance to see if its moments have any relation
// expected reality.
//
LogNormalVariable lognormal (mu, sigma);
- vector<double> samples;
+ std::vector<double> samples;
const int NSAMPLES = 10000;
double sum = 0;
@@ -83,12 +82,12 @@
// Wander back through the saved stamples and find their standard deviation
//
sum = 0;
- for (vector<double>::iterator iter = samples.begin (); iter != samples.end (); iter++)
+ for (std::vector<double>::iterator iter = samples.begin (); iter != samples.end (); iter++)
{
double tmp = (*iter - obtainedMean);
sum += tmp * tmp;
}
- double obtainedStdDev = sqrt (sum / (NSAMPLES - 1));
+ double obtainedStdDev = std::sqrt (sum / (NSAMPLES - 1));
NS_TEST_EXPECT_MSG_EQ_TOL (obtainedStdDev, desiredStdDev, 0.1, "Got unexpected standard deviation from LogNormalVariable");
}
--- a/src/core/test/rng-test-suite.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/test/rng-test-suite.cc Sat Sep 01 20:57:21 2012 +0200
@@ -15,10 +15,10 @@
*/
-#include <math.h>
+#include <cmath>
#include <gsl/gsl_cdf.h>
#include <gsl/gsl_histogram.h>
-#include <time.h>
+#include <ctime>
#include <fstream>
#include "ns3/test.h"
@@ -70,7 +70,7 @@
double
RngUniformTestCase::ChiSquaredTest (UniformVariable &u)
{
- gsl_histogram * h = gsl_histogram_alloc (N_BINS);
+ gsl_histogram * h = gsl_histogram_alloc (N_BINS);
gsl_histogram_set_ranges_uniform (h, 0., 1.);
for (uint32_t i = 0; i < N_MEASUREMENTS; ++i)
--- a/src/core/test/threaded-test-suite.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/test/threaded-test-suite.cc Sat Sep 01 20:57:21 2012 +0200
@@ -27,7 +27,7 @@
#include "ns3/string.h"
#include "ns3/system-thread.h"
-#include <time.h>
+#include <ctime>
#include <list>
#include <utility>
@@ -99,7 +99,7 @@
struct timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 500;
- nanosleep(&ts, NULL);
+ nanosleep (&ts, NULL);
}
}
}
--- a/src/core/wscript Fri Aug 31 12:24:28 2012 +0200
+++ b/src/core/wscript Sat Sep 01 20:57:21 2012 +0200
@@ -244,6 +244,7 @@
'model/fatal-impl.h',
'model/system-path.h',
'model/unused.h',
+ 'model/math.h',
]
if sys.platform == 'win32':
--- a/src/csma/model/csma-net-device.h Fri Aug 31 12:24:28 2012 +0200
+++ b/src/csma/model/csma-net-device.h Sat Sep 01 20:57:21 2012 +0200
@@ -21,7 +21,7 @@
#ifndef CSMA_NET_DEVICE_H
#define CSMA_NET_DEVICE_H
-#include <string.h>
+#include <cstring>
#include "ns3/node.h"
#include "ns3/backoff.h"
#include "ns3/address.h"
--- a/src/dsdv/examples/dsdv-manet.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/dsdv/examples/dsdv-manet.cc Sat Sep 01 20:57:21 2012 +0200
@@ -250,7 +250,7 @@
pos.Set ("X", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=1000.0]"));
pos.Set ("Y", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=1000.0]"));
- ostringstream speedConstantRandomVariableStream;
+ std::ostringstream speedConstantRandomVariableStream;
speedConstantRandomVariableStream << "ns3::ConstantRandomVariable[Constant="
<< m_nodeSpeed
<< "]";
--- a/src/dsr/examples/dsr.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/dsr/examples/dsr.cc Sat Sep 01 20:57:21 2012 +0200
@@ -147,12 +147,12 @@
pos.Set ("Y", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=1500.0]"));
Ptr<PositionAllocator> taPositionAlloc = pos.Create ()->GetObject<PositionAllocator> ();
- ostringstream speedUniformRandomVariableStream;
+ std::ostringstream speedUniformRandomVariableStream;
speedUniformRandomVariableStream << "ns3::UniformRandomVariable[Min=0.0|Max="
<< nodeSpeed
<< "]";
- ostringstream pauseConstantRandomVariableStream;
+ std::ostringstream pauseConstantRandomVariableStream;
pauseConstantRandomVariableStream << "ns3::ConstantRandomVariable[Constant="
<< pauseTime
<< "]";
--- a/src/dsr/model/dsr-routing.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/dsr/model/dsr-routing.cc Sat Sep 01 20:57:21 2012 +0200
@@ -2613,7 +2613,7 @@
if (m_rreqTable->GetRreqCnt (dst))
{
// When the route request count is larger than 0
- rreqDelay = Time (pow (m_rreqTable->GetRreqCnt (dst), 2) * m_requestPeriod);
+ rreqDelay = Time (std::pow (m_rreqTable->GetRreqCnt (dst), 2) * m_requestPeriod);
}
else
{
--- a/src/emu/model/emu-net-device.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/emu/model/emu-net-device.cc Sat Sep 01 20:57:21 2012 +0200
@@ -45,10 +45,10 @@
#include <netinet/in.h>
#include <netpacket/packet.h>
#include <arpa/inet.h>
-#include <errno.h>
+#include <cerrno>
#include <limits>
-#include <stdlib.h>
-#include <time.h>
+#include <cstdlib>
+#include <ctime>
#include <unistd.h>
NS_LOG_COMPONENT_DEFINE ("EmuNetDevice");
@@ -392,7 +392,7 @@
int sock = socket (PF_UNIX, SOCK_DGRAM, 0);
if (sock == -1)
{
- NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): Unix socket creation error, errno = " << strerror (errno));
+ NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): Unix socket creation error, errno = " << std::strerror (errno));
}
//
@@ -404,7 +404,7 @@
int status = bind (sock, (struct sockaddr*)&un, sizeof (sa_family_t));
if (status == -1)
{
- NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): Could not bind(): errno = " << strerror (errno));
+ NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): Could not bind(): errno = " << std::strerror (errno));
}
NS_LOG_INFO ("Created Unix socket");
@@ -421,7 +421,7 @@
status = getsockname (sock, (struct sockaddr*)&un, &len);
if (status == -1)
{
- NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): Could not getsockname(): errno = " << strerror (errno));
+ NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): Could not getsockname(): errno = " << std::strerror (errno));
}
//
@@ -466,7 +466,7 @@
// If the execlp successfully completes, it never returns. If it returns it failed or the OS is
// broken. In either case, we bail.
//
- NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): Back from execlp(), errno = " << ::strerror (errno));
+ NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): Back from execlp(), errno = " << std::strerror (errno));
}
else
{
@@ -479,7 +479,7 @@
pid_t waited = waitpid (pid, &st, 0);
if (waited == -1)
{
- NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): waitpid() fails, errno = " << strerror (errno));
+ NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): waitpid() fails, errno = " << std::strerror (errno));
}
NS_ASSERT_MSG (pid == waited, "EmuNetDevice::CreateSocket(): pid mismatch");
@@ -618,7 +618,7 @@
// Create a packet out of the buffer we received and free that buffer.
//
Ptr<Packet> packet = Create<Packet> (reinterpret_cast<const uint8_t *> (buf), len);
- free (buf);
+ std::free (buf);
buf = 0;
{
@@ -785,7 +785,7 @@
// buffer into the ns-3 context thread where it will create the packet, copy the buffer and then free it.
//
uint32_t bufferSize = 65536;
- uint8_t *buf = (uint8_t *)malloc (bufferSize);
+ uint8_t *buf = (uint8_t *)std::malloc (bufferSize);
if (buf == 0)
{
NS_FATAL_ERROR ("EmuNetDevice::ReadThread(): malloc packet buffer failed");
@@ -796,7 +796,7 @@
if (len == -1)
{
- free (buf);
+ std::free (buf);
buf = 0;
return;
}
--- a/src/emu/model/emu-net-device.h Fri Aug 31 12:24:28 2012 +0200
+++ b/src/emu/model/emu-net-device.h Sat Sep 01 20:57:21 2012 +0200
@@ -19,7 +19,8 @@
#ifndef EMU_NET_DEVICE_H
#define EMU_NET_DEVICE_H
-#include <string.h>
+#include <cstring>
+
#include "ns3/address.h"
#include "ns3/net-device.h"
#include "ns3/node.h"
--- a/src/emu/model/emu-sock-creator.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/emu/model/emu-sock-creator.cc Sat Sep 01 20:57:21 2012 +0200
@@ -21,8 +21,9 @@
#include <iostream>
#include <iomanip>
#include <sstream>
-#include <stdlib.h>
-#include <errno.h>
+#include <cstdlib>
+#include <cerrno>
+#include <cstring>
#include <sys/socket.h>
#include <sys/un.h>
@@ -49,7 +50,7 @@
std::cout << __FILE__ << ": fatal error at line " << __LINE__ << ": " << __FUNCTION__ << "(): " << msg << std::endl; \
if (printErrno) \
{ \
- std::cout << " errno = " << errno << " (" << strerror (errno) << ")" << std::endl; \
+ std::cout << " errno = " << errno << " (" << std::strerror (errno) << ")" << std::endl; \
} \
exit (-1);
--- a/src/energy/model/li-ion-energy-source.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/energy/model/li-ion-energy-source.cc Sat Sep 01 20:57:21 2012 +0200
@@ -289,12 +289,12 @@
double B = 3 / m_qExp;
// slope of the polarization curve
- double K = std::abs ( (m_eFull - m_eNom + A * (exp (-B * m_qNom) - 1)) * (m_qRated - m_qNom) / m_qNom);
+ double K = std::abs ( (m_eFull - m_eNom + A * (std::exp (-B * m_qNom) - 1)) * (m_qRated - m_qNom) / m_qNom);
// constant voltage
double E0 = m_eFull + K + m_internalResistance * m_typCurrent - A;
- double E = E0 - K * m_qRated / (m_qRated - it) + A * exp (-B * it);
+ double E = E0 - K * m_qRated / (m_qRated - it) + A * std::exp (-B * it);
// cell voltage
double V = E - m_internalResistance * i;
--- a/src/energy/model/rv-battery-model.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/energy/model/rv-battery-model.cc Sat Sep 01 20:57:21 2012 +0200
@@ -24,7 +24,7 @@
#include "ns3/double.h"
#include "ns3/trace-source-accessor.h"
#include "ns3/simulator.h"
-#include <math.h>
+#include <cmath>
NS_LOG_COMPONENT_DEFINE ("RvBatteryModel");
@@ -359,7 +359,7 @@
for (int m = 1; m <= m_numOfTerms; m++)
{
double square = beta * beta * m * m;
- sum += (exp (-square * (firstDelta)) - exp (-square * (secondDelta))) / square;
+ sum += (std::exp (-square * (firstDelta)) - std::exp (-square * (secondDelta))) / square;
}
return delta + 2 * sum;
}
--- a/src/energy/test/basic-energy-model-test.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/energy/test/basic-energy-model-test.cc Sat Sep 01 20:57:21 2012 +0200
@@ -33,7 +33,7 @@
#include "ns3/string.h"
#include "ns3/yans-wifi-helper.h"
#include "ns3/nqos-wifi-mac-helper.h"
-#include <math.h>
+#include <cmath>
using namespace ns3;
--- a/src/energy/test/rv-battery-model-test.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/energy/test/rv-battery-model-test.cc Sat Sep 01 20:57:21 2012 +0200
@@ -33,7 +33,7 @@
#include "ns3/string.h"
#include "ns3/yans-wifi-helper.h"
#include "ns3/nqos-wifi-mac-helper.h"
-#include <math.h>
+#include <cmath>
using namespace ns3;
--- a/src/flow-monitor/model/histogram.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/flow-monitor/model/histogram.cc Sat Sep 01 20:57:21 2012 +0200
@@ -18,7 +18,8 @@
// Author: Pedro Fortuna <pedro.fortuna@inescporto.pt> <pedro.fortuna@gmail.com>
//
-#include <math.h>
+#include <cmath>
+
#include "histogram.h"
#include "ns3/simulator.h"
#include "ns3/log.h"
@@ -78,7 +79,7 @@
void
Histogram::AddValue (double value)
{
- uint32_t index = (uint32_t)floor (value/m_binWidth);
+ uint32_t index = (uint32_t)std::floor (value/m_binWidth);
//check if we need to resize the vector
NS_LOG_DEBUG ("AddValue: index=" << index << ", m_histogram.size()=" << m_histogram.size ());
--- a/src/flow-monitor/model/ipv4-flow-probe.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/flow-monitor/model/ipv4-flow-probe.cc Sat Sep 01 20:57:21 2012 +0200
@@ -30,8 +30,6 @@
namespace ns3 {
-using namespace std;
-
NS_LOG_COMPONENT_DEFINE ("Ipv4FlowProbe");
//////////////////////////////////////
--- a/src/internet/model/nsc-tcp-socket-impl.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/internet/model/nsc-tcp-socket-impl.cc Sat Sep 01 20:57:21 2012 +0200
@@ -42,10 +42,9 @@
#include "sim_errno.h"
+
NS_LOG_COMPONENT_DEFINE ("NscTcpSocketImpl");
-using namespace std;
-
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (NscTcpSocketImpl);
--- a/src/internet/model/pending-data.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/internet/model/pending-data.cc Sat Sep 01 20:57:21 2012 +0200
@@ -26,12 +26,14 @@
#include <iostream>
#include <algorithm>
-#include <string.h>
+#include <cstring>
#include "ns3/fatal-error.h"
#include "ns3/log.h"
+
#include "pending-data.h"
+
NS_LOG_COMPONENT_DEFINE ("PendingData");
namespace ns3
--- a/src/internet/model/tcp-tx-buffer.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/internet/model/tcp-tx-buffer.cc Sat Sep 01 20:57:21 2012 +0200
@@ -20,10 +20,12 @@
#include <iostream>
#include <algorithm>
-#include <string.h>
+#include <cstring>
+
#include "ns3/packet.h"
#include "ns3/fatal-error.h"
#include "ns3/log.h"
+
#include "tcp-tx-buffer.h"
NS_LOG_COMPONENT_DEFINE ("TcpTxBuffer");
--- a/src/internet/test/global-route-manager-impl-test-suite.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/internet/test/global-route-manager-impl-test-suite.cc Sat Sep 01 20:57:21 2012 +0200
@@ -26,7 +26,7 @@
#include "ns3/global-route-manager-impl.h"
#include "ns3/candidate-queue.h"
#include "ns3/simulator.h"
-#include <stdlib.h> // for rand()
+#include <cstdlib> // for rand()
namespace ns3 {
@@ -49,7 +49,7 @@
for (int i = 0; i < 100; ++i)
{
SPFVertex *v = new SPFVertex;
- v->SetDistanceFromRoot (rand () % 100);
+ v->SetDistanceFromRoot (std::rand () % 100);
candidate.Push (v);
}
--- a/src/lte/examples/lena-profiling.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/lte/examples/lena-profiling.cc Sat Sep 01 20:57:21 2012 +0200
@@ -59,7 +59,7 @@
double nodeHeight = 1.5;
double roomHeight = 3;
double roomLength = 8;
- uint32_t nRooms = ceil (sqrt (nEnbPerFloor));
+ uint32_t nRooms = std::ceil (std::sqrt (nEnbPerFloor));
uint32_t nEnb;
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
--- a/src/lte/examples/lena-rem-sector-antenna.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/lte/examples/lena-rem-sector-antenna.cc Sat Sep 01 20:57:21 2012 +0200
@@ -146,11 +146,11 @@
}
else if ( i == nEnb - 2 )
{
- positionAlloc->Add (Vector (enbPosition.at(i).x - sqrt (10), enbPosition.at(i).y + sqrt (10), nodeHeight));
+ positionAlloc->Add (Vector (enbPosition.at(i).x - std::sqrt (10), enbPosition.at(i).y + std::sqrt (10), nodeHeight));
}
else if ( i == nEnb - 1 )
{
- positionAlloc->Add (Vector (enbPosition.at(i).x - sqrt (10), enbPosition.at(i).y - sqrt (10), nodeHeight));
+ positionAlloc->Add (Vector (enbPosition.at(i).x - std::sqrt (10), enbPosition.at(i).y - std::sqrt (10), nodeHeight));
}
else
{
--- a/src/lte/helper/lte-hex-grid-enb-topology-helper.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/lte/helper/lte-hex-grid-enb-topology-helper.cc Sat Sep 01 20:57:21 2012 +0200
@@ -103,7 +103,7 @@
{
NS_LOG_FUNCTION (this);
NetDeviceContainer enbDevs;
- const double xydfactor = sqrt (0.75);
+ const double xydfactor = std::sqrt (0.75);
double yd = xydfactor*m_d;
for (uint32_t n = 0; n < c.GetN (); ++n)
{
--- a/src/lte/model/lte-amc.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/lte/model/lte-amc.cc Sat Sep 01 20:57:21 2012 +0200
@@ -24,16 +24,13 @@
#include <ns3/lte-amc.h>
#include <ns3/log.h>
#include <ns3/assert.h>
-#include <math.h>
+#include <ns3/math.h>
#include <vector>
#include <ns3/spectrum-value.h>
#include <ns3/double.h>
#include "ns3/enum.h"
#include <ns3/lte-mi-error-model.h>
-#ifdef __FreeBSD__
-#define log2(x) (log(x)/M_LN2)
-#endif
NS_LOG_COMPONENT_DEFINE ("LteAmc");
@@ -318,14 +315,13 @@
* NB: SINR must be expressed in linear units
*/
- double s = log2 ( 1 + ( sinr_ /
- ( (-log (5.0 * m_ber )) / 1.5) ));
+ double s = log2 ( 1 + ( sinr_ / ( (-std::log (5.0 * m_ber )) / 1.5) ));
int cqi_ = GetCqiFromSpectralEfficiency (s);
NS_LOG_LOGIC (" PRB =" << cqi.size ()
<< ", sinr = " << sinr_
- << " (=" << 10 * log10 (sinr_) << " dB)"
+ << " (=" << 10 * std::log10 (sinr_) << " dB)"
<< ", spectral efficiency =" << s
<< ", CQI = " << cqi_ << ", BER = " << m_ber);
--- a/src/lte/model/lte-common.h Fri Aug 31 12:24:28 2012 +0200
+++ b/src/lte/model/lte-common.h Sat Sep 01 20:57:21 2012 +0200
@@ -22,7 +22,7 @@
#define LTE_COMMON_H
#include "ns3/uinteger.h"
-#include <math.h>
+#include <cmath>
// see 36.213 section 8
#define UL_PUSCH_TTIS_DELAY 4
--- a/src/lte/model/lte-enb-phy.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/lte/model/lte-enb-phy.cc Sat Sep 01 20:57:21 2012 +0200
@@ -21,7 +21,7 @@
#include <ns3/object-factory.h>
#include <ns3/log.h>
-#include <math.h>
+#include <cmath>
#include <ns3/simulator.h>
#include <ns3/attribute-accessor-helper.h>
#include <ns3/double.h>
@@ -595,7 +595,7 @@
int i = 0;
for (it = sinr.ConstValuesBegin (); it != sinr.ConstValuesEnd (); it++)
{
- double sinrdb = 10 * log10 ((*it));
+ double sinrdb = 10 * std::log10 ((*it));
// NS_LOG_DEBUG ("ULCQI RB " << i << " value " << sinrdb);
// convert from double to fixed point notation Sxxxxxxxxxxx.xxx
int16_t sinrFp = LteFfConverter::double2fpS11dot3 (sinrdb);
--- a/src/lte/model/lte-mi-error-model.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/lte/model/lte-mi-error-model.cc Sat Sep 01 20:57:21 2012 +0200
@@ -323,7 +323,7 @@
}
}
}
- NS_LOG_LOGIC (" RB " << map.at (i) << "Minimum SNR = " << 10*log10 (sinrLin) << " V, MCS = " << (uint16_t)mcs << ", MI = " << MI);
+ NS_LOG_LOGIC (" RB " << map.at (i) << "Minimum SNR = " << 10 * std::log10 (sinrLin) << " V, MCS = " << (uint16_t)mcs << ", MI = " << MI);
MIsum += MI;
}
MI = MIsum / map.size ();
@@ -477,9 +477,9 @@
if (C!=1)
{
double cbler = MappingMiBler (MI, mcs, Kplus);
- errorRate *= pow (1.0 - cbler, Cplus);
+ errorRate *= std::pow (1.0 - cbler, Cplus);
cbler = MappingMiBler (MI, mcs, Kminus);
- errorRate *= pow (1.0 - cbler, Cminus);
+ errorRate *= std::pow (1.0 - cbler, Cminus);
errorRate = 1.0 - errorRate;
}
else
--- a/src/lte/model/lte-phy.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/lte/model/lte-phy.cc Sat Sep 01 20:57:21 2012 +0200
@@ -22,7 +22,7 @@
#include <ns3/waveform-generator.h>
#include <ns3/object-factory.h>
#include <ns3/log.h>
-#include <math.h>
+#include <cmath>
#include <ns3/simulator.h>
#include "ns3/spectrum-error-model.h"
#include "lte-phy.h"
--- a/src/lte/model/lte-spectrum-phy.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/lte/model/lte-spectrum-phy.cc Sat Sep 01 20:57:21 2012 +0200
@@ -23,7 +23,7 @@
#include <ns3/object-factory.h>
#include <ns3/log.h>
-#include <math.h>
+#include <cmath>
#include <ns3/simulator.h>
#include <ns3/trace-source-accessor.h>
#include <ns3/antenna-model.h>
@@ -907,7 +907,7 @@
{
NS_LOG_FUNCTION (this << " txmode " << (uint16_t)txMode << " gain " << gain);
// convert to linear
- gain = pow (10.0, (gain / 10.0));
+ gain = std::pow (10.0, (gain / 10.0));
if (m_txModeGain.size () < txMode)
{
m_txModeGain.resize (txMode);
--- a/src/lte/model/lte-spectrum-value-helper.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/lte/model/lte-spectrum-value-helper.cc Sat Sep 01 20:57:21 2012 +0200
@@ -237,7 +237,7 @@
Ptr<SpectrumValue> txPsd = Create <SpectrumValue> (model);
// powerTx is expressed in dBm. We must convert it into natural unit.
- double powerTxW = pow (10., (powerTx - 30) / 10);
+ double powerTxW = std::pow (10., (powerTx - 30) / 10);
double txPowerDensity = (powerTxW / (txBandwidthConfiguration * 180000));
@@ -270,8 +270,8 @@
// see "LTE - From theory to practice"
// Section 22.4.4.2 Thermal Noise and Receiver Noise Figure
const double kT_dBm_Hz = -174.0; // dBm/Hz
- double kT_W_Hz = pow (10.0, (kT_dBm_Hz - 30) / 10.0);
- double noiseFigureLinear = pow (10.0, noiseFigureDb / 10.0);
+ double kT_W_Hz = std::pow (10.0, (kT_dBm_Hz - 30) / 10.0);
+ double noiseFigureLinear = std::pow (10.0, noiseFigureDb / 10.0);
double noisePowerSpectralDensity = kT_W_Hz * noiseFigureLinear;
Ptr<SpectrumValue> noisePsd = Create <SpectrumValue> (spectrumModel);
--- a/src/lte/model/lte-ue-phy.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/lte/model/lte-ue-phy.cc Sat Sep 01 20:57:21 2012 +0200
@@ -22,7 +22,7 @@
#include <ns3/object-factory.h>
#include <ns3/log.h>
-#include <math.h>
+#include <cmath>
#include <ns3/simulator.h>
#include <ns3/double.h>
#include "lte-ue-phy.h"
@@ -769,7 +769,7 @@
{
NS_LOG_FUNCTION (this << gain);
// convert to linear
- double gainLin = pow (10.0, (gain / 10.0));
+ double gainLin = std::pow (10.0, (gain / 10.0));
if (m_txModeGain.size () < txMode)
{
m_txModeGain.resize (txMode);
--- a/src/lte/model/pf-ff-mac-scheduler.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/lte/model/pf-ff-mac-scheduler.cc Sat Sep 01 20:57:21 2012 +0200
@@ -18,12 +18,9 @@
* Author: Marco Miozzo <marco.miozzo@cttc.es>
*/
-#ifdef __FreeBSD__
-#define log2(x) (log(x) / M_LN2)
-#endif /* __FreeBSD__ */
-
#include <ns3/log.h>
#include <ns3/pointer.h>
+#include <ns3/math.h>
#include <ns3/simulator.h>
#include <ns3/lte-amc.h>
@@ -909,8 +906,8 @@
// translate SINR -> cqi: WILD ACK: same as DL
double s = log2 ( 1 + (
- pow (10, minSinr / 10 ) /
- ( (-log (5.0 * 0.00005 )) / 1.5) ));
+ std::pow (10, minSinr / 10 ) /
+ ( (-std::log (5.0 * 0.00005 )) / 1.5) ));
cqi = m_amc->GetCqiFromSpectralEfficiency (s);
if (cqi == 0)
{
--- a/src/lte/model/rr-ff-mac-scheduler.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/lte/model/rr-ff-mac-scheduler.cc Sat Sep 01 20:57:21 2012 +0200
@@ -18,12 +18,9 @@
* Author: Marco Miozzo <marco.miozzo@cttc.es>
*/
-#ifdef __FreeBSD__
-#define log2(x) (log(x) / M_LN2)
-#endif /* __FreeBSD__ */
-
#include <ns3/log.h>
#include <ns3/pointer.h>
+#include <ns3/math.h>
#include <ns3/lte-amc.h>
#include <ns3/rr-ff-mac-scheduler.h>
@@ -738,8 +735,8 @@
}
// translate SINR -> cqi: WILD ACK: same as DL
double s = log2 ( 1 + (
- pow (10, minSinr / 10 ) /
- ( (-log (5.0 * 0.00005 )) / 1.5) ));
+ std::pow (10, minSinr / 10 ) /
+ ( (-std::log (5.0 * 0.00005 )) / 1.5) ));
cqi = m_amc->GetCqiFromSpectralEfficiency (s);
--- a/src/lte/model/trace-fading-loss-model.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/lte/model/trace-fading-loss-model.cc Sat Sep 01 20:57:21 2012 +0200
@@ -185,7 +185,7 @@
//Vector aSpeedVector = a->GetVelocity ();
//Vector bSpeedVector = b->GetVelocity ();
- //double speed = sqrt (pow (aSpeedVector.x-bSpeedVector.x,2) + pow (aSpeedVector.y-bSpeedVector.y,2));
+ //double speed = std::sqrt (std::pow (aSpeedVector.x-bSpeedVector.x,2) + std::pow (aSpeedVector.y-bSpeedVector.y,2));
NS_LOG_LOGIC (this << *rxPsd);
NS_ASSERT (!m_fadingTrace.empty ());
@@ -201,11 +201,11 @@
double fading = m_fadingTrace.at (subChannel).at (index);
NS_LOG_INFO (this << " FADING now " << now_ms << " offset " << (*itOff).second << " id " << index << " fading " << fading);
double power = *vit; // in Watt/Hz
- power = 10 * log10 (180000 * power); // in dB
+ power = 10 * std::log10 (180000 * power); // in dB
NS_LOG_LOGIC (this << subChannel << *vit << power << fading);
- *vit = pow (10., ((power + fading) / 10)) / 180000; // in Watt
+ *vit = std::pow (10., ((power + fading) / 10)) / 180000; // in Watt
NS_LOG_LOGIC (this << subChannel << *vit);
--- a/src/lte/test/lte-test-fading.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/lte/test/lte-test-fading.cc Sat Sep 01 20:57:21 2012 +0200
@@ -291,8 +291,8 @@
(*inPsd1)[1] = 1.;
Ptr<SpectrumValue> outPsd1 = Create<SpectrumValue> (sm);
outPsd1 = m_fadingModule->CalcRxPowerSpectralDensity (inPsd1, m_node1, m_node2);
- (*outPsd1)[0] = (10 * log10 (180000*(*outPsd1)[0])) - (10 * log10 (180000*(*inPsd1)[0]));
- (*outPsd1)[1] = (10 * log10 (180000*(*outPsd1)[1])) - (10 * log10 (180000*(*inPsd1)[1]));
+ (*outPsd1)[0] = (10 * std::log10 (180000*(*outPsd1)[0])) - (10 * std::log10 (180000*(*inPsd1)[0]));
+ (*outPsd1)[1] = (10 * std::log10 (180000*(*outPsd1)[1])) - (10 * std::log10 (180000*(*inPsd1)[1]));
m_fadingSamples.push_back ((*outPsd1));
}
--- a/src/lte/test/lte-test-interference.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/lte/test/lte-test-interference.cc Sat Sep 01 20:57:21 2012 +0200
@@ -98,8 +98,8 @@
: TestCase (name),
m_d1 (d1),
m_d2 (d2),
- m_dlSinrDb (10 * log10 (dlSinr)),
- m_ulSinrDb (10 * log10 (ulSinr)),
+ m_dlSinrDb (10 * std::log10 (dlSinr)),
+ m_ulSinrDb (10 * std::log10 (ulSinr)),
m_dlSe (dlSe),
m_ulSe (ulSe),
m_dlMcs (dlMcs),
@@ -210,16 +210,16 @@
Simulator::Run ();
- double dlSinr1Db = 10.0 * log10 (testDlSinr1->GetSinr ()->operator[] (0));
+ double dlSinr1Db = 10.0 * std::log10 (testDlSinr1->GetSinr ()->operator[] (0));
NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr1Db, m_dlSinrDb, 0.01, "Wrong SINR in DL! (eNB1 --> UE1)");
- double ulSinr1Db = 10.0 * log10 (testUlSinr1->GetSinr ()->operator[] (0));
+ double ulSinr1Db = 10.0 * std::log10 (testUlSinr1->GetSinr ()->operator[] (0));
NS_TEST_ASSERT_MSG_EQ_TOL (ulSinr1Db, m_ulSinrDb, 0.01, "Wrong SINR in UL! (UE1 --> eNB1)");
- double dlSinr2Db = 10.0 * log10 (testDlSinr2->GetSinr ()->operator[] (0));
+ double dlSinr2Db = 10.0 * std::log10 (testDlSinr2->GetSinr ()->operator[] (0));
NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr2Db, m_dlSinrDb, 0.01, "Wrong SINR in DL! (eNB2 --> UE2)");
- double ulSinr2Db = 10.0 * log10 (testUlSinr2->GetSinr ()->operator[] (0));
+ double ulSinr2Db = 10.0 * std::log10 (testUlSinr2->GetSinr ()->operator[] (0));
NS_TEST_ASSERT_MSG_EQ_TOL (ulSinr2Db, m_ulSinrDb, 0.01, "Wrong SINR in UL! (UE2 --> eNB2)");
Simulator::Destroy ();
--- a/src/lte/test/lte-test-link-adaptation.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/lte/test/lte-test-link-adaptation.cc Sat Sep 01 20:57:21 2012 +0200
@@ -113,7 +113,7 @@
double txPowerDbm = 30; // default eNB TX power over whole bandwdith
double ktDbm = -174; // reference LTE noise PSD
- double noisePowerDbm = ktDbm + 10 * log10 (25 * 180000); // corresponds to kT*bandwidth in linear units
+ double noisePowerDbm = ktDbm + 10 * std::log10 (25 * 180000); // corresponds to kT*bandwidth in linear units
double receiverNoiseFigureDb = 9.0; // default UE noise figure
for ( int i = 0 ; i < numOfTests; i++ )
@@ -209,7 +209,7 @@
Simulator::Stop (Seconds (0.007));
Simulator::Run ();
- double calculatedSinrDb = 10.0 * log10 (testSinr->GetSinr ()->operator[] (0));
+ double calculatedSinrDb = 10.0 * std::log10 (testSinr->GetSinr ()->operator[] (0));
NS_TEST_ASSERT_MSG_EQ_TOL (calculatedSinrDb, m_snrDb, 0.0000001, "Wrong SINR !");
Simulator::Destroy ();
}
--- a/src/lte/test/lte-test-pathloss-model.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/lte/test/lte-test-pathloss-model.cc Sat Sep 01 20:57:21 2012 +0200
@@ -139,11 +139,11 @@
double txPowerDbm = 30; // default eNB TX power over whole bandwdith
- double txPowerLin = pow (10, (txPowerDbm - 30)/10);
+ double txPowerLin = std::pow (10, (txPowerDbm - 30)/10);
double ktDbm = -174; // reference LTE noise PSD
- double noisePowerDbm = ktDbm + 10 * log10 (25 * 180000); // corresponds to kT*bandwidth in linear units
+ double noisePowerDbm = ktDbm + 10 * std::log10 (25 * 180000); // corresponds to kT*bandwidth in linear units
double receiverNoiseFigureDb = 9.0; // default UE noise figure
- double noiseLin = pow (10, (noisePowerDbm-30+receiverNoiseFigureDb)/10);
+ double noiseLin = std::pow (10, (noisePowerDbm-30+receiverNoiseFigureDb)/10);
// reference values obtained with the octave script src/lte/test/reference/lte_pathloss.m
@@ -156,7 +156,7 @@
// double lossDb = txPowerDbm - snrEfficiencyMcs[i].snrDb - noisePowerDbm - receiverNoiseFigureDb;
double sinrLin = (txPowerLin/(pow(10, loss[i]/10))) / noiseLin;
// double sinrDb = txPowerDbm- noisePowerDbm - receiverNoiseFigureDb - loss[i];
- double sinrDb = 10*log10(sinrLin);
+ double sinrDb = 10 * std::log10 (sinrLin);
NS_LOG_INFO (" Ptx " << txPowerDbm << " Pn " << noisePowerDbm << " Fn " << receiverNoiseFigureDb << " Pl " << loss[i] << " dist " << dist[i]);
std::ostringstream name;
name << " snr= " << sinrDb << " dB, "
@@ -280,7 +280,7 @@
Simulator::Stop (Seconds (0.005));
Simulator::Run ();
- double calculatedSinrDb = 10.0 * log10 (testSinr->GetSinr ()->operator[] (0));
+ double calculatedSinrDb = 10.0 * std::log10 (testSinr->GetSinr ()->operator[] (0));
NS_LOG_INFO ("Distance " << m_distance << " Calculated SINR " << calculatedSinrDb << " ref " << m_snrDb);
Simulator::Destroy ();
NS_TEST_ASSERT_MSG_EQ_TOL (calculatedSinrDb, m_snrDb, 0.001, "Wrong SINR !");
--- a/src/lte/test/lte-test-phy-error-model.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/lte/test/lte-test-phy-error-model.cc Sat Sep 01 20:57:21 2012 +0200
@@ -260,8 +260,8 @@
double ber = 1.0 - ((double)dlDataRxed.at (i)/txed);
double np = n-n*m_berRef;
NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at (i) << " txed " << txed
- << " BER " << ber << " Err " << fabs (m_berRef - ber) << " lambda " << lambda
- << " np " << np << " difference " << abs(lambda - np) << " quantile " << m_bernQuantile);
+ << " BER " << ber << " Err " << std::fabs (m_berRef - ber) << " lambda " << lambda
+ << " np " << np << " difference " << std::abs (lambda - np) << " quantile " << m_bernQuantile);
NS_UNUSED (ber);
// the quantiles are evaluated offline according to a Bernoulli
// ditribution with n equal to the number of packet sent and p equal
--- a/src/lte/test/test-lte-antenna.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/lte/test/test-lte-antenna.cc Sat Sep 01 20:57:21 2012 +0200
@@ -156,25 +156,25 @@
const double enbTxPowerDbm = 30; // default eNB TX power over whole bandwdith
const double ueTxPowerDbm = 10; // default UE TX power over whole bandwdith
const double ktDbm = -174; // reference LTE noise PSD
- const double noisePowerDbm = ktDbm + 10 * log10 (25 * 180000); // corresponds to kT*bandwidth in linear units
+ const double noisePowerDbm = ktDbm + 10 * std::log10 (25 * 180000); // corresponds to kT*bandwidth in linear units
const double ueNoiseFigureDb = 9.0; // default UE noise figure
const double enbNoiseFigureDb = 5.0; // default eNB noise figure
double calculatedSinrDbDl = -INFINITY;
if (testDlSinr->GetSinr () != 0)
{
- calculatedSinrDbDl = 10.0 * log10 (testDlSinr->GetSinr ()->operator[] (0));
+ calculatedSinrDbDl = 10.0 * std::log10 (testDlSinr->GetSinr ()->operator[] (0));
}
double calculatedSinrDbUl = -INFINITY;
if (testUlSinr->GetSinr () != 0)
{
- calculatedSinrDbUl = 10.0 * log10 (testUlSinr->GetSinr ()->operator[] (0));
+ calculatedSinrDbUl = 10.0 * std::log10 (testUlSinr->GetSinr ()->operator[] (0));
}
// remember that propagation loss is 0dB
double calculatedAntennaGainDbDl = - (enbTxPowerDbm - calculatedSinrDbDl - noisePowerDbm - ueNoiseFigureDb);
double calculatedAntennaGainDbUl = - (ueTxPowerDbm - calculatedSinrDbUl - noisePowerDbm - enbNoiseFigureDb);
- double tolerance = (m_antennaGainDb != 0) ? abs (m_antennaGainDb)*0.001 : 0.001;
+ double tolerance = (m_antennaGainDb != 0) ? std::abs (m_antennaGainDb)*0.001 : 0.001;
NS_TEST_ASSERT_MSG_EQ_TOL (calculatedAntennaGainDbDl, m_antennaGainDb, tolerance, "Wrong DL antenna gain!");
NS_TEST_ASSERT_MSG_EQ_TOL (calculatedAntennaGainDbUl, m_antennaGainDb, tolerance, "Wrong UL antenna gain!");
--- a/src/mobility/helper/ns2-mobility-helper.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/mobility/helper/ns2-mobility-helper.cc Sat Sep 01 20:57:21 2012 +0200
@@ -51,8 +51,6 @@
NS_LOG_COMPONENT_DEFINE ("Ns2MobilityHelper");
-using namespace std;
-
namespace ns3 {
// Constants definitions
@@ -69,12 +67,12 @@
// Type to maintain line parsed and its values
struct ParseResult
{
- vector<string> tokens; // tokens from a line
- vector<int> ivals; // int values for each tokens
- vector<bool> has_ival; // points if a tokens has an int value
- vector<double> dvals; // double values for each tokens
- vector<bool> has_dval; // points if a tokens has a double value
- vector<string> svals; // string value for each token
+ std::vector<std::string> tokens; // tokens from a line
+ std::vector<int> ivals; // int values for each tokens
+ std::vector<bool> has_ival; // points if a tokens has an int value
+ std::vector<double> dvals; // double values for each tokens
+ std::vector<bool> has_dval; // points if a tokens has a double value
+ std::vector<std::string> svals; // string value for each token
};
/**
* \brief Keeps last movement schedule. If new movement occurs during
@@ -102,32 +100,32 @@
// Parses a line of ns2 mobility
-static ParseResult ParseNs2Line (const string& str);
+static ParseResult ParseNs2Line (const std::string& str);
// Put out blank spaces at the start and end of a line
-static string TrimNs2Line (const string& str);
+static std::string TrimNs2Line (const std::string& str);
// Checks if a string represents a number or it has others characters than digits an point.
-static bool IsNumber (const string& s);
+static bool IsNumber (const std::string& s);
// Check if s string represents a numeric value
template<class T>
-static bool IsVal (const string& str, T& ret);
+static bool IsVal (const std::string& str, T& ret);
// Checks if the value between brackets is a correct nodeId number
-static bool HasNodeIdNumber (string str);
+static bool HasNodeIdNumber (std::string str);
// Gets nodeId number in string format from the string like $node_(4)
-static string GetNodeIdFromToken (string str);
+static std::string GetNodeIdFromToken (std::string str);
// Get node id number in int format
static int GetNodeIdInt (ParseResult pr);
// Get node id number in string format
-static string GetNodeIdString (ParseResult pr);
+static std::string GetNodeIdString (ParseResult pr);
// Add one coord to a vector position
-static Vector SetOneInitialCoord (Vector actPos, string& coord, double value);
+static Vector SetOneInitialCoord (Vector actPos, std::string& coord, double value);
// Check if this corresponds to a line like this: $node_(0) set X_ 123
static bool IsSetInitialPos (ParseResult pr);
@@ -143,10 +141,10 @@
double xFinalPosition, double yFinalPosition, double speed);
// Set initial position for a node
-static Vector SetInitialPosition (Ptr<ConstantVelocityMobilityModel> model, string coord, double coordVal);
+static Vector SetInitialPosition (Ptr<ConstantVelocityMobilityModel> model, std::string coord, double coordVal);
// Schedule a set of position for a node
-static Vector SetSchedPosition (Ptr<ConstantVelocityMobilityModel> model, double at, string coord, double coordVal);
+static Vector SetSchedPosition (Ptr<ConstantVelocityMobilityModel> model, double at, std::string coord, double coordVal);
Ns2MobilityHelper::Ns2MobilityHelper (std::string filename)
@@ -181,7 +179,7 @@
void
Ns2MobilityHelper::ConfigNodesMovements (const ObjectStore &store) const
{
- map<int, DestinationPoint> last_pos; // Stores previous movement scheduled for each node
+ std::map<int, DestinationPoint> last_pos; // Stores previous movement scheduled for each node
//*****************************************************************
// Parse the file the first time to get the initial node positions.
@@ -398,15 +396,15 @@
ParseResult
-ParseNs2Line (const string& str)
+ParseNs2Line (const std::string& str)
{
ParseResult ret;
- istringstream s;
- string line;
+ std::istringstream s;
+ std::string line;
// ignore comments (#)
size_t pos_sharp = str.find_first_of ('#');
- if (pos_sharp != string::npos)
+ if (pos_sharp != std::string::npos)
{
line = str.substr (0, pos_sharp);
}
@@ -428,7 +426,7 @@
while (!s.eof ())
{
- string x;
+ std::string x;
s >> x;
if (x.length () == 0)
{
@@ -460,7 +458,7 @@
// removes " from the last position
ret.tokens[tokensLength - 1] = ret.tokens[tokensLength - 1].substr (0,lasTokenLength - 1);
- string x;
+ std::string x;
x = ret.tokens[tokensLength - 1];
if (HasNodeIdNumber (x))
@@ -499,10 +497,10 @@
}
-string
-TrimNs2Line (const string& s)
+std::string
+TrimNs2Line (const std::string& s)
{
- string ret = s;
+ std::string ret = s;
while (ret.size () > 0 && isblank (ret[0]))
{
@@ -519,7 +517,7 @@
bool
-IsNumber (const string& s)
+IsNumber (const std::string& s)
{
char *endp;
double v = strtod (s.c_str (), &endp); // declared with warn_unused_result
@@ -529,7 +527,7 @@
template<class T>
-bool IsVal (const string& str, T& ret)
+bool IsVal (const std::string& str, T& ret)
{
if (str.size () == 0)
{
@@ -537,8 +535,8 @@
}
else if (IsNumber (str))
{
- string s2 = str;
- istringstream s (s2);
+ std::string s2 = str;
+ std::istringstream s (s2);
s >> ret;
return true;
}
@@ -550,7 +548,7 @@
bool
-HasNodeIdNumber (string str)
+HasNodeIdNumber (std::string str)
{
// find brackets
@@ -580,8 +578,8 @@
}
-string
-GetNodeIdFromToken (string str)
+std::string
+GetNodeIdFromToken (std::string str)
{
if (HasNodeIdNumber (str))
{
@@ -620,7 +618,7 @@
}
// Get node id number in string format
-string
+std::string
GetNodeIdString (ParseResult pr)
{
switch (pr.tokens.size ())
@@ -641,7 +639,7 @@
Vector
-SetOneInitialCoord (Vector position, string& coord, double value)
+SetOneInitialCoord (Vector position, std::string& coord, double value)
{
// set the position for the coord.
@@ -716,7 +714,7 @@
if (speed > 0)
{
// first calculate the time; time = distance / speed
- double time = sqrt (pow (xFinalPosition - retval.m_finalPosition.x, 2) + pow (yFinalPosition - retval.m_finalPosition.y, 2)) / speed;
+ double time = std::sqrt (std::pow (xFinalPosition - retval.m_finalPosition.x, 2) + std::pow (yFinalPosition - retval.m_finalPosition.y, 2)) / speed;
NS_LOG_DEBUG ("at=" << at << " time=" << time);
if (time == 0)
{
@@ -744,7 +742,7 @@
Vector
-SetInitialPosition (Ptr<ConstantVelocityMobilityModel> model, string coord, double coordVal)
+SetInitialPosition (Ptr<ConstantVelocityMobilityModel> model, std::string coord, double coordVal)
{
model->SetPosition (SetOneInitialCoord (model->GetPosition (), coord, coordVal));
@@ -758,7 +756,7 @@
// Schedule a set of position for a node
Vector
-SetSchedPosition (Ptr<ConstantVelocityMobilityModel> model, double at, string coord, double coordVal)
+SetSchedPosition (Ptr<ConstantVelocityMobilityModel> model, double at, std::string coord, double coordVal)
{
// update position
model->SetPosition (SetOneInitialCoord (model->GetPosition (), coord, coordVal));
--- a/src/mobility/model/mobility-model.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/mobility/model/mobility-model.cc Sat Sep 01 20:57:21 2012 +0200
@@ -18,7 +18,7 @@
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
-#include <math.h>
+#include <cmath>
#include "mobility-model.h"
#include "ns3/trace-source-accessor.h"
--- a/src/mobility/model/position-allocator.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/mobility/model/position-allocator.cc Sat Sep 01 20:57:21 2012 +0200
@@ -478,7 +478,7 @@
x = m_rv->GetValue (-m_rho, m_rho);
y = m_rv->GetValue (-m_rho, m_rho);
}
- while (sqrt (x*x + y*y) > m_rho);
+ while (std::sqrt (x*x + y*y) > m_rho);
x += m_x;
y += m_y;
--- a/src/mobility/model/steady-state-random-waypoint-mobility-model.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/mobility/model/steady-state-random-waypoint-mobility-model.cc Sat Sep 01 20:57:21 2012 +0200
@@ -162,7 +162,7 @@
{
// there is an error in equation 20 in the Tech. Report MCS-03-04
// this error is corrected in the TMC 2004 paper and below
- pause = Seconds (m_maxPause - sqrt ((1 - u)*(m_maxPause*m_maxPause - m_minPause*m_minPause)));
+ pause = Seconds (m_maxPause - std::sqrt ((1 - u)*(m_maxPause*m_maxPause - m_minPause*m_minPause)));
}
}
else // if pause is constant
--- a/src/mobility/test/steady-state-random-waypoint-mobility-model-test.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/mobility/test/steady-state-random-waypoint-mobility-model-test.cc Sat Sep 01 20:57:21 2012 +0200
@@ -100,7 +100,7 @@
for (i = mobilityStack.begin (); i != mobilityStack.end (); ++i)
{
model = (*i);
- velocity = sqrt (pow (model->GetVelocity ().x, 2) + pow (model->GetVelocity ().y, 2));
+ velocity = std::sqrt (std::pow (model->GetVelocity ().x, 2) + std::pow (model->GetVelocity ().y, 2));
sum_x += model->GetPosition ().x;
sum_y += model->GetPosition ().y;
sum_v += velocity;
@@ -120,7 +120,7 @@
for (i = mobilityStack.begin (); i != mobilityStack.end (); ++i)
{
model = (*i);
- velocity = sqrt (pow (model->GetVelocity ().x, 2) + pow (model->GetVelocity ().y, 2));
+ velocity = std::sqrt (std::pow (model->GetVelocity ().x, 2) + std::pow (model->GetVelocity ().y, 2));
tmp = model->GetPosition ().x - mean_x;
sum_x += tmp * tmp;
tmp = model->GetPosition ().y - mean_y;
--- a/src/mpi/examples/nms-p2p-nix-distributed.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/mpi/examples/nms-p2p-nix-distributed.cc Sat Sep 01 20:57:21 2012 +0200
@@ -53,7 +53,6 @@
#include <mpi.h>
#endif
-using namespace std;
using namespace ns3;
typedef struct timeval TIMER_TYPE;
--- a/src/mpi/model/distributed-simulator-impl.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/mpi/model/distributed-simulator-impl.cc Sat Sep 01 20:57:21 2012 +0200
@@ -29,7 +29,7 @@
#include "ns3/assert.h"
#include "ns3/log.h"
-#include <math.h>
+#include <cmath>
#ifdef NS3_MPI
#include <mpi.h>
--- a/src/netanim/examples/uan-animation.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/netanim/examples/uan-animation.cc Sat Sep 01 20:57:21 2012 +0200
@@ -160,7 +160,7 @@
{
double x = urv->GetValue ();
double y = urv->GetValue ();
- double newr = sqrt ((x - m_boundary / 2.0) * (x - m_boundary / 2.0)
+ double newr = std::sqrt ((x - m_boundary / 2.0) * (x - m_boundary / 2.0)
+ (y - m_boundary / 2.0) * (y - m_boundary / 2.0));
rsum += newr;
minr = std::min (minr, newr);
--- a/src/netanim/model/animation-interface.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/netanim/model/animation-interface.cc Sat Sep 01 20:57:21 2012 +0200
@@ -40,7 +40,7 @@
#include "ns3/uan-mac.h"
#include "ns3/ipv4.h"
-#include <stdio.h>
+#include <cstdio>
#include <unistd.h>
#include <sstream>
#include <fstream>
@@ -125,7 +125,7 @@
return true;
}
NS_LOG_INFO ("Creating new trace file:" << fn.c_str ());
- m_f = fopen (fn.c_str (), "w");
+ m_f = std::fopen (fn.c_str (), "w");
if (!m_f)
{
NS_FATAL_ERROR ("Unable to open Animation output file");
@@ -607,7 +607,7 @@
{ // Terminate the anim element
WriteN (GetXMLClose ("anim"));
}
- fclose (m_f);
+ std::fclose (m_f);
}
m_outputFileSet = false;
}
@@ -692,7 +692,7 @@
uint32_t written = 0;
while (nLeft)
{
- int n = fwrite (p, 1, nLeft, m_f);
+ int n = std::fwrite (p, 1, nLeft, m_f);
if (n <= 0)
{
return written;
--- a/src/netanim/model/animation-interface.h Fri Aug 31 12:24:28 2012 +0200
+++ b/src/netanim/model/animation-interface.h Sat Sep 01 20:57:21 2012 +0200
@@ -22,7 +22,7 @@
#define ANIMATION_INTERFACE__H
#include <string>
-#include <stdio.h>
+#include <cstdio>
#include <map>
#include "ns3/ptr.h"
#include "ns3/net-device.h"
--- a/src/network/examples/droptail_vs_red.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/network/examples/droptail_vs_red.cc Sat Sep 01 20:57:21 2012 +0200
@@ -30,7 +30,6 @@
#include <map>
using namespace ns3;
-using namespace std;
int main (int argc, char *argv[])
--- a/src/network/model/address.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/network/model/address.cc Sat Sep 01 20:57:21 2012 +0200
@@ -20,7 +20,7 @@
#include "ns3/assert.h"
#include "address.h"
-#include <string.h>
+#include <cstring>
#include <iostream>
#include <iomanip>
@@ -38,14 +38,14 @@
m_len (len)
{
NS_ASSERT (m_len <= MAX_SIZE);
- memcpy (m_data, buffer, m_len);
+ std::memcpy (m_data, buffer, m_len);
}
Address::Address (const Address & address)
: m_type (address.m_type),
m_len (address.m_len)
{
NS_ASSERT (m_len <= MAX_SIZE);
- memcpy (m_data, address.m_data, m_len);
+ std::memcpy (m_data, address.m_data, m_len);
}
Address &
Address::operator = (const Address &address)
@@ -54,7 +54,7 @@
m_type = address.m_type;
m_len = address.m_len;
NS_ASSERT (m_len <= MAX_SIZE);
- memcpy (m_data, address.m_data, m_len);
+ std::memcpy (m_data, address.m_data, m_len);
return *this;
}
@@ -74,7 +74,7 @@
Address::CopyTo (uint8_t buffer[MAX_SIZE]) const
{
NS_ASSERT (m_len <= MAX_SIZE);
- memcpy (buffer, m_data, m_len);
+ std::memcpy (buffer, m_data, m_len);
return m_len;
}
uint32_t
@@ -83,7 +83,7 @@
NS_ASSERT (len >= m_len + 2);
buffer[0] = m_type;
buffer[1] = m_len;
- memcpy (buffer + 2, m_data, m_len);
+ std::memcpy (buffer + 2, m_data, m_len);
return m_len + 2;
}
@@ -91,7 +91,7 @@
Address::CopyFrom (const uint8_t *buffer, uint8_t len)
{
NS_ASSERT (len <= MAX_SIZE);
- memcpy (m_data, buffer, len);
+ std::memcpy (m_data, buffer, len);
m_len = len;
return m_len;
}
@@ -103,7 +103,7 @@
m_len = buffer[1];
NS_ASSERT (len >= m_len + 2);
- memcpy (m_data, buffer + 2, m_len);
+ std::memcpy (m_data, buffer + 2, m_len);
return m_len + 2;
}
bool
@@ -173,7 +173,7 @@
{
return false;
}
- return memcmp (a.m_data, b.m_data, a.m_len) == 0;
+ return std::memcmp (a.m_data, b.m_data, a.m_len) == 0;
}
bool operator != (const Address &a, const Address &b)
{
--- a/src/network/model/application.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/network/model/application.cc Sat Sep 01 20:57:21 2012 +0200
@@ -26,8 +26,6 @@
#include "ns3/nstime.h"
#include "ns3/simulator.h"
-using namespace std;
-
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (Application);
--- a/src/network/model/buffer.h Fri Aug 31 12:24:28 2012 +0200
+++ b/src/network/model/buffer.h Sat Sep 01 20:57:21 2012 +0200
@@ -628,7 +628,7 @@
} // namespace ns3
#include "ns3/assert.h"
-#include <string.h>
+#include <cstring>
namespace ns3 {
@@ -711,13 +711,13 @@
GetWriteErrorMessage ());
if (m_current <= m_zeroStart)
{
- memset (&(m_data[m_current]), data, len);
+ std::memset (&(m_data[m_current]), data, len);
m_current += len;
}
else
{
uint8_t *buffer = &m_data[m_current - (m_zeroEnd-m_zeroStart)];
- memset (buffer, data, len);
+ std::memset (buffer, data, len);
m_current += len;
}
}
--- a/src/network/model/byte-tag-list.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/network/model/byte-tag-list.cc Sat Sep 01 20:57:21 2012 +0200
@@ -20,7 +20,7 @@
#include "byte-tag-list.h"
#include "ns3/log.h"
#include <vector>
-#include <string.h>
+#include <cstring>
NS_LOG_COMPONENT_DEFINE ("ByteTagList");
@@ -173,7 +173,7 @@
(m_data->count != 1 && m_data->dirty != m_used))
{
struct ByteTagListData *newData = Allocate (spaceNeeded);
- memcpy (&newData->data, &m_data->data, m_used);
+ std::memcpy (&newData->data, &m_data->data, m_used);
Deallocate (m_data);
m_data = newData;
}
--- a/src/network/model/packet-tag-list.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/network/model/packet-tag-list.cc Sat Sep 01 20:57:21 2012 +0200
@@ -22,7 +22,7 @@
#include "tag.h"
#include "ns3/fatal-error.h"
#include "ns3/log.h"
-#include <string.h>
+#include <cstring>
NS_LOG_COMPONENT_DEFINE ("PacketTagList");
@@ -119,7 +119,7 @@
copy->tid = cur->tid;
copy->count = 1;
copy->next = 0;
- memcpy (copy->data, cur->data, PACKET_TAG_MAX_SIZE);
+ std::memcpy (copy->data, cur->data, PACKET_TAG_MAX_SIZE);
*prevNext = copy;
prevNext = ©->next;
}
--- a/src/network/model/packet.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/network/model/packet.cc Sat Sep 01 20:57:21 2012 +0200
@@ -22,7 +22,7 @@
#include "ns3/log.h"
#include "ns3/simulator.h"
#include <string>
-#include <stdarg.h>
+#include <cstdarg>
NS_LOG_COMPONENT_DEFINE ("Packet");
--- a/src/network/model/tag-buffer.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/network/model/tag-buffer.cc Sat Sep 01 20:57:21 2012 +0200
@@ -19,7 +19,7 @@
*/
#include "tag-buffer.h"
#include "ns3/assert.h"
-#include <string.h>
+#include <cstring>
namespace ns3 {
@@ -186,7 +186,7 @@
NS_ASSERT (m_end >= m_current);
uintptr_t size = o.m_end - o.m_current;
NS_ASSERT (size <= (uintptr_t)(m_end - m_current));
- memcpy (m_current, o.m_current, size);
+ std::memcpy (m_current, o.m_current, size);
m_current += size;
}
--- a/src/network/test/packet-metadata-test.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/network/test/packet-metadata-test.cc Sat Sep 01 20:57:21 2012 +0200
@@ -17,7 +17,7 @@
*
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
-#include <stdarg.h>
+#include <cstdarg>
#include <iostream>
#include <sstream>
#include "ns3/test.h"
--- a/src/network/test/packet-test-suite.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/network/test/packet-test-suite.cc Sat Sep 01 20:57:21 2012 +0200
@@ -20,7 +20,7 @@
#include "ns3/packet.h"
#include "ns3/test.h"
#include <string>
-#include <stdarg.h>
+#include <cstdarg>
namespace ns3 {
--- a/src/network/test/pcap-file-test-suite.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/network/test/pcap-file-test-suite.cc Sat Sep 01 20:57:21 2012 +0200
@@ -17,8 +17,8 @@
*/
#include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
+#include <cstdio>
+#include <cstdlib>
#include <sstream>
#include <cstring>
@@ -46,13 +46,13 @@
static bool
CheckFileExists (std::string filename)
{
- FILE * p = fopen (filename.c_str (), "rb");
+ FILE * p = std::fopen (filename.c_str (), "rb");
if (p == 0)
{
return false;
}
- fclose (p);
+ std::fclose (p);
return true;
}
@@ -60,16 +60,16 @@
static bool
CheckFileLength (std::string filename, uint64_t sizeExpected)
{
- FILE * p = fopen (filename.c_str (), "rb");
+ FILE * p = std::fopen (filename.c_str (), "rb");
if (p == 0)
{
return false;
}
- fseek (p, 0, SEEK_END);
+ std::fseek (p, 0, SEEK_END);
- uint64_t sizeActual = ftell (p);
- fclose (p);
+ uint64_t sizeActual = std::ftell (p);
+ std::fclose (p);
return sizeActual == sizeExpected;
}
@@ -463,7 +463,7 @@
//
// Take a look and see what was done to the file
//
- FILE *p = fopen (m_testFilename.c_str (), "r+b");
+ FILE *p = std::fopen (m_testFilename.c_str (), "r+b");
NS_TEST_ASSERT_MSG_NE (p, 0, "fopen(" << m_testFilename << ") should have been able to open a correctly created pcap file");
uint32_t val32;
@@ -494,42 +494,42 @@
u.a = 1;
bool bigEndian = u.b[3];
- size_t result = fread (&val32, sizeof(val32), 1, p);
+ size_t result = std::fread (&val32, sizeof(val32), 1, p);
NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() magic number");
if (bigEndian) val32 = Swap (val32);
NS_TEST_ASSERT_MSG_EQ (val32, 0xa1b2c3d4, "Magic number written incorrectly");
- result = fread (&val16, sizeof(val16), 1, p);
+ result = std::fread (&val16, sizeof(val16), 1, p);
NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() version major");
if (bigEndian) val16 = Swap (val16);
NS_TEST_ASSERT_MSG_EQ (val16, 2, "Version major written incorrectly");
- result = fread (&val16, sizeof(val16), 1, p);
+ result = std::fread (&val16, sizeof(val16), 1, p);
NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() version minor");
if (bigEndian) val16 = Swap (val16);
NS_TEST_ASSERT_MSG_EQ (val16, 4, "Version minor written incorrectly");
- result = fread (&val32, sizeof(val32), 1, p);
+ result = std::fread (&val32, sizeof(val32), 1, p);
NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() time zone correction");
if (bigEndian) val32 = Swap (val32);
NS_TEST_ASSERT_MSG_EQ (val32, 7, "Version minor written incorrectly");
- result = fread (&val32, sizeof(val32), 1, p);
+ result = std::fread (&val32, sizeof(val32), 1, p);
NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() sig figs");
if (bigEndian) val32 = Swap (val32);
NS_TEST_ASSERT_MSG_EQ (val32, 0, "Sig figs written incorrectly");
- result = fread (&val32, sizeof(val32), 1, p);
+ result = std::fread (&val32, sizeof(val32), 1, p);
NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() snap length");
if (bigEndian) val32 = Swap (val32);
NS_TEST_ASSERT_MSG_EQ (val32, 5678, "Snap length written incorrectly");
- result = fread (&val32, sizeof(val32), 1, p);
+ result = std::fread (&val32, sizeof(val32), 1, p);
NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() data link type");
if (bigEndian) val32 = Swap (val32);
NS_TEST_ASSERT_MSG_EQ (val32, 1234, "Data length type written incorrectly");
- fclose (p);
+ std::fclose (p);
p = 0;
//
@@ -577,38 +577,38 @@
// Take a look and see what was done to the file. Everything should now
// appear byte-swapped.
//
- p = fopen (m_testFilename.c_str (), "r+b");
+ p = std::fopen (m_testFilename.c_str (), "r+b");
NS_TEST_ASSERT_MSG_NE (p, 0, "fopen(" << m_testFilename << ") should have been able to open a correctly created pcap file");
- result = fread (&val32, sizeof(val32), 1, p);
+ result = std::fread (&val32, sizeof(val32), 1, p);
NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() magic number");
NS_TEST_ASSERT_MSG_EQ (val32, Swap (uint32_t (0xa1b2c3d4)), "Magic number written incorrectly");
- result = fread (&val16, sizeof(val16), 1, p);
+ result = std::fread (&val16, sizeof(val16), 1, p);
NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() version major");
NS_TEST_ASSERT_MSG_EQ (val16, Swap (uint16_t (2)), "Version major written incorrectly");
- result = fread (&val16, sizeof(val16), 1, p);
+ result = std::fread (&val16, sizeof(val16), 1, p);
NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() version minor");
NS_TEST_ASSERT_MSG_EQ (val16, Swap (uint16_t (4)), "Version minor written incorrectly");
- result = fread (&val32, sizeof(val32), 1, p);
+ result = std::fread (&val32, sizeof(val32), 1, p);
NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() time zone correction");
NS_TEST_ASSERT_MSG_EQ (val32, Swap (uint32_t (7)), "Version minor written incorrectly");
- result = fread (&val32, sizeof(val32), 1, p);
+ result = std::fread (&val32, sizeof(val32), 1, p);
NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() sig figs");
NS_TEST_ASSERT_MSG_EQ (val32, 0, "Sig figs written incorrectly");
- result = fread (&val32, sizeof(val32), 1, p);
+ result = std::fread (&val32, sizeof(val32), 1, p);
NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() snap length");
NS_TEST_ASSERT_MSG_EQ (val32, Swap (uint32_t (5678)), "Snap length written incorrectly");
- result = fread (&val32, sizeof(val32), 1, p);
+ result = std::fread (&val32, sizeof(val32), 1, p);
NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() data link type");
NS_TEST_ASSERT_MSG_EQ (val32, Swap (uint32_t (1234)), "Data length type written incorrectly");
- fclose (p);
+ std::fclose (p);
p = 0;
//
@@ -717,7 +717,7 @@
// Let's peek into the file and see what actually went out for that
// packet.
//
- FILE *p = fopen (m_testFilename.c_str (), "r+b");
+ FILE *p = std::fopen (m_testFilename.c_str (), "r+b");
NS_TEST_ASSERT_MSG_NE (p, 0, "fopen() should have been able to open a correctly created pcap file");
//
@@ -725,8 +725,8 @@
// and we wrote in 43 bytes, so the file must be 83 bytes long. Let's just
// double check that this is exactly what happened.
//
- fseek (p, 0, SEEK_END);
- uint64_t size = ftell (p);
+ std::fseek (p, 0, SEEK_END);
+ uint64_t size = std::ftell (p);
NS_TEST_ASSERT_MSG_EQ (size, 83, "Pcap file with one 43 byte packet is incorrect size");
//
@@ -734,7 +734,7 @@
// starting there in the file. We've tested this all before so we just assume
// it's all right and just seek to just past that point..
//
- fseek (p, 24, SEEK_SET);
+ std::fseek (p, 24, SEEK_SET);
uint32_t val32;
@@ -763,22 +763,22 @@
u.a = 1;
bool bigEndian = u.b[3];
- size_t result = fread (&val32, sizeof(val32), 1, p);
+ size_t result = std::fread (&val32, sizeof(val32), 1, p);
NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() seconds timestamp");
if (bigEndian) val32 = Swap (val32);
NS_TEST_ASSERT_MSG_EQ (val32, 1234, "Seconds timestamp written incorrectly");
- result = fread (&val32, sizeof(val32), 1, p);
+ result = std::fread (&val32, sizeof(val32), 1, p);
NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() microseconds timestamp");
if (bigEndian) val32 = Swap (val32);
NS_TEST_ASSERT_MSG_EQ (val32, 5678, "Microseconds timestamp written incorrectly");
- result = fread (&val32, sizeof(val32), 1, p);
+ result = std::fread (&val32, sizeof(val32), 1, p);
NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() included length");
if (bigEndian) val32 = Swap (val32);
NS_TEST_ASSERT_MSG_EQ (val32, 43, "Included length written incorrectly");
- result = fread (&val32, sizeof(val32), 1, p);
+ result = std::fread (&val32, sizeof(val32), 1, p);
NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() actual length");
if (bigEndian) val32 = Swap (val32);
NS_TEST_ASSERT_MSG_EQ (val32, 128, "Actual length written incorrectly");
@@ -789,7 +789,7 @@
//
uint8_t bufferIn[128];
- result = fread (bufferIn, 1, 43, p);
+ result = std::fread (bufferIn, 1, 43, p);
NS_TEST_ASSERT_MSG_EQ (result, 43, "Unable to fread() packet data of expected length");
for (uint32_t i = 0; i < 43; ++i)
@@ -797,7 +797,7 @@
NS_TEST_ASSERT_MSG_EQ (bufferIn[i], bufferOut[i], "Incorrect packet data written");
}
- fclose (p);
+ std::fclose (p);
p = 0;
//
@@ -859,7 +859,7 @@
// Let's peek into the file and see what actually went out for that
// packet.
//
- p = fopen (m_testFilename.c_str (), "r+b");
+ p = std::fopen (m_testFilename.c_str (), "r+b");
NS_TEST_ASSERT_MSG_NE (p, 0, "fopen() should have been able to open a correctly created pcap file");
//
@@ -867,8 +867,8 @@
// and we wrote in 43 bytes, so the file must be 83 bytes long. Let's just
// double check that this is exactly what happened.
//
- fseek (p, 0, SEEK_END);
- size = ftell (p);
+ std::fseek (p, 0, SEEK_END);
+ size = std::ftell (p);
NS_TEST_ASSERT_MSG_EQ (size, 83, "Pcap file with one 43 byte packet is incorrect size");
//
@@ -876,21 +876,21 @@
// starting there in the file. We've tested this all before so we just assume
// it's all right and just seek past it.
//
- fseek (p, 24, SEEK_SET);
+ std::fseek (p, 24, SEEK_SET);
- result = fread (&val32, sizeof(val32), 1, p);
+ result = std::fread (&val32, sizeof(val32), 1, p);
NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() seconds timestamp");
NS_TEST_ASSERT_MSG_EQ (val32, Swap (uint32_t (1234)), "Swapped seconds timestamp written incorrectly");
- result = fread (&val32, sizeof(val32), 1, p);
+ result = std::fread (&val32, sizeof(val32), 1, p);
NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() microseconds timestamp");
NS_TEST_ASSERT_MSG_EQ (val32, Swap (uint32_t (5678)), "Swapped microseconds timestamp written incorrectly");
- result = fread (&val32, sizeof(val32), 1, p);
+ result = std::fread (&val32, sizeof(val32), 1, p);
NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() included length");
NS_TEST_ASSERT_MSG_EQ (val32, Swap (uint32_t (43)), "Swapped included length written incorrectly");
- result = fread (&val32, sizeof(val32), 1, p);
+ result = std::fread (&val32, sizeof(val32), 1, p);
NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() actual length");
NS_TEST_ASSERT_MSG_EQ (val32, Swap (uint32_t (128)), "Swapped Actual length written incorrectly");
@@ -898,7 +898,7 @@
// Take a look and see what went out into the file. The packet data
// should be unchanged (unswapped).
//
- result = fread (bufferIn, 1, 43, p);
+ result = std::fread (bufferIn, 1, 43, p);
NS_TEST_ASSERT_MSG_EQ (result, 43, "Unable to fread() packet data of expected length");
for (uint32_t i = 0; i < 43; ++i)
@@ -906,7 +906,7 @@
NS_TEST_ASSERT_MSG_EQ (bufferIn[i], bufferOut[i], "Incorrect packet data written");
}
- fclose (p);
+ std::fclose (p);
p = 0;
//
--- a/src/network/utils/error-model.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/network/utils/error-model.cc Sat Sep 01 20:57:21 2012 +0200
@@ -52,7 +52,7 @@
* This code has been ported from ns-2 (queue/errmodel.{cc,h}
*/
-#include <math.h>
+#include <cmath>
#include "error-model.h"
@@ -250,7 +250,7 @@
{
NS_LOG_FUNCTION_NOARGS ();
// compute pkt error rate, assume uniformly distributed byte error
- double per = 1 - pow (1.0 - m_rate, p->GetSize ());
+ double per = 1 - std::pow (1.0 - m_rate, p->GetSize ());
return (m_ranvar->GetValue () < per);
}
@@ -259,7 +259,7 @@
{
NS_LOG_FUNCTION_NOARGS ();
// compute pkt error rate, assume uniformly distributed bit error
- double per = 1 - pow (1.0 - m_rate, (8 * p->GetSize ()) );
+ double per = 1 - std::pow (1.0 - m_rate, (8 * p->GetSize ()) );
return (m_ranvar->GetValue () < per);
}
--- a/src/network/utils/ipv4-address.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/network/utils/ipv4-address.cc Sat Sep 01 20:57:21 2012 +0200
@@ -18,7 +18,7 @@
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
-#include <stdlib.h>
+#include <cstdlib>
#include "ns3/log.h"
#include "ipv4-address.h"
#include "ns3/assert.h"
@@ -74,7 +74,7 @@
{
if (*mask == ASCII_SLASH)
{
- uint32_t plen = static_cast<uint32_t> (atoi (++mask));
+ uint32_t plen = static_cast<uint32_t> (std::atoi (++mask));
NS_ASSERT (plen <= 32);
if (plen > 0)
{
--- a/src/network/utils/ipv6-address.h Fri Aug 31 12:24:28 2012 +0200
+++ b/src/network/utils/ipv6-address.h Sat Sep 01 20:57:21 2012 +0200
@@ -22,7 +22,7 @@
#define IPV6_ADDRESS_H
#include <stdint.h>
-#include <string.h>
+#include <cstring>
#include <ostream>
@@ -446,17 +446,17 @@
inline bool operator == (const Ipv6Address& a, const Ipv6Address& b)
{
- return (!memcmp (a.m_address, b.m_address, 16));
+ return (!std::memcmp (a.m_address, b.m_address, 16));
}
inline bool operator != (const Ipv6Address& a, const Ipv6Address& b)
{
- return memcmp (a.m_address, b.m_address, 16);
+ return std::memcmp (a.m_address, b.m_address, 16);
}
inline bool operator < (const Ipv6Address& a, const Ipv6Address& b)
{
- return (memcmp (a.m_address, b.m_address, 16) < 0);
+ return (std::memcmp (a.m_address, b.m_address, 16) < 0);
}
/**
--- a/src/network/utils/mac48-address.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/network/utils/mac48-address.cc Sat Sep 01 20:57:21 2012 +0200
@@ -22,7 +22,7 @@
#include "ns3/assert.h"
#include <iomanip>
#include <iostream>
-#include <string.h>
+#include <cstring>
namespace ns3 {
@@ -50,7 +50,7 @@
Mac48Address::Mac48Address ()
{
- memset (m_address, 0, 6);
+ std::memset (m_address, 0, 6);
}
Mac48Address::Mac48Address (const char *str)
{
@@ -85,12 +85,12 @@
void
Mac48Address::CopyFrom (const uint8_t buffer[6])
{
- memcpy (m_address, buffer, 6);
+ std::memcpy (m_address, buffer, 6);
}
void
Mac48Address::CopyTo (uint8_t buffer[6]) const
{
- memcpy (buffer, m_address, 6);
+ std::memcpy (buffer, m_address, 6);
}
bool
--- a/src/network/utils/mac64-address.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/network/utils/mac64-address.cc Sat Sep 01 20:57:21 2012 +0200
@@ -22,7 +22,7 @@
#include "ns3/assert.h"
#include <iomanip>
#include <iostream>
-#include <string.h>
+#include <cstring>
namespace ns3 {
@@ -48,7 +48,7 @@
Mac64Address::Mac64Address ()
{
- memset (m_address, 0, 8);
+ std::memset (m_address, 0, 8);
}
Mac64Address::Mac64Address (const char *str)
{
@@ -83,12 +83,12 @@
void
Mac64Address::CopyFrom (const uint8_t buffer[8])
{
- memcpy (m_address, buffer, 8);
+ std::memcpy (m_address, buffer, 8);
}
void
Mac64Address::CopyTo (uint8_t buffer[8]) const
{
- memcpy (buffer, m_address, 8);
+ std::memcpy (buffer, m_address, 8);
}
bool
@@ -143,7 +143,7 @@
uint8_t adb[8];
a.CopyTo (ada);
b.CopyTo (adb);
- return memcmp (ada, adb, 8) == 0;
+ return std::memcmp (ada, adb, 8) == 0;
}
bool operator != (const Mac64Address &a, const Mac64Address &b)
{
--- a/src/network/utils/pcap-file-wrapper.h Fri Aug 31 12:24:28 2012 +0200
+++ b/src/network/utils/pcap-file-wrapper.h Sat Sep 01 20:57:21 2012 +0200
@@ -19,7 +19,7 @@
#ifndef PCAP_FILE_WRAPPER_H
#define PCAP_FILE_WRAPPER_H
-#include <string.h>
+#include <cstring>
#include <limits>
#include <fstream>
#include "ns3/ptr.h"
--- a/src/network/utils/radiotap-header.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/network/utils/radiotap-header.cc Sat Sep 01 20:57:21 2012 +0200
@@ -19,7 +19,7 @@
*/
#include <iomanip>
-#include <math.h>
+#include <cmath>
#include "ns3/log.h"
#include "radiotap-header.h"
--- a/src/network/utils/red-queue.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/network/utils/red-queue.cc Sat Sep 01 20:57:21 2012 +0200
@@ -385,7 +385,7 @@
*/
if (m_qW == 0.0)
{
- m_qW = 1.0 - exp (-1.0 / m_ptc);
+ m_qW = 1.0 - std::exp (-1.0 / m_ptc);
}
else if (m_qW == -1.0)
{
@@ -395,11 +395,11 @@
{
rtt = 0.1;
}
- m_qW = 1.0 - exp (-1.0 / (10 * rtt * m_ptc));
+ m_qW = 1.0 - std::exp (-1.0 / (10 * rtt * m_ptc));
}
else if (m_qW == -2.0)
{
- m_qW = 1.0 - exp (-10.0 / m_ptc);
+ m_qW = 1.0 - std::exp (-10.0 / m_ptc);
}
// TODO: implement adaptive RED
@@ -450,7 +450,7 @@
* pkts: the number of packets arriving in 50 ms
*/
double pkts = m_ptc * 0.05;
- double fraction = pow ((1 - m_qW), pkts);
+ double fraction = std::pow ((1 - m_qW), pkts);
if ((double) qSize < fraction * m_qAvg)
{
@@ -470,7 +470,7 @@
* pkts: the number of packets arriving in 50 ms
*/
double pkts = m_ptc * 0.05;
- double fraction = pow ((1 - m_qW), pkts);
+ double fraction = std::pow ((1 - m_qW), pkts);
double ratio = qSize / (fraction * m_qAvg);
if (ratio < 1.0)
--- a/src/nix-vector-routing/examples/nms-p2p-nix.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/nix-vector-routing/examples/nms-p2p-nix.cc Sat Sep 01 20:57:21 2012 +0200
@@ -48,7 +48,6 @@
#include "ns3/ipv4-list-routing-helper.h"
#include "ns3/ipv4-nix-vector-helper.h"
-using namespace std;
using namespace ns3;
typedef struct timeval TIMER_TYPE;
@@ -126,7 +125,7 @@
{
TIMER_TYPE t0, t1, t2;
TIMER_NOW (t0);
- cout << " ==== DARPA NMS CAMPUS NETWORK SIMULATION ====" << endl;
+ std::cout << " ==== DARPA NMS CAMPUS NETWORK SIMULATION ====" << std::endl;
LogComponentEnable ("OnOffApplication", LOG_LEVEL_INFO);
int nCN = 2, nLANClients = 42;
@@ -140,12 +139,12 @@
if (nCN < 2)
{
- cout << "Number of total CNs (" << nCN << ") lower than minimum of 2"
- << endl;
+ std::cout << "Number of total CNs (" << nCN << ") lower than minimum of 2"
+ << std::endl;
return 1;
}
- cout << "Number of CNs: " << nCN << ", LAN nodes: " << nLANClients << endl;
+ std::cout << "Number of CNs: " << nCN << ", LAN nodes: " << nLANClients << std::endl;
Array2D<NodeContainer> nodes_net0(nCN, 3);
Array2D<NodeContainer> nodes_net1(nCN, 6);
@@ -190,9 +189,9 @@
// Create Campus Networks
for (int z = 0; z < nCN; ++z)
{
- cout << "Creating Campus Network " << z << ":" << endl;
+ std::cout << "Creating Campus Network " << z << ":" << std::endl;
// Create Net0
- cout << " SubNet [ 0";
+ std::cout << " SubNet [ 0";
for (int i = 0; i < 3; ++i)
{
nodes_net0[z][i].Create (1);
@@ -207,7 +206,7 @@
ndc0[i] = p2p_1gb5ms.Install (nodes_net0[z][i]);
}
// Create Net1
- cout << " 1";
+ std::cout << " 1";
for (int i = 0; i < 6; ++i)
{
nodes_net1[z][i].Create (1);
@@ -238,7 +237,7 @@
address.SetBase (oss.str ().c_str (), "255.255.255.0");
ifs = address.Assign (ndc0_1);
// Create Net2
- cout << " 2";
+ std::cout << " 2";
for (int i = 0; i < 14; ++i)
{
nodes_net2[z][i].Create (1);
@@ -280,7 +279,7 @@
}
}
// Create Net3
- cout << " 3 ]" << endl;
+ std::cout << " 3 ]" << std::endl;
for (int i = 0; i < 9; ++i)
{
nodes_net3[z][i].Create (1);
@@ -316,7 +315,7 @@
ifs3LAN[z][i][j] = address.Assign (ndc3LAN[i][j]);
}
}
- cout << " Connecting Subnets..." << endl;
+ std::cout << " Connecting Subnets..." << std::endl;
// Create Lone Routers (Node 4 & 5)
nodes_netLR[z].Create (2);
stack.Install (nodes_netLR[z]);
@@ -368,7 +367,7 @@
address.SetBase (oss.str ().c_str (), "255.255.255.0");
ifs = address.Assign (ndc3_5b);
// Assign IP addresses
- cout << " Assigning IP addresses..." << endl;
+ std::cout << " Assigning IP addresses..." << std::endl;
for (int i = 0; i < 3; ++i)
{
oss.str ("");
@@ -409,7 +408,7 @@
// Create Ring Links
if (nCN > 1)
{
- cout << "Forming Ring Topology..." << endl;
+ std::cout << "Forming Ring Topology..." << std::endl;
NodeContainer* nodes_ring = new NodeContainer[nCN];
for (int z = 0; z < nCN-1; ++z)
{
@@ -432,7 +431,7 @@
}
// Create Traffic Flows
- cout << "Creating TCP Traffic Flows:" << endl;
+ std::cout << "Creating TCP Traffic Flows:" << std::endl;
Config::SetDefault ("ns3::OnOffApplication::MaxBytes", UintegerValue (500000));
Config::SetDefault ("ns3::OnOffApplication::OnTime",
StringValue ("ns3::ConstantRandomVariable[Constant=1.0]"));
@@ -451,7 +450,7 @@
x = 0;
}
// Subnet 2 LANs
- cout << " Campus Network " << z << " Flows [ Net2 ";
+ std::cout << " Campus Network " << z << " Flows [ Net2 ";
for (int i = 0; i < 7; ++i)
{
for (int j = 0; j < nLANClients; ++j)
@@ -475,7 +474,7 @@
}
}
// Subnet 3 LANs
- cout << "Net3 ]" << endl;
+ std::cout << "Net3 ]" << std::endl;
for (int i = 0; i < 5; ++i)
{
for (int j = 0; j < nLANClients; ++j)
@@ -500,41 +499,41 @@
}
}
- cout << "Created " << NodeList::GetNNodes () << " nodes." << endl;
+ std::cout << "Created " << NodeList::GetNNodes () << " nodes." << std::endl;
TIMER_TYPE routingStart;
TIMER_NOW (routingStart);
if (nix)
{
// Calculate routing tables
- cout << "Using Nix-vectors..." << endl;
+ std::cout << "Using Nix-vectors..." << std::endl;
}
else
{
// Calculate routing tables
- cout << "Populating Global Static Routing Tables..." << endl;
+ std::cout << "Populating Global Static Routing Tables..." << std::endl;
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
}
TIMER_TYPE routingEnd;
TIMER_NOW (routingEnd);
- cout << "Routing tables population took "
- << TIMER_DIFF (routingEnd, routingStart) << endl;
+ std::cout << "Routing tables population took "
+ << TIMER_DIFF (routingEnd, routingStart) << std::endl;
Simulator::ScheduleNow (Progress);
- cout << "Running simulator..." << endl;
+ std::cout << "Running simulator..." << std::endl;
TIMER_NOW (t1);
Simulator::Stop (Seconds (100.0));
Simulator::Run ();
TIMER_NOW (t2);
- cout << "Simulator finished." << endl;
+ std::cout << "Simulator finished." << std::endl;
Simulator::Destroy ();
double d1 = TIMER_DIFF (t1, t0), d2 = TIMER_DIFF (t2, t1);
- cout << "-----" << endl << "Runtime Stats:" << endl;
- cout << "Simulator init time: " << d1 << endl;
- cout << "Simulator run time: " << d2 << endl;
- cout << "Total elapsed time: " << d1+d2 << endl;
+ std::cout << "-----" << std::endl << "Runtime Stats:" << std::endl;
+ std::cout << "Simulator init time: " << d1 << std::endl;
+ std::cout << "Simulator run time: " << d2 << std::endl;
+ std::cout << "Total elapsed time: " << d1+d2 << std::endl;
delete[] nodes_netLR;
return 0;
--- a/src/olsr/model/olsr-header.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/olsr/model/olsr-header.cc Sat Sep 01 20:57:21 2012 +0200
@@ -18,10 +18,12 @@
* Author: Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
*/
+#include <cmath>
+
#include "ns3/assert.h"
+#include "ns3/log.h"
#include "olsr-header.h"
-#include "ns3/log.h"
#define IPV4_ADDRESS_SIZE 4
#define OLSR_MSG_HEADER_SIZE 12
@@ -58,7 +60,7 @@
double tmp = 16*(seconds/(OLSR_C*(1<<b))-1);
// round it up. This results in the value for 'a'
- a = (int) ceil (tmp);
+ a = (int) std::ceil (tmp);
// if 'a' is equal to 16: increment 'b' by one, and set 'a' to 0
if (a == 16)
--- a/src/olsr/test/olsr-header-test-suite.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/olsr/test/olsr-header-test-suite.cc Sat Sep 01 20:57:21 2012 +0200
@@ -41,7 +41,7 @@
{
uint8_t emf = olsr::SecondsToEmf (time);
double seconds = olsr::EmfToSeconds (emf);
- NS_TEST_ASSERT_MSG_EQ ((seconds < 0 || fabs (seconds - time) > 0.1), false,
+ NS_TEST_ASSERT_MSG_EQ ((seconds < 0 || std::fabs (seconds - time) > 0.1), false,
"XXX");
}
}
--- a/src/point-to-point-layout/model/point-to-point-dumbbell.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/point-to-point-layout/model/point-to-point-dumbbell.cc Sat Sep 01 20:57:21 2012 +0200
@@ -18,6 +18,7 @@
// Implement an object to create a dumbbell topology.
+#include <cmath>
#include <iostream>
#include <sstream>
@@ -273,8 +274,8 @@
loc = CreateObject<ConstantPositionMobilityModel> ();
ln->AggregateObject (loc);
}
- Vector lnl (lrl.x - cos (theta) * xAdder,
- lrl.y + sin (theta) * xAdder, 0); // Left Node Location
+ Vector lnl (lrl.x - std::cos (theta) * xAdder,
+ lrl.y + std::sin (theta) * xAdder, 0); // Left Node Location
// Insure did not exceed bounding box
if (lnl.y < uly)
{
@@ -306,8 +307,8 @@
loc = CreateObject<ConstantPositionMobilityModel> ();
rn->AggregateObject (loc);
}
- Vector rnl (rrl.x + cos (theta) * xAdder, // Right node location
- rrl.y + sin (theta) * xAdder, 0);
+ Vector rnl (rrl.x + std::cos (theta) * xAdder, // Right node location
+ rrl.y + std::sin (theta) * xAdder, 0);
// Insure did not exceed bounding box
if (rnl.y < uly)
{
--- a/src/point-to-point-layout/model/point-to-point-star.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/point-to-point-layout/model/point-to-point-star.cc Sat Sep 01 20:57:21 2012 +0200
@@ -14,6 +14,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <cmath>
#include <iostream>
#include <sstream>
@@ -184,8 +185,8 @@
spokeLoc = CreateObject<ConstantPositionMobilityModel> ();
spokeNode->AggregateObject (spokeLoc);
}
- Vector spokeVec (hubVec.x + cos (theta*i) * spokeDist,
- hubVec.y + sin (theta*i) * spokeDist,
+ Vector spokeVec (hubVec.x + std::cos (theta*i) * spokeDist,
+ hubVec.y + std::sin (theta*i) * spokeDist,
0);
spokeLoc->SetPosition (spokeVec);
}
--- a/src/point-to-point/model/point-to-point-net-device.h Fri Aug 31 12:24:28 2012 +0200
+++ b/src/point-to-point/model/point-to-point-net-device.h Sat Sep 01 20:57:21 2012 +0200
@@ -19,7 +19,7 @@
#ifndef POINT_TO_POINT_NET_DEVICE_H
#define POINT_TO_POINT_NET_DEVICE_H
-#include <string.h>
+#include <cstring>
#include "ns3/address.h"
#include "ns3/node.h"
#include "ns3/net-device.h"
--- a/src/point-to-point/model/point-to-point-remote-channel.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/point-to-point/model/point-to-point-remote-channel.cc Sat Sep 01 20:57:21 2012 +0200
@@ -27,8 +27,6 @@
#include "ns3/log.h"
#include "ns3/mpi-interface.h"
-using namespace std;
-
NS_LOG_COMPONENT_DEFINE ("PointToPointRemoteChannel");
namespace ns3 {
--- a/src/propagation/examples/jakes-propagation-model-example.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/propagation/examples/jakes-propagation-model-example.cc Sat Sep 01 20:57:21 2012 +0200
@@ -21,7 +21,7 @@
#include "ns3/mobility-module.h"
#include "ns3/jakes-propagation-loss-model.h"
#include <vector>
-#include <math.h>
+#include <cmath>
using namespace ns3;
/**
--- a/src/propagation/model/cost231-propagation-loss-model.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/propagation/model/cost231-propagation-loss-model.cc Sat Sep 01 20:57:21 2012 +0200
@@ -24,7 +24,7 @@
#include "ns3/mobility-model.h"
#include "ns3/double.h"
#include "ns3/pointer.h"
-#include <math.h>
+#include <cmath>
#include "cost231-propagation-loss-model.h"
namespace ns3 {
@@ -166,14 +166,14 @@
return 0.0;
}
- double log_f = log (m_frequency / 1000000000) / 2.302;
+ double log_f = std::log (m_frequency / 1000000000) / 2.302;
double C_H = 0.8 + ((1.11 * log_f) - 0.7) * m_SSAntennaHeight - (1.56 * log_f);
- double log_BSH = log (m_BSAntennaHeight) / 2.303;
+ double log_BSH = std::log (m_BSAntennaHeight) / 2.303;
// from the COST231 wiki entry
// 2.303 is for the logarithm base change
- double loss_in_db = 46.3 + (33.9 * log_f) - (13.82 * log_BSH) - C_H + ((44.9 - 6.55 * log_BSH) * log (distance)
+ double loss_in_db = 46.3 + (33.9 * log_f) - (13.82 * log_BSH) - C_H + ((44.9 - 6.55 * log_BSH) * std::log (distance)
/ 2.303) + C + m_shadowing;
NS_LOG_DEBUG ("dist =" << distance << ", Path Loss = " << loss_in_db);
--- a/src/propagation/model/itu-r-1411-los-propagation-loss-model.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/propagation/model/itu-r-1411-los-propagation-loss-model.cc Sat Sep 01 20:57:21 2012 +0200
@@ -57,18 +57,18 @@
double lossLow = 0.0;
double lossUp = 0.0;
NS_ASSERT_MSG (a->GetPosition ().z > 0 && b->GetPosition ().z > 0, "nodes' height must be greater than 0");
- double Lbp = fabs (20 * log10 ((m_lambda * m_lambda) / (8 * M_PI * a->GetPosition ().z * b->GetPosition ().z)));
+ double Lbp = std::fabs (20 * std::log10 ((m_lambda * m_lambda) / (8 * M_PI * a->GetPosition ().z * b->GetPosition ().z)));
double Rbp = (4 * a->GetPosition ().z * b->GetPosition ().z) / m_lambda;
NS_LOG_LOGIC (this << " Lbp " << Lbp << " Rbp " << Rbp << " lambda " << m_lambda);
if (dist <= Rbp)
{
- lossLow = Lbp + 20 * log10 (dist / Rbp);
- lossUp = Lbp + 20 + 25 * log10 (dist / Rbp);
+ lossLow = Lbp + 20 * std::log10 (dist / Rbp);
+ lossUp = Lbp + 20 + 25 * std::log10 (dist / Rbp);
}
else
{
- lossLow = Lbp + 40 * log10 (dist / Rbp);
- lossUp = Lbp + 20 + 40 * log10 (dist / Rbp);
+ lossLow = Lbp + 40 * std::log10 (dist / Rbp);
+ lossUp = Lbp + 20 + 40 * std::log10 (dist / Rbp);
}
double loss = (lossUp + lossLow) / 2;
--- a/src/propagation/model/itu-r-1411-nlos-over-rooftop-propagation-loss-model.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/propagation/model/itu-r-1411-nlos-over-rooftop-propagation-loss-model.cc Sat Sep 01 20:57:21 2012 +0200
@@ -136,7 +136,7 @@
double kf = 0.0;
if (hb > m_rooftopHeight)
{
- Lbsh = -18 * log10 (1 + Dhb);
+ Lbsh = -18 * std::log10 (1 + Dhb);
ka = (fmhz > 2000 ? 71.4 : 54.0);
kd = 18.0;
}
@@ -166,12 +166,12 @@
kf = -4 + 1.5 * (fmhz / 925.0 - 1);
}
- Lmsd = Lbsh + ka + kd*log10 (distance / 1000.0) + kf*log10 (fmhz) - 9.0 * log10 (m_buildingSeparation);
+ Lmsd = Lbsh + ka + kd * std::log10 (distance / 1000.0) + kf * std::log10 (fmhz) - 9.0 * std::log10 (m_buildingSeparation);
}
else
{
- double theta = atan (Dhb / m_buildingSeparation);
- double rho = sqrt (Dhb * Dhb + m_buildingSeparation * m_buildingSeparation);
+ double theta = std::atan (Dhb / m_buildingSeparation);
+ double rho = std::sqrt (Dhb * Dhb + m_buildingSeparation * m_buildingSeparation);
double Qm = 0.0;
if ((hb > m_rooftopHeight - 1.0) && (hb < m_rooftopHeight + 1.0))
{
@@ -179,17 +179,17 @@
}
else if (hb > m_rooftopHeight)
{
- Qm = 2.35 * pow (Dhb / distance * sqrt (m_buildingSeparation / m_lambda), 0.9);
+ Qm = 2.35 * pow (Dhb / distance * std::sqrt (m_buildingSeparation / m_lambda), 0.9);
}
else
{
- Qm = m_buildingSeparation / (2 * M_PI * distance) * sqrt (m_lambda / rho) * (1 / theta - (1 / (2 * M_PI + theta)));
+ Qm = m_buildingSeparation / (2 * M_PI * distance) * std::sqrt (m_lambda / rho) * (1 / theta - (1 / (2 * M_PI + theta)));
}
- Lmsd = -10 * log10 (Qm * Qm);
+ Lmsd = -10 * std::log10 (Qm * Qm);
}
- double Lbf = 32.4 + 20 * log10 (distance / 1000) + 20 * log10 (fmhz);
+ double Lbf = 32.4 + 20 * std::log10 (distance / 1000) + 20 * std::log10 (fmhz);
double Dhm = m_rooftopHeight - hm;
- double Lrts = -8.2 - 10 * log10 (m_streetsWidth) + 10 * log10 (fmhz) + 20 * log10 (Dhm) + Lori;
+ double Lrts = -8.2 - 10 * std::log10 (m_streetsWidth) + 10 * std::log10 (fmhz) + 20 * std::log10 (Dhm) + Lori;
NS_LOG_LOGIC (this << " Lbf " << Lbf << " Lrts " << Lrts << " Dhm" << Dhm << " Lmsd " << Lmsd);
double loss = 0.0;
if (Lrts + Lmsd > 0)
--- a/src/propagation/model/jakes-process.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/propagation/model/jakes-process.cc Sat Sep 01 20:57:21 2012 +0200
@@ -40,7 +40,7 @@
std::complex<double>
JakesProcess::Oscillator::GetValueAt (Time at) const
{
- return (m_amplitude * cos (at.GetSeconds () * m_omega + m_phase));
+ return (m_amplitude * std::cos (at.GetSeconds () * m_omega + m_phase));
}
NS_OBJECT_ENSURE_REGISTERED (JakesProcess);
@@ -103,10 +103,10 @@
/// 1a. Initiate \f[ \alpha_n = \frac{2\pi n - \pi + \theta}{4M}, n=1,2, \ldots,M\f], n is oscillatorNumber, M is m_nOscillators
double alpha = (2.0 * JakesPropagationLossModel::PI * n - JakesPropagationLossModel::PI + theta) / (4.0 * m_nOscillators);
/// 1b. Initiate rotation speed:
- double omega = m_omegaDopplerMax * cos (alpha);
+ double omega = m_omegaDopplerMax * std::cos (alpha);
/// 2. Initiate complex amplitude:
double psi = m_jakes->GetUniformRandomVariable ()->GetValue ();
- std::complex<double> amplitude = std::complex<double> (cos (psi), sin (psi)) * 2.0 / sqrt (m_nOscillators);
+ std::complex<double> amplitude = std::complex<double> (std::cos (psi), std::sin (psi)) * 2.0 / std::sqrt (m_nOscillators);
/// 3. Construct oscillator:
m_oscillators.push_back (Oscillator (amplitude, phi, omega));
}
@@ -144,7 +144,7 @@
JakesProcess::GetChannelGainDb () const
{
std::complex<double> complexGain = GetComplexGain ();
- return (10 * log10 ((pow (complexGain.real (), 2) + pow (complexGain.imag (), 2)) / 2));
+ return (10 * std::log10 ((std::pow (complexGain.real (), 2) + std::pow (complexGain.imag (), 2)) / 2));
}
} // namespace ns3
--- a/src/propagation/model/kun-2600-mhz-propagation-loss-model.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/propagation/model/kun-2600-mhz-propagation-loss-model.cc Sat Sep 01 20:57:21 2012 +0200
@@ -47,7 +47,7 @@
Kun2600MhzPropagationLossModel::GetLoss (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const
{
double dist = a->GetDistanceFrom (b);
- double loss = 36 + 26 * log10 (dist);
+ double loss = 36 + 26 * std::log10 (dist);
return loss;
}
--- a/src/propagation/model/okumura-hata-propagation-loss-model.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/propagation/model/okumura-hata-propagation-loss-model.cc Sat Sep 01 20:57:21 2012 +0200
@@ -76,21 +76,21 @@
{
// standard Okumura Hata
// see eq. (4.4.1) in the COST 231 final report
- double log_f = log10 (fmhz);
+ double log_f = std::log10 (fmhz);
double hb = (a->GetPosition ().z > b->GetPosition ().z ? a->GetPosition ().z : b->GetPosition ().z);
double hm = (a->GetPosition ().z < b->GetPosition ().z ? a->GetPosition ().z : b->GetPosition ().z);
NS_ASSERT_MSG (hb > 0 && hm > 0, "nodes' height must be greater then 0");
- double log_aHeight = 13.82 * log10 (hb);
+ double log_aHeight = 13.82 * std::log10 (hb);
double log_bHeight = 0.0;
if (m_citySize == LargeCity)
{
if (m_frequency < 200)
{
- log_bHeight = 8.29 * pow (log10 (1.54 * hm), 2) - 1.1;
+ log_bHeight = 8.29 * std::pow (log10 (1.54 * hm), 2) - 1.1;
}
else
{
- log_bHeight = 3.2 * pow (log10 (11.75 * hm), 2) - 4.97;
+ log_bHeight = 3.2 * std::pow (log10 (11.75 * hm), 2) - 4.97;
}
}
else
@@ -98,15 +98,15 @@
log_bHeight = 0.8 + (1.1 * log_f - 0.7) * hm - 1.56 * log_f;
}
- NS_LOG_INFO (this << " logf " << 26.16 * log_f << " loga " << log_aHeight << " X " << (((44.9 - (6.55 * log10(hb)) ))*log10 (a->GetDistanceFrom (b))) << " logb " << log_bHeight);
- loss = 69.55 + (26.16 * log_f) - log_aHeight + (((44.9 - (6.55 * log10 (hb)) )) * log10 (dist)) - log_bHeight;
+ NS_LOG_INFO (this << " logf " << 26.16 * log_f << " loga " << log_aHeight << " X " << (((44.9 - (6.55 * std::log10 (hb)) )) * std::log10 (a->GetDistanceFrom (b))) << " logb " << log_bHeight);
+ loss = 69.55 + (26.16 * log_f) - log_aHeight + (((44.9 - (6.55 * std::log10 (hb)) )) * std::log10 (dist)) - log_bHeight;
if (m_environment == SubUrbanEnvironment)
{
- loss += -2 * (pow (log10 (fmhz / 28), 2)) - 5.4;
+ loss += -2 * (std::pow (std::log10 (fmhz / 28), 2)) - 5.4;
}
else if (m_environment == OpenAreasEnvironment)
{
- loss += -4.70 * pow (log10 (fmhz),2) + 18.33 * log10 (fmhz) - 40.94;
+ loss += -4.70 * std::pow (std::log10 (fmhz),2) + 18.33 * std::log10 (fmhz) - 40.94;
}
}
@@ -115,17 +115,17 @@
// COST 231 Okumura model
// see eq. (4.4.3) in the COST 231 final report
- double log_f = log10 (fmhz);
+ double log_f = std::log10 (fmhz);
double hb = (a->GetPosition ().z > b->GetPosition ().z ? a->GetPosition ().z : b->GetPosition ().z);
double hm = (a->GetPosition ().z < b->GetPosition ().z ? a->GetPosition ().z : b->GetPosition ().z);
NS_ASSERT_MSG (hb > 0 && hm > 0, "nodes' height must be greater then 0");
- double log_aHeight = 13.82 * log10 (hb);
+ double log_aHeight = 13.82 * std::log10 (hb);
double log_bHeight = 0.0;
double C = 0.0;
if (m_citySize == LargeCity)
{
- log_bHeight = 3.2 * pow ((log10 (11.75 * hm)),2);
+ log_bHeight = 3.2 * std::pow ((std::log10 (11.75 * hm)), 2);
C = 3;
}
else
@@ -133,7 +133,7 @@
log_bHeight = 1.1 * log_f - 0.7 * hm - (1.56 * log_f - 0.8);
}
- loss = 46.3 + (33.9 * log_f) - log_aHeight + (((44.9 - (6.55 * log10 (hb)) )) * log10 (dist)) - log_bHeight + C;
+ loss = 46.3 + (33.9 * log_f) - log_aHeight + (((44.9 - (6.55 * std::log10 (hb)) )) * std::log10 (dist)) - log_bHeight + C;
}
return loss;
}
--- a/src/propagation/model/propagation-loss-model.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/propagation/model/propagation-loss-model.cc Sat Sep 01 20:57:21 2012 +0200
@@ -28,7 +28,7 @@
#include "ns3/double.h"
#include "ns3/string.h"
#include "ns3/pointer.h"
-#include <math.h>
+#include <cmath>
NS_LOG_COMPONENT_DEFINE ("PropagationLossModel");
@@ -209,14 +209,14 @@
double
FriisPropagationLossModel::DbmToW (double dbm) const
{
- double mw = pow (10.0,dbm/10.0);
+ double mw = std::pow (10.0,dbm/10.0);
return mw / 1000.0;
}
double
FriisPropagationLossModel::DbmFromW (double w) const
{
- double dbm = log10 (w * 1000.0) * 10.0;
+ double dbm = std::log10 (w * 1000.0) * 10.0;
return dbm;
}
@@ -261,7 +261,7 @@
}
double numerator = m_lambda * m_lambda;
double denominator = 16 * PI * PI * distance * distance * m_systemLoss;
- double pr = 10 * log10 (numerator / denominator);
+ double pr = 10 * std::log10 (numerator / denominator);
NS_LOG_DEBUG ("distance="<<distance<<"m, attenuation coefficient="<<pr<<"dB");
return txPowerDbm + pr;
}
@@ -356,14 +356,14 @@
double
TwoRayGroundPropagationLossModel::DbmToW (double dbm) const
{
- double mw = pow (10.0,dbm / 10.0);
+ double mw = std::pow (10.0,dbm / 10.0);
return mw / 1000.0;
}
double
TwoRayGroundPropagationLossModel::DbmFromW (double w) const
{
- double dbm = log10 (w * 1000.0) * 10.0;
+ double dbm = std::log10 (w * 1000.0) * 10.0;
return dbm;
}
@@ -423,7 +423,7 @@
double numerator = m_lambda * m_lambda;
tmp = PI * distance;
double denominator = 16 * tmp * tmp * m_systemLoss;
- double pr = 10 * log10 (numerator / denominator);
+ double pr = 10 * std::log10 (numerator / denominator);
NS_LOG_DEBUG ("Receiver within crossover (" << dCross << "m) for Two_ray path; using Friis");
NS_LOG_DEBUG ("distance=" << distance << "m, attenuation coefficient=" << pr << "dB");
return txPowerDbm + pr;
@@ -434,7 +434,7 @@
double rayNumerator = tmp * tmp;
tmp = distance * distance;
double rayDenominator = tmp * tmp * m_systemLoss;
- double rayPr = 10 * log10 (rayNumerator / rayDenominator);
+ double rayPr = 10 * std::log10 (rayNumerator / rayDenominator);
NS_LOG_DEBUG ("distance=" << distance << "m, attenuation coefficient=" << rayPr << "dB");
return txPowerDbm + rayPr;
@@ -522,7 +522,7 @@
*
* rx = rx0(tx) - 10 * n * log (d/d0)
*/
- double pathLossDb = 10 * m_exponent * log10 (distance / m_referenceDistance);
+ double pathLossDb = 10 * m_exponent * std::log10 (distance / m_referenceDistance);
double rxc = -m_referenceLoss - pathLossDb;
NS_LOG_DEBUG ("distance="<<distance<<"m, reference-attenuation="<< -m_referenceLoss<<"dB, "<<
"attenuation coefficient="<<rxc<<"db");
@@ -608,20 +608,20 @@
else if (distance < m_distance1)
{
pathLossDb = m_referenceLoss
- + 10 * m_exponent0 * log10 (distance / m_distance0);
+ + 10 * m_exponent0 * std::log10 (distance / m_distance0);
}
else if (distance < m_distance2)
{
pathLossDb = m_referenceLoss
- + 10 * m_exponent0 * log10 (m_distance1 / m_distance0)
- + 10 * m_exponent1 * log10 (distance / m_distance1);
+ + 10 * m_exponent0 * std::log10 (m_distance1 / m_distance0)
+ + 10 * m_exponent1 * std::log10 (distance / m_distance1);
}
else
{
pathLossDb = m_referenceLoss
- + 10 * m_exponent0 * log10 (m_distance1 / m_distance0)
- + 10 * m_exponent1 * log10 (m_distance2 / m_distance1)
- + 10 * m_exponent2 * log10 (distance / m_distance2);
+ + 10 * m_exponent0 * std::log10 (m_distance1 / m_distance0)
+ + 10 * m_exponent1 * std::log10 (m_distance2 / m_distance1)
+ + 10 * m_exponent2 * std::log10 (distance / m_distance2);
}
NS_LOG_DEBUG ("ThreeLogDistance distance=" << distance << "m, " <<
@@ -716,13 +716,13 @@
// the current power unit is dBm, but Watt is put into the Nakagami /
// Rayleigh distribution.
- double powerW = pow (10, (txPowerDbm - 30) / 10);
+ double powerW = std::pow (10, (txPowerDbm - 30) / 10);
double resultPowerW;
// switch between Erlang- and Gamma distributions: this is only for
// speed. (Gamma is equal to Erlang for any positive integer m.)
- unsigned int int_m = static_cast<unsigned int>(floor (m));
+ unsigned int int_m = static_cast<unsigned int>(std::floor (m));
if (int_m == m)
{
@@ -733,7 +733,7 @@
resultPowerW = m_gammaRandomVariable->GetValue (m, powerW / m);
}
- double resultPowerDbm = 10 * log10 (resultPowerW) + 30;
+ double resultPowerDbm = 10 * std::log10 (resultPowerW) + 30;
NS_LOG_DEBUG ("Nakagami distance=" << distance << "m, " <<
"power=" << powerW <<"W, " <<
--- a/src/propagation/test/propagation-loss-model-test-suite.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/propagation/test/propagation-loss-model-test-suite.cc Sat Sep 01 20:57:21 2012 +0200
@@ -75,7 +75,7 @@
// Select a reference transmit power
// Pt = 10^(17.0206/10)/10^3 = .05035702 W
double txPowerW = 0.05035702;
- double txPowerdBm = 10 * log10 (txPowerW) + 30;
+ double txPowerdBm = 10 * std::log10 (txPowerW) + 30;
//
// We want to test the propagation loss model calculations at a few chosen
@@ -124,7 +124,7 @@
testVector = m_testVectors.Get (i);
b->SetPosition (testVector.m_position);
double resultdBm = lossModel->CalcRxPower (testVector.m_pt, a, b);
- double resultW = pow (10.0, resultdBm/10.0)/1000;
+ double resultW = std::pow (10.0, resultdBm/10.0)/1000;
NS_TEST_EXPECT_MSG_EQ_TOL (resultW, testVector.m_pr, testVector.m_tolerance, "Got unexpected rcv power");
}
}
@@ -174,7 +174,7 @@
// Select a reference transmit power of 17.0206 dBm
// Pt = 10^(17.0206/10)/10^3 = .05035702 W
double txPowerW = 0.05035702;
- double txPowerdBm = 10 * log10 (txPowerW) + 30;
+ double txPowerdBm = 10 * std::log10 (txPowerW) + 30;
//
// As with the Friis tests above, we want to test the propagation loss
@@ -253,7 +253,7 @@
testVector = m_testVectors.Get (i);
b->SetPosition (testVector.m_position);
double resultdBm = lossModel->CalcRxPower (testVector.m_pt, a, b);
- double resultW = pow (10.0, resultdBm / 10.0) / 1000;
+ double resultW = std::pow (10.0, resultdBm / 10.0) / 1000;
NS_TEST_EXPECT_MSG_EQ_TOL (resultW, testVector.m_pr, testVector.m_tolerance, "Got unexpected rcv power");
}
}
@@ -297,7 +297,7 @@
// Select a reference transmit power
// Pt = 10^(17.0206/10)/10^3 = .05035702 W
double txPowerW = 0.05035702;
- double txPowerdBm = 10 * log10 (txPowerW) + 30;
+ double txPowerdBm = 10 * std::log10 (txPowerW) + 30;
//
// We want to test the propagation loss model calculations at a few chosen
@@ -341,7 +341,7 @@
testVector = m_testVectors.Get (i);
b->SetPosition (testVector.m_position);
double resultdBm = lossModel->CalcRxPower (testVector.m_pt, a, b);
- double resultW = pow (10.0, resultdBm/10.0)/1000;
+ double resultW = std::pow (10.0, resultdBm/10.0)/1000;
NS_TEST_EXPECT_MSG_EQ_TOL (resultW, testVector.m_pr, testVector.m_tolerance, "Got unexpected rcv power");
}
}
--- a/src/spectrum/examples/adhoc-aloha-ideal-phy-matrix-propagation-loss-model.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/spectrum/examples/adhoc-aloha-ideal-phy-matrix-propagation-loss-model.cc Sat Sep 01 20:57:21 2012 +0200
@@ -40,9 +40,6 @@
#include <ns3/applications-module.h>
#include <ns3/adhoc-aloha-noack-ideal-phy-helper.h>
-#ifdef __FreeBSD__
-#define log2(x) (log (x)/M_LN2)
-#endif
NS_LOG_COMPONENT_DEFINE ("TestAdhocOfdmAloha");
@@ -216,7 +213,7 @@
std::cout << "throughput: " << throughputBps << std::endl;
std::cout << "throughput: " << std::setw (20) << std::fixed << throughputBps << " bps" << std::endl;
std::cout << "phy rate : " << std::setw (20) << std::fixed << phyRate*1.0 << " bps" << std::endl;
- double rxPowerW = txPowerW / (pow (10.0, lossDb/10.0));
+ double rxPowerW = txPowerW / (std::pow (10.0, lossDb/10.0));
double capacity = 20e6*log2 (1.0 + (rxPowerW/20.0e6)/noisePsdValue);
std::cout << "shannon capacity: " << std::setw (20) << std::fixed << capacity << " bps" << std::endl;
--- a/src/spectrum/model/aloha-noack-net-device.h Fri Aug 31 12:24:28 2012 +0200
+++ b/src/spectrum/model/aloha-noack-net-device.h Sat Sep 01 20:57:21 2012 +0200
@@ -21,7 +21,7 @@
#ifndef ALOHA_NOACK_NET_DEVICE_H
#define ALOHA_NOACK_NET_DEVICE_H
-#include <string.h>
+#include <cstring>
#include <ns3/node.h>
#include <ns3/address.h>
#include <ns3/net-device.h>
--- a/src/spectrum/model/constant-spectrum-propagation-loss.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/spectrum/model/constant-spectrum-propagation-loss.cc Sat Sep 01 20:57:21 2012 +0200
@@ -18,7 +18,7 @@
* Author: Manuel Requena <manuel.requena@cttc.es>
*/
-#include <math.h>
+#include <cmath>
#include "ns3/log.h"
@@ -65,7 +65,7 @@
{
NS_LOG_FUNCTION (this);
m_lossDb = lossDb;
- m_lossLinear = pow (10, m_lossDb / 10);
+ m_lossLinear = std::pow (10, m_lossDb / 10);
}
--- a/src/spectrum/model/friis-spectrum-propagation-loss.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/spectrum/model/friis-spectrum-propagation-loss.cc Sat Sep 01 20:57:21 2012 +0200
@@ -18,11 +18,9 @@
* Author: Nicola Baldo <nbaldo@cttc.es>
*/
-
#include <ns3/mobility-model.h>
#include <ns3/friis-spectrum-propagation-loss.h>
-#include <math.h>
-
+#include <cmath> // for M_PI
namespace ns3 {
--- a/src/spectrum/model/half-duplex-ideal-phy.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/spectrum/model/half-duplex-ideal-phy.cc Sat Sep 01 20:57:21 2012 +0200
@@ -20,7 +20,7 @@
#include <ns3/object-factory.h>
#include <ns3/log.h>
-#include <math.h>
+#include <cmath>
#include <ns3/simulator.h>
#include <ns3/trace-source-accessor.h>
#include <ns3/packet-burst.h>
@@ -289,7 +289,7 @@
txParams->psd = m_txPsd;
txParams->data = m_txPacket;
- NS_LOG_LOGIC (this << " tx power: " << 10 * log10 (Integral (*(txParams->psd))) + 30 << " dBm");
+ NS_LOG_LOGIC (this << " tx power: " << 10 * std::log10 (Integral (*(txParams->psd))) + 30 << " dBm");
m_channel->StartTx (txParams);
Simulator::Schedule (Seconds (txTimeSeconds), &HalfDuplexIdealPhy::EndTx, this);
}
@@ -329,7 +329,7 @@
{
NS_LOG_FUNCTION (this << spectrumParams);
NS_LOG_LOGIC (this << " state: " << m_state);
- NS_LOG_LOGIC (this << " rx power: " << 10 * log10 (Integral (*(spectrumParams->psd))) + 30 << " dBm");
+ NS_LOG_LOGIC (this << " rx power: " << 10 * std::log10 (Integral (*(spectrumParams->psd))) + 30 << " dBm");
// interference will happen regardless of the state of the receiver
m_interference.AddSignal (spectrumParams->psd, spectrumParams->duration);
--- a/src/spectrum/model/multi-model-spectrum-channel.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/spectrum/model/multi-model-spectrum-channel.cc Sat Sep 01 20:57:21 2012 +0200
@@ -317,7 +317,7 @@
// beyond range
continue;
}
- double pathGainLinear = pow (10.0, (-pathLossDb) / 10.0);
+ double pathGainLinear = std::pow (10.0, (-pathLossDb) / 10.0);
*(rxParams->psd) *= pathGainLinear;
if (m_spectrumPropagationLoss)
--- a/src/spectrum/model/non-communicating-net-device.h Fri Aug 31 12:24:28 2012 +0200
+++ b/src/spectrum/model/non-communicating-net-device.h Sat Sep 01 20:57:21 2012 +0200
@@ -21,7 +21,7 @@
#ifndef NON_COMMUNICATING_NET_DEVICE_H
#define NON_COMMUNICATING_NET_DEVICE_H
-#include <string.h>
+#include <cstring>
#include <ns3/node.h>
#include <ns3/address.h>
#include <ns3/net-device.h>
--- a/src/spectrum/model/single-model-spectrum-channel.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/spectrum/model/single-model-spectrum-channel.cc Sat Sep 01 20:57:21 2012 +0200
@@ -172,7 +172,7 @@
// beyond range
continue;
}
- double pathGainLinear = pow (10.0, (-pathLossDb) / 10.0);
+ double pathGainLinear = std::pow (10.0, (-pathLossDb) / 10.0);
*(rxParams->psd) *= pathGainLinear;
if (m_spectrumPropagationLoss)
--- a/src/spectrum/model/spectrum-value.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/spectrum/model/spectrum-value.cc Sat Sep 01 20:57:21 2012 +0200
@@ -20,14 +20,9 @@
*/
#include <ns3/spectrum-value.h>
-#include <math.h>
+#include <ns3/math.h>
#include <ns3/log.h>
-#ifdef __FreeBSD__
-#define log2(x) (log (x) / M_LN2)
-#endif
-
-
NS_LOG_COMPONENT_DEFINE ("SpectrumValue");
@@ -285,7 +280,7 @@
while (it1 != m_values.end ())
{
- *it1 = pow (*it1, exp);
+ *it1 = std::pow (*it1, exp);
++it1;
}
}
@@ -299,7 +294,7 @@
while (it1 != m_values.end ())
{
- *it1 = pow (base, *it1);
+ *it1 = std::pow (base, *it1);
++it1;
}
}
@@ -313,7 +308,7 @@
while (it1 != m_values.end ())
{
- *it1 = log10 (*it1);
+ *it1 = std::log10 (*it1);
++it1;
}
}
@@ -340,7 +335,7 @@
while (it1 != m_values.end ())
{
- *it1 = log (*it1);
+ *it1 = std::log (*it1);
++it1;
}
}
@@ -355,7 +350,7 @@
s += (*it1) * (*it1);
++it1;
}
- return sqrt (s);
+ return std::sqrt (s);
}
--- a/src/spectrum/test/spectrum-ideal-phy-test.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/spectrum/test/spectrum-ideal-phy-test.cc Sat Sep 01 20:57:21 2012 +0200
@@ -28,14 +28,13 @@
#include <ns3/ptr.h>
#include <ns3/string.h>
#include <iostream>
-
+#include <ns3/math.h>
#include <ns3/spectrum-model-ism2400MHz-res1MHz.h>
#include <ns3/spectrum-model-300kHz-300GHz-log.h>
#include <ns3/wifi-spectrum-value-helper.h>
#include <ns3/single-model-spectrum-channel.h>
#include <ns3/waveform-generator.h>
#include <ns3/spectrum-analyzer.h>
-#include <ns3/log.h>
#include <string>
#include <iomanip>
#include <ns3/friis-spectrum-propagation-loss.h>
@@ -50,9 +49,6 @@
#include <ns3/on-off-helper.h>
#include <ns3/config.h>
-#ifdef __FreeBSD__
-#define log2(x) (log(x)/M_LN2)
-#endif
NS_LOG_COMPONENT_DEFINE ("SpectrumIdealPhyTest");
@@ -127,7 +123,7 @@
const double T = 290; // temperature in Kelvin
double noisePsdValue = k * T; // W/Hz
double lossLinear = (txPowerW) / (m_snrLinear * noisePsdValue * g_bandwidth);
- double lossDb = 10 * log10 (lossLinear);
+ double lossDb = 10 * std::log10 (lossLinear);
uint64_t phyRate = m_phyRate; // bps
uint32_t pktSize = 50; // bytes
--- a/src/spectrum/test/spectrum-value-test.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/spectrum/test/spectrum-value-test.cc Sat Sep 01 20:57:21 2012 +0200
@@ -24,7 +24,7 @@
#include <ns3/log.h>
#include <ns3/test.h>
#include <iostream>
-#include <math.h>
+#include <cmath>
#include "spectrum-test.h"
--- a/src/stats/model/basic-data-calculators.h Fri Aug 31 12:24:28 2012 +0200
+++ b/src/stats/model/basic-data-calculators.h Sat Sep 01 20:57:21 2012 +0200
@@ -50,7 +50,7 @@
double getMin () const { return m_min; }
double getMax () const { return m_max; }
double getMean () const { return m_meanCurr; }
- double getStddev () const { return sqrt (m_varianceCurr); }
+ double getStddev () const { return std::sqrt (m_varianceCurr); }
double getVariance () const { return m_varianceCurr; }
double getSqrSum () const { return m_squareTotal; }
--- a/src/stats/test/basic-data-calculators-test-suite.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/stats/test/basic-data-calculators-test-suite.cc Sat Sep 01 20:57:21 2012 +0200
@@ -18,7 +18,7 @@
* Author: Mitch Watrous (watrous@u.washington.edu)
*/
-#include <math.h>
+#include <cmath>
#include "ns3/test.h"
#include "ns3/basic-data-calculators.h"
@@ -91,7 +91,7 @@
{
variance = (count * sqrSum - sum * sum) / (count * (count - 1));
}
- stddev = sqrt (variance);
+ stddev = std::sqrt (variance);
// Test the calculator.
NS_TEST_ASSERT_MSG_EQ_TOL (calculator.getCount(), count, TOLERANCE, "Count value wrong");
@@ -169,7 +169,7 @@
{
variance = (count * sqrSum - sum * sum) / (count * (count - 1));
}
- stddev = sqrt (variance);
+ stddev = std::sqrt (variance);
// Test the calculator.
NS_TEST_ASSERT_MSG_EQ_TOL (calculator.getCount(), count, TOLERANCE, "Count value wrong");
@@ -247,7 +247,7 @@
{
variance = (count * sqrSum - sum * sum) / (count * (count - 1));
}
- stddev = sqrt (variance);
+ stddev = std::sqrt (variance);
// Test the calculator.
NS_TEST_ASSERT_MSG_EQ_TOL (calculator.getCount(), count, TOLERANCE, "Count value wrong");
--- a/src/tap-bridge/model/tap-bridge.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/tap-bridge/model/tap-bridge.cc Sat Sep 01 20:57:21 2012 +0200
@@ -39,9 +39,9 @@
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/un.h>
-#include <errno.h>
+#include <cerrno>
#include <limits>
-#include <stdlib.h>
+#include <cstdlib>
#include <unistd.h>
//
@@ -71,7 +71,7 @@
NS_LOG_FUNCTION_NOARGS ();
uint32_t bufferSize = 65536;
- uint8_t *buf = (uint8_t *)malloc (bufferSize);
+ uint8_t *buf = (uint8_t *)std::malloc (bufferSize);
NS_ABORT_MSG_IF (buf == 0, "malloc() failed");
NS_LOG_LOGIC ("Calling read on tap device fd " << m_fd);
@@ -79,7 +79,7 @@
if (len <= 0)
{
NS_LOG_INFO ("TapBridgeFdReader::DoRead(): done");
- free (buf);
+ std::free (buf);
buf = 0;
len = 0;
}
@@ -320,7 +320,7 @@
// socket for that purpose.
//
int sock = socket (PF_UNIX, SOCK_DGRAM, 0);
- NS_ABORT_MSG_IF (sock == -1, "TapBridge::CreateTap(): Unix socket creation error, errno = " << strerror (errno));
+ NS_ABORT_MSG_IF (sock == -1, "TapBridge::CreateTap(): Unix socket creation error, errno = " << std::strerror (errno));
//
// Bind to that socket and let the kernel allocate an endpoint
@@ -329,7 +329,7 @@
memset (&un, 0, sizeof (un));
un.sun_family = AF_UNIX;
int status = bind (sock, (struct sockaddr*)&un, sizeof (sa_family_t));
- NS_ABORT_MSG_IF (status == -1, "TapBridge::CreateTap(): Could not bind(): errno = " << strerror (errno));
+ NS_ABORT_MSG_IF (status == -1, "TapBridge::CreateTap(): Could not bind(): errno = " << std::strerror (errno));
NS_LOG_INFO ("Created Unix socket");
NS_LOG_INFO ("sun_family = " << un.sun_family);
NS_LOG_INFO ("sun_path = " << un.sun_path);
@@ -342,7 +342,7 @@
//
socklen_t len = sizeof (un);
status = getsockname (sock, (struct sockaddr*)&un, &len);
- NS_ABORT_MSG_IF (status == -1, "TapBridge::CreateTap(): Could not getsockname(): errno = " << strerror (errno));
+ NS_ABORT_MSG_IF (status == -1, "TapBridge::CreateTap(): Could not getsockname(): errno = " << std::strerror (errno));
//
// Now encode that socket name (family and path) as a string of hex digits
@@ -531,7 +531,7 @@
//
int st;
pid_t waited = waitpid (pid, &st, 0);
- NS_ABORT_MSG_IF (waited == -1, "TapBridge::CreateTap(): waitpid() fails, errno = " << strerror (errno));
+ NS_ABORT_MSG_IF (waited == -1, "TapBridge::CreateTap(): waitpid() fails, errno = " << std::strerror (errno));
NS_ASSERT_MSG (pid == waited, "TapBridge::CreateTap(): pid mismatch");
//
@@ -700,7 +700,7 @@
// buffer.
//
Ptr<Packet> packet = Create<Packet> (reinterpret_cast<const uint8_t *> (buf), len);
- free (buf);
+ std::free (buf);
buf = 0;
//
--- a/src/tap-bridge/model/tap-bridge.h Fri Aug 31 12:24:28 2012 +0200
+++ b/src/tap-bridge/model/tap-bridge.h Sat Sep 01 20:57:21 2012 +0200
@@ -19,7 +19,7 @@
#ifndef TAP_BRIDGE_H
#define TAP_BRIDGE_H
-#include <string.h>
+#include <cstring>
#include "ns3/address.h"
#include "ns3/net-device.h"
#include "ns3/node.h"
--- a/src/tap-bridge/model/tap-creator.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/tap-bridge/model/tap-creator.cc Sat Sep 01 20:57:21 2012 +0200
@@ -19,12 +19,12 @@
#include <unistd.h>
#include <stdint.h>
#include <string>
-#include <string.h> // for strerror
+#include <cstring> // for strerror
#include <iostream>
#include <iomanip>
#include <sstream>
-#include <stdlib.h>
-#include <errno.h>
+#include <cstdlib>
+#include <cerrno>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/types.h>
@@ -51,9 +51,9 @@
std::cout << __FILE__ << ": fatal error at line " << __LINE__ << ": " << __FUNCTION__ << "(): " << msg << std::endl; \
if (printErrno) \
{ \
- std::cout << " errno = " << errno << " (" << strerror (errno) << ")" << std::endl; \
+ std::cout << " errno = " << errno << " (" << std::strerror (errno) << ")" << std::endl; \
} \
- exit (-1);
+ std::exit (-1);
#define ABORT_IF(cond, msg, printErrno) \
if (cond) \
--- a/src/test/perf/perf-io.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/test/perf/perf-io.cc Sat Sep 01 20:57:21 2012 +0200
@@ -14,11 +14,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <time.h>
+#include <ctime>
#include <sys/time.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include <cstdio>
+#include <cstdlib>
#include <iostream>
#include <fstream>
@@ -28,7 +28,6 @@
#include "ns3/abort.h"
using namespace ns3;
-using namespace std;
static const uint64_t US_PER_NS = (uint64_t)1000;
static const uint64_t US_PER_SEC = (uint64_t)1000000;
@@ -49,7 +48,7 @@
{
for (uint32_t i = 0; i < n; ++i)
{
- if (fwrite (buffer, 1, size, file) != size)
+ if (std::fwrite (buffer, 1, size, file) != size)
{
NS_ABORT_MSG ("PerfFile(): fwrite error");
}
@@ -110,7 +109,7 @@
uint64_t et = GetRealtimeInNs () - start;
result = min (result, et);
stream.close ();
- cout << "."; std::cout.flush ();
+ std::cout << "."; std::cout.flush ();
}
cout << std::endl;
}
--- a/src/tools/examples/gnuplot-example.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/tools/examples/gnuplot-example.cc Sat Sep 01 20:57:21 2012 +0200
@@ -35,13 +35,11 @@
void Create2DPlotFile ()
{
- using namespace std;
-
- string fileNameWithNoExtension = "plot-2d";
- string graphicsFileName = fileNameWithNoExtension + ".png";
- string plotFileName = fileNameWithNoExtension + ".plt";
- string plotTitle = "2-D Plot";
- string dataTitle = "2-D Data";
+ std::string fileNameWithNoExtension = "plot-2d";
+ std::string graphicsFileName = fileNameWithNoExtension + ".png";
+ std::string plotFileName = fileNameWithNoExtension + ".plt";
+ std::string plotTitle = "2-D Plot";
+ std::string dataTitle = "2-D Data";
// Instantiate the plot and set its title.
Gnuplot plot (graphicsFileName);
@@ -84,7 +82,7 @@
plot.AddDataset (dataset);
// Open the plot file.
- ofstream plotFile (plotFileName.c_str());
+ std::ofstream plotFile (plotFileName.c_str());
// Write the plot file.
plot.GenerateOutput (plotFile);
@@ -103,13 +101,11 @@
void Create2DPlotWithErrorBarsFile ()
{
- using namespace std;
-
- string fileNameWithNoExtension = "plot-2d-with-error-bars";
- string graphicsFileName = fileNameWithNoExtension + ".png";
- string plotFileName = fileNameWithNoExtension + ".plt";
- string plotTitle = "2-D Plot With Error Bars";
- string dataTitle = "2-D Data With Error Bars";
+ std::string fileNameWithNoExtension = "plot-2d-with-error-bars";
+ std::string graphicsFileName = fileNameWithNoExtension + ".png";
+ std::string plotFileName = fileNameWithNoExtension + ".plt";
+ std::string plotTitle = "2-D Plot With Error Bars";
+ std::string dataTitle = "2-D Data With Error Bars";
// Instantiate the plot and set its title.
Gnuplot plot (graphicsFileName);
@@ -164,7 +160,7 @@
plot.AddDataset (dataset);
// Open the plot file.
- ofstream plotFile (plotFileName.c_str());
+ std::ofstream plotFile (plotFileName.c_str());
// Write the plot file.
plot.GenerateOutput (plotFile);
@@ -183,13 +179,11 @@
void Create3DPlotFile ()
{
- using namespace std;
-
- string fileNameWithNoExtension = "plot-3d";
- string graphicsFileName = fileNameWithNoExtension + ".png";
- string plotFileName = fileNameWithNoExtension + ".plt";
- string plotTitle = "3-D Plot";
- string dataTitle = "3-D Data";
+ std::string fileNameWithNoExtension = "plot-3d";
+ std::string graphicsFileName = fileNameWithNoExtension + ".png";
+ std::string plotFileName = fileNameWithNoExtension + ".plt";
+ std::string plotTitle = "3-D Plot";
+ std::string dataTitle = "3-D Data";
// Instantiate the plot and set its title.
Gnuplot plot (graphicsFileName);
@@ -250,7 +244,7 @@
plot.AddDataset (dataset);
// Open the plot file.
- ofstream plotFile (plotFileName.c_str());
+ std::ofstream plotFile (plotFileName.c_str());
// Write the plot file.
plot.GenerateOutput (plotFile);
--- a/src/tools/model/average.h Fri Aug 31 12:24:28 2012 +0200
+++ b/src/tools/model/average.h Sat Sep 01 20:57:21 2012 +0200
@@ -85,7 +85,7 @@
/// Unbiased estimate of variance
double Var () const { return m_varianceCalculator.getVariance ();}
/// Standard deviation
- double Stddev () const { return sqrt (Var ()); }
+ double Stddev () const { return std::sqrt (Var ()); }
//\}
/**
@@ -98,11 +98,11 @@
*/
//\{
/// Margin of error of the mean for 90% confidence level
- double Error90 () const { return 1.645 * sqrt (Var () / Count ()); }
+ double Error90 () const { return 1.645 * std::sqrt (Var () / Count ()); }
/// Margin of error of the mean for 95% confidence level
- double Error95 () const { return 1.960 * sqrt (Var () / Count ()); }
+ double Error95 () const { return 1.960 * std::sqrt (Var () / Count ()); }
/// Margin of error of the mean for 99% confidence level
- double Error99 () const { return 2.576 * sqrt (Var () / Count ()); }
+ double Error99 () const { return 2.576 * std::sqrt (Var () / Count ()); }
//\}
private:
--- a/src/tools/test/average-test-suite.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/tools/test/average-test-suite.cc Sat Sep 01 20:57:21 2012 +0200
@@ -18,7 +18,7 @@
* Author: Mitch Watrous (watrous@u.washington.edu)
*/
-#include <math.h>
+#include <cmath>
#include "ns3/test.h"
#include "ns3/average.h"
@@ -91,7 +91,7 @@
{
variance = (count * sqrSum - sum * sum) / (count * (count - 1));
}
- stddev = sqrt (variance);
+ stddev = std::sqrt (variance);
// Test the calculator.
NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Count (), count, TOLERANCE, "Count value wrong");
@@ -167,7 +167,7 @@
{
variance = (count * sqrSum - sum * sum) / (count * (count - 1));
}
- stddev = sqrt (variance);
+ stddev = std::sqrt (variance);
// Test the calculator.
NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Count (), count, TOLERANCE, "Count value wrong");
@@ -243,7 +243,7 @@
{
variance = (count * sqrSum - sum * sum) / (count * (count - 1));
}
- stddev = sqrt (variance);
+ stddev = std::sqrt (variance);
// Test the calculator.
NS_TEST_ASSERT_MSG_EQ_TOL (calculator.Count (), count, TOLERANCE, "Count value wrong");
--- a/src/topology-read/examples/topology-example-sim.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/topology-read/examples/topology-example-sim.cc Sat Sep 01 20:57:21 2012 +0200
@@ -39,12 +39,11 @@
#include <list>
using namespace ns3;
-using namespace std;
NS_LOG_COMPONENT_DEFINE ("TopologyCreationExperiment");
-static list<unsigned int> data;
+static std::list<unsigned int> data;
static void SinkRx (Ptr<const Packet> p, const Address &ad)
{
@@ -60,8 +59,8 @@
int main (int argc, char *argv[])
{
- string format ("Inet");
- string input ("src/topology-read/examples/Inet_small_toposample.txt");
+ std::string format ("Inet");
+ std::string input ("src/topology-read/examples/Inet_small_toposample.txt");
// Set up command line parameters used to control the experiment.
CommandLine cmd;
--- a/src/topology-read/model/inet-topology-reader.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/topology-read/model/inet-topology-reader.cc Sat Sep 01 20:57:21 2012 +0200
@@ -24,9 +24,9 @@
#include <sstream>
#include "ns3/log.h"
+
#include "inet-topology-reader.h"
-using namespace std;
namespace ns3 {
@@ -55,9 +55,9 @@
NodeContainer
InetTopologyReader::Read (void)
{
- ifstream topgen;
+ std::ifstream topgen;
topgen.open (GetFileName ().c_str ());
- map<string, Ptr<Node> > nodeMap;
+ std::map<std::string, Ptr<Node> > nodeMap;
NodeContainer nodes;
if ( !topgen.is_open () )
@@ -65,9 +65,9 @@
return nodes;
}
- string from;
- string to;
- string linkAttr;
+ std::string from;
+ std::string to;
+ std::string linkAttr;
int linksNumber = 0;
int nodesNumber = 0;
@@ -75,8 +75,8 @@
int totnode = 0;
int totlink = 0;
- istringstream lineBuffer;
- string line;
+ std::istringstream lineBuffer;
+ std::string line;
getline (topgen,line);
lineBuffer.str (line);
--- a/src/topology-read/model/orbis-topology-reader.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/topology-read/model/orbis-topology-reader.cc Sat Sep 01 20:57:21 2012 +0200
@@ -27,7 +27,6 @@
#include "ns3/log.h"
#include "orbis-topology-reader.h"
-using namespace std;
namespace ns3 {
@@ -56,9 +55,9 @@
NodeContainer
OrbisTopologyReader::Read (void)
{
- ifstream topgen;
+ std::ifstream topgen;
topgen.open (GetFileName ().c_str ());
- map<string, Ptr<Node> > nodeMap;
+ std::map<std::string, Ptr<Node> > nodeMap;
NodeContainer nodes;
if ( !topgen.is_open () )
@@ -66,10 +65,10 @@
return nodes;
}
- string from;
- string to;
- istringstream lineBuffer;
- string line;
+ std::string from;
+ std::string to;
+ std::istringstream lineBuffer;
+ std::string line;
int linksNumber = 0;
int nodesNumber = 0;
--- a/src/uan/examples/uan-cw-example.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/uan/examples/uan-cw-example.cc Sat Sep 01 20:57:21 2012 +0200
@@ -159,7 +159,7 @@
{
double x = urv->GetValue (0, m_boundary);
double y = urv->GetValue (0, m_boundary);
- double newr = sqrt ((x - m_boundary / 2.0) * (x - m_boundary / 2.0)
+ double newr = std::sqrt ((x - m_boundary / 2.0) * (x - m_boundary / 2.0)
+ (y - m_boundary / 2.0) * (y - m_boundary / 2.0));
rsum += newr;
minr = std::min (minr, newr);
--- a/src/uan/model/uan-mac-rc-gw.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/uan/model/uan-mac-rc-gw.cc Sat Sep 01 20:57:21 2012 +0200
@@ -383,7 +383,7 @@
double winSize = (double)(totalBytes) * 8.0 / dataRate + m_sifs.GetSeconds () * totalFrames + pDelay;
if (numRts == 0)
{
- winSize = (optA * exp (1.0) + 0.5) * 2.0 * 8.0 * m_rtsSize / (thAlpha * m_totalRate) + 2 * m_maxDelta.GetSeconds ();
+ winSize = (optA * std::exp (1.0) + 0.5) * 2.0 * 8.0 * m_rtsSize / (thAlpha * m_totalRate) + 2 * m_maxDelta.GetSeconds ();
}
double effWinSize = winSize - m_rtsSize * 8 / ctlRate - 2 * m_maxDelta.GetSeconds ();
@@ -559,7 +559,7 @@
{
double alpha;
- double lrae = m_rtsSize * 8.0*a*std::exp (1.0);
+ double lrae = m_rtsSize * 8.0 * a * std::exp (1.0);
if (totalFrames == 0)
{
@@ -574,11 +574,11 @@
double gamma = (w - u + v) / (2 * (u - totalFrames * m_sifs.GetSeconds () * m_totalRate));
- alpha = -gamma + sqrt (gamma * gamma + v / (u - totalFrames * m_sifs.GetSeconds () * m_totalRate));
+ alpha = -gamma + std::sqrt (gamma * gamma + v / (u - totalFrames * m_sifs.GetSeconds () * m_totalRate));
if (alpha < 0 || alpha > 1)
{
- alpha = -gamma - sqrt (gamma * gamma + v / (u - totalFrames * m_sifs.GetSeconds () * m_totalRate));
+ alpha = -gamma - std::sqrt (gamma * gamma + v / (u - totalFrames * m_sifs.GetSeconds () * m_totalRate));
}
}
NS_ASSERT_MSG (alpha > 0 && alpha < 1, "Error computing alpha. Alpha out of valid range!");
--- a/src/uan/model/uan-noise-model-default.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/uan/model/uan-noise-model-default.cc Sat Sep 01 20:57:21 2012 +0200
@@ -62,19 +62,19 @@
double turb, wind, ship, thermal;
double turbDb, windDb, shipDb, thermalDb, noiseDb;
- turbDb = 17.0 - 30.0 * log10 (fKhz);
- turb = pow (10.0, turbDb * 0.1);
+ turbDb = 17.0 - 30.0 * std::log10 (fKhz);
+ turb = std::pow (10.0, turbDb * 0.1);
- shipDb = 40.0 + 20.0 * (m_shipping - 0.5) + 26.0 * log10 (fKhz) - 60.0 * log10 (fKhz + 0.03);
- ship = pow (10.0, (shipDb * 0.1));
+ shipDb = 40.0 + 20.0 * (m_shipping - 0.5) + 26.0 * std::log10 (fKhz) - 60.0 * std::log10 (fKhz + 0.03);
+ ship = std::pow (10.0, (shipDb * 0.1));
- windDb = 50.0 + 7.5 * pow (m_wind, 0.5) + 20.0 * log10 (fKhz) - 40.0 * log10 (fKhz + 0.4);
- wind = pow (10.0, windDb * 0.1);
+ windDb = 50.0 + 7.5 * std::pow (m_wind, 0.5) + 20.0 * std::log10 (fKhz) - 40.0 * std::log10 (fKhz + 0.4);
+ wind = std::pow (10.0, windDb * 0.1);
- thermalDb = -15 + 20 * log10 (fKhz);
- thermal = pow (10, thermalDb * 0.1);
+ thermalDb = -15 + 20 * std::log10 (fKhz);
+ thermal = std::pow (10, thermalDb * 0.1);
- noiseDb = 10 * log10 (turb + ship + wind + thermal);
+ noiseDb = 10 * std::log10 (turb + ship + wind + thermal);
return noiseDb;
}
--- a/src/uan/model/uan-phy-gen.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/uan/model/uan-phy-gen.cc Sat Sep 01 20:57:21 2012 +0200
@@ -144,9 +144,9 @@
UanPdp::Iterator pit = pdp.GetBegin ();
for (; pit != pdp.GetEnd (); pit++)
{
- if (abs (pit->GetAmp ()) > maxAmp)
+ if (std::abs (pit->GetAmp ()) > maxAmp)
{
- maxAmp = abs (pit->GetAmp ());
+ maxAmp = std::abs (pit->GetAmp ());
maxTapDelay = pit->GetDelay ().GetSeconds ();
}
}
@@ -895,7 +895,7 @@
double
UanPhyGen::CalculateSinrDb (Ptr<Packet> pkt, Time arrTime, double rxPowerDb, UanTxMode mode, UanPdp pdp)
{
- double noiseDb = m_channel->GetNoiseDbHz ( (double) mode.GetCenterFreqHz () / 1000.0) + 10 * log10 (mode.GetBandwidthHz ());
+ double noiseDb = m_channel->GetNoiseDbHz ( (double) mode.GetCenterFreqHz () / 1000.0) + 10 * std::log10 (mode.GetBandwidthHz ());
return m_sinr->CalcSinrDb (pkt, arrTime, rxPowerDb, noiseDb, mode, pdp, m_transducer->GetArrivalList ());
}
@@ -924,12 +924,12 @@
double
UanPhyGen::DbToKp (double db)
{
- return pow (10, db / 10.0);
+ return std::pow (10, db / 10.0);
}
double
UanPhyGen::KpToDb (double kp)
{
- return 10 * log10 (kp);
+ return 10 * std::log10 (kp);
}
void
--- a/src/uan/model/uan-phy.h Fri Aug 31 12:24:28 2012 +0200
+++ b/src/uan/model/uan-phy.h Sat Sep 01 20:57:21 2012 +0200
@@ -77,7 +77,7 @@
*/
inline double DbToKp (double db) const
{
- return pow (10, db / 10.0);
+ return std::pow (10, db / 10.0);
}
/**
* \param kp value in kilopascals
@@ -86,7 +86,7 @@
*/
inline double KpToDb (double kp) const
{
- return 10 * log10 (kp);
+ return 10 * std::log10 (kp);
}
};
--- a/src/uan/model/uan-prop-model-thorp.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/uan/model/uan-prop-model-thorp.cc Sat Sep 01 20:57:21 2012 +0200
@@ -56,7 +56,7 @@
{
double dist = a->GetDistanceFrom (b);
- return m_SpreadCoef * 10.0 * log10 (dist)
+ return m_SpreadCoef * 10.0 * std::log10 (dist)
+ dist * GetAttenDbKm (mode.GetCenterFreqHz () / 1000.0);
}
--- a/src/uan/model/uan-prop-model.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/uan/model/uan-prop-model.cc Sat Sep 01 20:57:21 2012 +0200
@@ -213,9 +213,9 @@
for (uint32_t i = 0; i < GetNTaps (); i++)
{
- if (abs (m_taps[i].GetAmp ()) > maxAmp)
+ if (std::abs (m_taps[i].GetAmp ()) > maxAmp)
{
- maxAmp = abs (m_taps[i].GetAmp ());
+ maxAmp = std::abs (m_taps[i].GetAmp ());
maxTapIndex = i;
}
}
@@ -236,7 +236,7 @@
NS_ASSERT_MSG (GetNTaps () == 1, "Attempted to sum taps over time interval in "
"UanPdp with resolution 0 and multiple taps");
- return abs (m_taps[0].GetAmp ());
+ return std::abs (m_taps[0].GetAmp ());
}
uint32_t numTaps = static_cast<uint32_t> (duration.GetSeconds () / m_resolution.GetSeconds () + 0.5);
@@ -245,9 +245,9 @@
for (uint32_t i = 0; i < GetNTaps (); i++)
{
- if (abs (m_taps[i].GetAmp ()) > maxAmp)
+ if (std::abs (m_taps[i].GetAmp ()) > maxAmp)
{
- maxAmp = abs (m_taps[i].GetAmp ());
+ maxAmp = std::abs (m_taps[i].GetAmp ());
maxTapIndex = i;
}
}
@@ -259,7 +259,7 @@
for (uint32_t i = start; i < end; i++)
{
- sum += abs (m_taps[i].GetAmp ());
+ sum += std::abs (m_taps[i].GetAmp ());
}
return sum;
}
@@ -273,7 +273,7 @@
if (begin <= Seconds (0.0) && end >= Seconds (0.0))
{
- return abs (m_taps[0].GetAmp ());
+ return std::abs (m_taps[0].GetAmp ());
}
else
{
@@ -288,7 +288,7 @@
double sum = 0;
for (uint32_t i = stIndex; i < endIndex; i++)
{
- sum += abs (m_taps[i].GetAmp ());
+ sum += std::abs (m_taps[i].GetAmp ());
}
return sum;
--- a/src/visualizer/model/pyviz.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/visualizer/model/pyviz.cc Sat Sep 01 20:57:21 2012 +0200
@@ -18,7 +18,7 @@
* Author: Gustavo Carneiro <gjc@inescporto.pt>
*/
-#include <stdlib.h>
+#include <cstdlib>
#include "pyviz.h"
#include "ns3/simulator.h"
#include "ns3/config.h"
@@ -459,7 +459,7 @@
{
NS_LOG_FUNCTION (context << packet->GetUid ());
std::vector<std::string> splitPath = PathSplit (context);
- int nodeIndex = atoi (splitPath[1].c_str ());
+ int nodeIndex = std::atoi (splitPath[1].c_str ());
Ptr<Node> node = NodeList::GetNode (nodeIndex);
if (m_nodesOfInterest.find (nodeIndex) == m_nodesOfInterest.end ())
@@ -519,8 +519,8 @@
NS_LOG_FUNCTION (context << packet->GetUid () << *packet);
std::vector<std::string> splitPath = PathSplit (context);
- int nodeIndex = atoi (splitPath[1].c_str ());
- int devIndex = atoi (splitPath[3].c_str ());
+ int nodeIndex = std::atoi (splitPath[1].c_str ());
+ int devIndex = std::atoi (splitPath[3].c_str ());
Ptr<Node> node = NodeList::GetNode (nodeIndex);
Ptr<NetDevice> device = node->GetDevice (devIndex);
@@ -651,8 +651,8 @@
NS_LOG_FUNCTION (context << uid);
std::vector<std::string> splitPath = PathSplit (context);
- int nodeIndex = atoi (splitPath[1].c_str ());
- int devIndex = atoi (splitPath[3].c_str ());
+ int nodeIndex = std::atoi (splitPath[1].c_str ());
+ int devIndex = std::atoi (splitPath[3].c_str ());
// ---- statistics
NetDeviceStatistics &stats = FindNetDeviceStatistics (nodeIndex, devIndex);
--- a/src/wifi/model/block-ack-manager.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/wifi/model/block-ack-manager.cc Sat Sep 01 20:57:21 2012 +0200
@@ -103,7 +103,7 @@
void
BlockAckManager::CreateAgreement (const MgtAddBaRequestHeader *reqHdr, Mac48Address recipient)
{
- pair<Mac48Address, uint8_t> key (recipient, reqHdr->GetTid ());
+ std::pair<Mac48Address, uint8_t> key (recipient, reqHdr->GetTid ());
OriginatorBlockAckAgreement agreement (recipient, reqHdr->GetTid ());
agreement.SetStartingSequence (reqHdr->GetStartingSequence ());
/* for now we assume that originator doesn't use this field. Use of this field
@@ -121,8 +121,8 @@
}
agreement.SetState (OriginatorBlockAckAgreement::PENDING);
PacketQueue queue (0);
- pair<OriginatorBlockAckAgreement, PacketQueue> value (agreement, queue);
- m_agreements.insert (make_pair (key, value));
+ std::pair<OriginatorBlockAckAgreement, PacketQueue> value (agreement, queue);
+ m_agreements.insert (std::make_pair (key, value));
m_blockPackets (recipient, reqHdr->GetTid ());
}
@@ -132,7 +132,7 @@
AgreementsI it = m_agreements.find (std::make_pair (recipient, tid));
if (it != m_agreements.end ())
{
- for (list<PacketQueueI>::iterator i = m_retryPackets.begin (); i != m_retryPackets.end ();)
+ for (std::list<PacketQueueI>::iterator i = m_retryPackets.begin (); i != m_retryPackets.end ();)
{
if ((*i)->hdr.GetAddr1 () == recipient && (*i)->hdr.GetQosTid () == tid)
{
@@ -145,7 +145,7 @@
}
m_agreements.erase (it);
//remove scheduled bar
- for (list<Bar>::iterator i = m_bars.begin (); i != m_bars.end ();)
+ for (std::list<Bar>::iterator i = m_bars.begin (); i != m_bars.end ();)
{
if (i->recipient == recipient && i->tid == tid)
{
@@ -294,7 +294,7 @@
uint16_t currentSeq = 0;
if (ExistsAgreement (recipient, tid))
{
- list<PacketQueueI>::const_iterator it = m_retryPackets.begin ();
+ std::list<PacketQueueI>::const_iterator it = m_retryPackets.begin ();
while (it != m_retryPackets.end ())
{
if ((*it)->hdr.GetAddr1 () == recipient && (*it)->hdr.GetQosTid () == tid)
@@ -588,7 +588,7 @@
else
{
/* remove retry packet iterator if it's present in retry queue */
- for (list<PacketQueueI>::iterator it = m_retryPackets.begin (); it != m_retryPackets.end (); it++)
+ for (std::list<PacketQueueI>::iterator it = m_retryPackets.begin (); it != m_retryPackets.end (); it++)
{
if ((*it)->hdr.GetAddr1 () == j->second.first.GetPeer ()
&& (*it)->hdr.GetQosTid () == j->second.first.GetTid ()
--- a/src/wifi/model/block-ack-manager.h Fri Aug 31 12:24:28 2012 +0200
+++ b/src/wifi/model/block-ack-manager.h Sat Sep 01 20:57:21 2012 +0200
@@ -31,8 +31,6 @@
#include "ctrl-headers.h"
#include "qos-utils.h"
-using namespace std;
-
namespace ns3 {
class MgtAddBaResponseHeader;
--- a/src/wifi/model/dcf-manager.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/wifi/model/dcf-manager.cc Sat Sep 01 20:57:21 2012 +0200
@@ -21,7 +21,7 @@
#include "ns3/assert.h"
#include "ns3/log.h"
#include "ns3/simulator.h"
-#include <math.h>
+#include <cmath>
#include "dcf-manager.h"
#include "wifi-phy.h"
--- a/src/wifi/model/dsss-error-rate-model.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/wifi/model/dsss-error-rate-model.cc Sat Sep 01 20:57:21 2012 +0200
@@ -17,9 +17,10 @@
*
* Author: Gary Pei <guangyu.pei@boeing.com>
*/
+
#include "ns3/log.h"
#include "dsss-error-rate-model.h"
-#include <math.h>
+#include <cmath>
NS_LOG_COMPONENT_DEFINE ("DsssErrorRateModel");
@@ -33,17 +34,16 @@
double
DsssErrorRateModel::DqpskFunction (double x)
{
- return ((sqrt (2.0) + 1.0) / sqrt (8.0 * 3.1415926 * sqrt (2.0)))
- * (1.0 / sqrt (x))
- * exp ( -(2.0 - sqrt (2.0)) * x);
+ return ((std::sqrt (2.0) + 1.0) / std::sqrt (8.0 * 3.1415926 * std::sqrt (2.0)))
+ * (1.0 / std::sqrt (x)) * std::exp ( -(2.0 - std::sqrt (2.0)) * x);
}
double
DsssErrorRateModel::GetDsssDbpskSuccessRate (double sinr, uint32_t nbits)
{
double EbN0 = sinr * 22000000.0 / 1000000.0; // 1 bit per symbol with 1 MSPS
- double ber = 0.5 * exp (-EbN0);
- return pow ((1.0 - ber), nbits);
+ double ber = 0.5 * std::exp (-EbN0);
+ return std::pow ((1.0 - ber), nbits);
}
double
@@ -51,7 +51,7 @@
{
double EbN0 = sinr * 22000000.0 / 1000000.0 / 2.0; // 2 bits per symbol, 1 MSPS
double ber = DqpskFunction (EbN0);
- return pow ((1.0 - ber), nbits);
+ return std::pow ((1.0 - ber), nbits);
}
double
@@ -61,7 +61,7 @@
// symbol error probability
double EbN0 = sinr * 22000000.0 / 1375000.0 / 4.0;
double sep = SymbolErrorProb16Cck (4.0 * EbN0 / 2.0);
- return pow (1.0 - sep,nbits / 4.0);
+ return std::pow (1.0 - sep,nbits / 4.0);
#else
NS_LOG_WARN ("Running a 802.11b CCK Matlab model less accurate than GSL model");
// The matlab model
@@ -81,9 +81,9 @@
double a2 = 3.3092430025608586e-003;
double a3 = 4.1654372361004000e-001;
double a4 = 1.0288981434358866e+000;
- ber = a1 * exp (-(pow ((sinr - a2) / a3,a4)));
+ ber = a1 * std::exp (-std::pow ((sinr - a2) / a3, a4));
}
- return pow ((1.0 - ber), nbits);
+ return std::pow ((1.0 - ber), nbits);
#endif
}
@@ -94,7 +94,7 @@
// symbol error probability
double EbN0 = sinr * 22000000.0 / 1375000.0 / 8.0;
double sep = SymbolErrorProb256Cck (8.0 * EbN0 / 2.0);
- return pow (1.0 - sep,nbits / 8.0);
+ return std::pow (1.0 - sep, nbits / 8.0);
#else
NS_LOG_WARN ("Running a 802.11b CCK Matlab model less accurate than GSL model");
// The matlab model
@@ -118,7 +118,7 @@
double a6 = 2.2032715128698435e+000;
ber = (a1 * sinr * sinr + a2 * sinr + a3) / (sinr * sinr * sinr + a4 * sinr * sinr + a5 * sinr + a6);
}
- return pow ((1.0 - ber), nbits);
+ return std::pow ((1.0 - ber), nbits);
#endif
}
@@ -128,8 +128,8 @@
{
double beta = ((FunctionParameters *) params)->beta;
double n = ((FunctionParameters *) params)->n;
- double IntegralFunction = pow (2 * gsl_cdf_ugaussian_P (x + beta) - 1, n - 1)
- * exp (-x * x / 2.0) / sqrt (2.0 * M_PI);
+ double IntegralFunction = std::pow (2 * gsl_cdf_ugaussian_P (x + beta) - 1, n - 1)
+ * std::exp (-x * x / 2.0) / std::sqrt (2.0 * M_PI);
return IntegralFunction;
}
@@ -140,7 +140,7 @@
double error;
FunctionParameters params;
- params.beta = sqrt (2.0 * e2);
+ params.beta = std::sqrt (2.0 * e2);
params.n = 8.0;
gsl_integration_workspace * w = gsl_integration_workspace_alloc (1000);
@@ -161,7 +161,7 @@
double DsssErrorRateModel::SymbolErrorProb256Cck (double e1)
{
- return 1.0 - pow (1.0 - SymbolErrorProb16Cck (e1 / 2.0), 2.0);
+ return 1.0 - std::pow (1.0 - SymbolErrorProb16Cck (e1 / 2.0), 2.0);
}
#endif
--- a/src/wifi/model/ideal-wifi-manager.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/wifi/model/ideal-wifi-manager.cc Sat Sep 01 20:57:21 2012 +0200
@@ -17,11 +17,12 @@
*
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
+
#include "ideal-wifi-manager.h"
#include "wifi-phy.h"
#include "ns3/assert.h"
#include "ns3/double.h"
-#include <math.h>
+#include <cmath>
namespace ns3 {
--- a/src/wifi/model/nist-error-rate-model.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/wifi/model/nist-error-rate-model.cc Sat Sep 01 20:57:21 2012 +0200
@@ -17,6 +17,8 @@
*
* Author: Gary Pei <guangyu.pei@boeing.com>
*/
+
+#include <cmath>
#include "nist-error-rate-model.h"
#include "wifi-phy.h"
#include "ns3/log.h"
@@ -44,7 +46,7 @@
double
NistErrorRateModel::GetBpskBer (double snr) const
{
- double z = sqrt (snr);
+ double z = std::sqrt (snr);
double ber = 0.5 * erfc (z);
NS_LOG_INFO ("bpsk snr=" << snr << " ber=" << ber);
return ber;
@@ -52,7 +54,7 @@
double
NistErrorRateModel::GetQpskBer (double snr) const
{
- double z = sqrt (snr / 2.0);
+ double z = std::sqrt (snr / 2.0);
double ber = 0.5 * erfc (z);
NS_LOG_INFO ("qpsk snr=" << snr << " ber=" << ber);
return ber;
@@ -60,7 +62,7 @@
double
NistErrorRateModel::Get16QamBer (double snr) const
{
- double z = sqrt (snr / (5.0 * 2.0));
+ double z = std::sqrt (snr / (5.0 * 2.0));
double ber = 0.75 * 0.5 * erfc (z);
NS_LOG_INFO ("16-Qam" << " snr=" << snr << " ber=" << ber);
return ber;
@@ -68,7 +70,7 @@
double
NistErrorRateModel::Get64QamBer (double snr) const
{
- double z = sqrt (snr / (21.0 * 2.0));
+ double z = std::sqrt (snr / (21.0 * 2.0));
double ber = 7.0 / 12.0 * 0.5 * erfc (z);
NS_LOG_INFO ("64-Qam" << " snr=" << snr << " ber=" << ber);
return ber;
@@ -84,7 +86,7 @@
}
double pe = CalculatePe (ber, bValue);
pe = std::min (pe, 1.0);
- double pms = pow (1 - pe, nbits);
+ double pms = std::pow (1 - pe, nbits);
return pms;
}
double
@@ -98,58 +100,58 @@
}
double pe = CalculatePe (ber, bValue);
pe = std::min (pe, 1.0);
- double pms = pow (1 - pe, nbits);
+ double pms = std::pow (1 - pe, nbits);
return pms;
}
double
NistErrorRateModel::CalculatePe (double p, uint32_t bValue) const
{
- double D = sqrt (4.0 * p * (1.0 - p));
+ double D = std::sqrt (4.0 * p * (1.0 - p));
double pe = 1.0;
if (bValue == 1)
{
// code rate 1/2, use table 3.1.1
- pe = 0.5 * ( 36.0 * pow (D, 10.0)
- + 211.0 * pow (D, 12.0)
- + 1404.0 * pow (D, 14.0)
- + 11633.0 * pow (D, 16.0)
- + 77433.0 * pow (D, 18.0)
- + 502690.0 * pow (D, 20.0)
- + 3322763.0 * pow (D, 22.0)
- + 21292910.0 * pow (D, 24.0)
- + 134365911.0 * pow (D, 26.0)
+ pe = 0.5 * ( 36.0 * std::pow (D, 10.0)
+ + 211.0 * std::pow (D, 12.0)
+ + 1404.0 * std::pow (D, 14.0)
+ + 11633.0 * std::pow (D, 16.0)
+ + 77433.0 * std::pow (D, 18.0)
+ + 502690.0 * std::pow (D, 20.0)
+ + 3322763.0 * std::pow (D, 22.0)
+ + 21292910.0 * std::pow (D, 24.0)
+ + 134365911.0 * std::pow (D, 26.0)
);
}
else if (bValue == 2)
{
// code rate 2/3, use table 3.1.2
pe = 1.0 / (2.0 * bValue) *
- ( 3.0 * pow (D, 6.0)
- + 70.0 * pow (D, 7.0)
- + 285.0 * pow (D, 8.0)
- + 1276.0 * pow (D, 9.0)
- + 6160.0 * pow (D, 10.0)
- + 27128.0 * pow (D, 11.0)
- + 117019.0 * pow (D, 12.0)
- + 498860.0 * pow (D, 13.0)
- + 2103891.0 * pow (D, 14.0)
- + 8784123.0 * pow (D, 15.0)
+ ( 3.0 * std::pow (D, 6.0)
+ + 70.0 * std::pow (D, 7.0)
+ + 285.0 * std::pow (D, 8.0)
+ + 1276.0 * std::pow (D, 9.0)
+ + 6160.0 * std::pow (D, 10.0)
+ + 27128.0 * std::pow (D, 11.0)
+ + 117019.0 * std::pow (D, 12.0)
+ + 498860.0 * std::pow (D, 13.0)
+ + 2103891.0 * std::pow (D, 14.0)
+ + 8784123.0 * std::pow (D, 15.0)
);
}
else if (bValue == 3)
{
// code rate 3/4, use table 3.1.2
pe = 1.0 / (2.0 * bValue) *
- ( 42.0 * pow (D, 5.0)
- + 201.0 * pow (D, 6.0)
- + 1492.0 * pow (D, 7.0)
- + 10469.0 * pow (D, 8.0)
- + 62935.0 * pow (D, 9.0)
- + 379644.0 * pow (D, 10.0)
- + 2253373.0 * pow (D, 11.0)
- + 13073811.0 * pow (D, 12.0)
- + 75152755.0 * pow (D, 13.0)
- + 428005675.0 * pow (D, 14.0)
+ ( 42.0 * std::pow (D, 5.0)
+ + 201.0 * std::pow (D, 6.0)
+ + 1492.0 * std::pow (D, 7.0)
+ + 10469.0 * std::pow (D, 8.0)
+ + 62935.0 * std::pow (D, 9.0)
+ + 379644.0 * std::pow (D, 10.0)
+ + 2253373.0 * std::pow (D, 11.0)
+ + 13073811.0 * std::pow (D, 12.0)
+ + 75152755.0 * std::pow (D, 13.0)
+ + 428005675.0 * std::pow (D, 14.0)
);
}
else
@@ -170,7 +172,7 @@
}
double pe = CalculatePe (ber, bValue);
pe = std::min (pe, 1.0);
- double pms = pow (1 - pe, nbits);
+ double pms = std::pow (1 - pe, nbits);
return pms;
}
double
@@ -184,7 +186,7 @@
}
double pe = CalculatePe (ber, bValue);
pe = std::min (pe, 1.0);
- double pms = pow (1 - pe, nbits);
+ double pms = std::pow (1 - pe, nbits);
return pms;
}
double
--- a/src/wifi/model/wifi-mac-queue.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/wifi/model/wifi-mac-queue.cc Sat Sep 01 20:57:21 2012 +0200
@@ -19,6 +19,7 @@
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
* Author: Mirko Banchi <mk.banchi@gmail.com>
*/
+
#include "ns3/simulator.h"
#include "ns3/packet.h"
#include "ns3/uinteger.h"
@@ -26,8 +27,6 @@
#include "wifi-mac-queue.h"
#include "qos-blocked-destinations.h"
-using namespace std;
-
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (WifiMacQueue);
--- a/src/wifi/model/wifi-phy.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/wifi/model/wifi-phy.cc Sat Sep 01 20:57:21 2012 +0200
@@ -30,7 +30,7 @@
#include "ns3/uinteger.h"
#include "ns3/enum.h"
#include "ns3/trace-source-accessor.h"
-#include <math.h>
+#include <cmath>
NS_LOG_COMPONENT_DEFINE ("WifiPhy");
@@ -264,7 +264,7 @@
double numDataBitsPerSymbol = payloadMode.GetDataRate () * symbolDurationUs / 1e6;
// IEEE Std 802.11-2007, section 17.3.5.3, equation (17-11)
- uint32_t numSymbols = lrint (ceil ((16 + size * 8.0 + 6.0) / numDataBitsPerSymbol));
+ uint32_t numSymbols = lrint (std::ceil ((16 + size * 8.0 + 6.0) / numDataBitsPerSymbol));
// Add signal extension for ERP PHY
if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
@@ -282,7 +282,7 @@
NS_LOG_LOGIC (" size=" << size
<< " mode=" << payloadMode
<< " rate=" << payloadMode.GetDataRate () );
- return lrint (ceil ((size * 8.0) / (payloadMode.GetDataRate () / 1.0e6)));
+ return lrint (std::ceil ((size * 8.0) / (payloadMode.GetDataRate () / 1.0e6)));
default:
NS_FATAL_ERROR ("unsupported modulation class");
--- a/src/wifi/model/wifi-remote-station-manager.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/wifi/model/wifi-remote-station-manager.cc Sat Sep 01 20:57:21 2012 +0200
@@ -823,8 +823,8 @@
double
WifiRemoteStationInfo::CalculateAveragingCoefficient ()
{
- double retval = exp ((double)(m_lastUpdate.GetMicroSeconds () - Simulator::Now ().GetMicroSeconds ())
- / (double)m_memoryTime.GetMicroSeconds ());
+ double retval = std::exp ((double)(m_lastUpdate.GetMicroSeconds () - Simulator::Now ().GetMicroSeconds ())
+ / (double)m_memoryTime.GetMicroSeconds ());
m_lastUpdate = Simulator::Now ();
return retval;
}
--- a/src/wifi/model/yans-error-rate-model.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/wifi/model/yans-error-rate-model.cc Sat Sep 01 20:57:21 2012 +0200
@@ -17,6 +17,9 @@
*
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
+
+#include <cmath>
+
#include "yans-error-rate-model.h"
#include "wifi-phy.h"
#include "ns3/log.h"
@@ -44,13 +47,13 @@
double
YansErrorRateModel::Log2 (double val) const
{
- return log (val) / log (2.0);
+ return std::log (val) / std::log (2.0);
}
double
YansErrorRateModel::GetBpskBer (double snr, uint32_t signalSpread, uint32_t phyRate) const
{
double EbNo = snr * signalSpread / phyRate;
- double z = sqrt (EbNo);
+ double z = std::sqrt (EbNo);
double ber = 0.5 * erfc (z);
NS_LOG_INFO ("bpsk snr=" << snr << " ber=" << ber);
return ber;
@@ -59,9 +62,9 @@
YansErrorRateModel::GetQamBer (double snr, unsigned int m, uint32_t signalSpread, uint32_t phyRate) const
{
double EbNo = snr * signalSpread / phyRate;
- double z = sqrt ((1.5 * Log2 (m) * EbNo) / (m - 1.0));
- double z1 = ((1.0 - 1.0 / sqrt (m)) * erfc (z));
- double z2 = 1 - pow ((1 - z1), 2.0);
+ double z = std::sqrt ((1.5 * Log2 (m) * EbNo) / (m - 1.0));
+ double z1 = ((1.0 - 1.0 / std::sqrt (m)) * erfc (z));
+ double z2 = 1 - std::pow ((1 - z1), 2.0);
double ber = z2 / Log2 (m);
NS_LOG_INFO ("Qam m=" << m << " rate=" << phyRate << " snr=" << snr << " ber=" << ber);
return ber;
@@ -80,7 +83,7 @@
double
YansErrorRateModel::Binomial (uint32_t k, double p, uint32_t n) const
{
- double retval = Factorial (n) / (Factorial (k) * Factorial (n - k)) * pow (p, k) * pow (1 - p, n - k);
+ double retval = Factorial (n) / (Factorial (k) * Factorial (n - k)) * std::pow (p, k) * std::pow (1 - p, n - k);
return retval;
}
double
@@ -142,7 +145,7 @@
double pd = CalculatePd (ber, dFree);
double pmu = adFree * pd;
pmu = std::min (pmu, 1.0);
- double pms = pow (1 - pmu, nbits);
+ double pms = std::pow (1 - pmu, nbits);
return pms;
}
@@ -165,7 +168,7 @@
pd = CalculatePd (ber, dFree + 1);
pmu += adFreePlusOne * pd;
pmu = std::min (pmu, 1.0);
- double pms = pow (1 - pmu, nbits);
+ double pms = std::pow (1 - pmu, nbits);
return pms;
}
--- a/src/wifi/model/yans-wifi-phy.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/wifi/model/yans-wifi-phy.cc Sat Sep 01 20:57:21 2012 +0200
@@ -34,7 +34,7 @@
#include "ns3/pointer.h"
#include "ns3/net-device.h"
#include "ns3/trace-source-accessor.h"
-#include <math.h>
+#include <cmath>
NS_LOG_COMPONENT_DEFINE ("YansWifiPhy");
@@ -719,27 +719,27 @@
double
YansWifiPhy::DbToRatio (double dB) const
{
- double ratio = pow (10.0,dB / 10.0);
+ double ratio = std::pow (10.0, dB / 10.0);
return ratio;
}
double
YansWifiPhy::DbmToW (double dBm) const
{
- double mW = pow (10.0,dBm / 10.0);
+ double mW = std::pow (10.0, dBm / 10.0);
return mW / 1000.0;
}
double
YansWifiPhy::WToDbm (double w) const
{
- return 10.0 * log10 (w * 1000.0);
+ return 10.0 * std::log10 (w * 1000.0);
}
double
YansWifiPhy::RatioToDb (double ratio) const
{
- return 10.0 * log10 (ratio);
+ return 10.0 * std::log10 (ratio);
}
double
--- a/src/wimax/model/bs-net-device.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/wimax/model/bs-net-device.cc Sat Sep 01 20:57:21 2012 +0200
@@ -20,6 +20,8 @@
* <amine.ismail@UDcast.com>
*/
+#include <cmath>
+
#include "ns3/simulator.h"
#include "ns3/drop-tail-queue.h"
#include "ns3/node.h"
@@ -524,8 +526,8 @@
{
//setting DL/UL subframe allocation for this frame
uint32_t symbolsPerFrame = GetPhy ()->GetSymbolsPerFrame ();
- SetNrDlSymbols ((symbolsPerFrame / 2) - static_cast<uint32_t> (ceil (GetTtg ()*m_psDuration.GetSeconds ()/m_symbolDuration.GetSeconds ())));
- SetNrUlSymbols ((symbolsPerFrame / 2) - static_cast<uint32_t> (ceil (GetRtg ()*m_psDuration.GetSeconds ()/m_symbolDuration.GetSeconds ())));
+ SetNrDlSymbols ((symbolsPerFrame / 2) - static_cast<uint32_t> (std::ceil (GetTtg ()*m_psDuration.GetSeconds ()/m_symbolDuration.GetSeconds ())));
+ SetNrUlSymbols ((symbolsPerFrame / 2) - static_cast<uint32_t> (std::ceil (GetRtg ()*m_psDuration.GetSeconds ()/m_symbolDuration.GetSeconds ())));
m_frameStartTime = Simulator::Now ();
--- a/src/wimax/model/bs-scheduler-rtps.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/wimax/model/bs-scheduler-rtps.cc Sat Sep 01 20:57:21 2012 +0200
@@ -553,7 +553,7 @@
for (int i = 0; i < nbConnection; i++)
{
NS_LOG_INFO ("\t\tprevious symbolsRequired[" << i << "] = " << symbolsRequired[i]);
- symbolsRequired[i] = (uint32_t) floor (symbolsRequired[i] * delta);
+ symbolsRequired[i] = (uint32_t) std::floor (symbolsRequired[i] * delta);
totSymbolsRequired += symbolsRequired[i];
NS_LOG_INFO ("\t\tnew symbolsRequired[" << i << "] = " << symbolsRequired[i]);
}
--- a/src/wimax/model/bs-uplink-scheduler-mbqos.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/wimax/model/bs-uplink-scheduler-mbqos.cc Sat Sep 01 20:57:21 2012 +0200
@@ -195,7 +195,7 @@
// if backlogged < granted_bw then we don't need to provide granted_bw + min_bw in next window, but backlogged + min_bw
if (serviceFlow->GetRecord ()->GetBacklogged ()
- < ((uint32_t) abs (serviceFlow->GetRecord ()->GetBwSinceLastExpiry ())))
+ < ((uint32_t) std::abs (serviceFlow->GetRecord ()->GetBwSinceLastExpiry ())))
{
serviceFlow->GetRecord ()->SetBwSinceLastExpiry (-serviceFlow->GetRecord ()->GetBacklogged ());
}
--- a/src/wimax/model/bs-uplink-scheduler-rtps.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/wimax/model/bs-uplink-scheduler-rtps.cc Sat Sep 01 20:57:21 2012 +0200
@@ -572,7 +572,7 @@
for (int i = 0; i < nbAllocation; i++)
{
NS_LOG_INFO ("\t\tprevious allocSizeSymbols_[" << i << "] = " << allocSizeSymbols_[i]);
- allocSizeSymbols_[i] = (uint32_t) floor (allocSizeSymbols_[i] * delta);
+ allocSizeSymbols_[i] = (uint32_t) std::floor (allocSizeSymbols_[i] * delta);
totAllocSizeSymbols += allocSizeSymbols_[i];
NS_LOG_INFO ("\t\tnew allocSizeSymbols_[" << i << "] = " << allocSizeSymbols_[i]);
}
--- a/src/wimax/model/simple-ofdm-wimax-phy.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/wimax/model/simple-ofdm-wimax-phy.cc Sat Sep 01 20:57:21 2012 +0200
@@ -33,7 +33,8 @@
#include "simple-ofdm-wimax-channel.h"
#include "ns3/trace-source-accessor.h"
#include <string>
-#include <math.h>
+#include <cmath>
+
NS_LOG_COMPONENT_DEFINE ("SimpleOfdmWimaxPhy");
namespace ns3 {
@@ -344,7 +345,7 @@
{
uint8_t drop = 0;
- double Nwb = -114 + m_noiseFigure + 10 * log (GetBandwidth () / 1000000000.0) / 2.303;
+ double Nwb = -114 + m_noiseFigure + 10 * std::log (GetBandwidth () / 1000000000.0) / 2.303;
double SNR = rxPower - Nwb;
SNRToBlockErrorRateRecord * record = m_snrToBlockErrorRateManager->GetSNRToBlockErrorRateRecord (SNR, modulationType);
@@ -477,8 +478,8 @@
for (std::list<Ptr<Packet> >::iterator iter = packets.begin (); iter != packets.end (); ++iter)
{
Ptr<Packet> packet = *iter;
- uint8_t *pstart = (uint8_t*) malloc (packet->GetSize ());
- memset (pstart, 0, packet->GetSize ());
+ uint8_t *pstart = (uint8_t*) std::malloc (packet->GetSize ());
+ std::memset (pstart, 0, packet->GetSize ());
packet->CopyData (pstart, packet->GetSize ());
bvec temp (8);
temp.resize (0, 0);
@@ -492,7 +493,7 @@
}
j++;
}
- free (pstart);
+ std::free (pstart);
}
return buffer;
@@ -521,7 +522,7 @@
for (int l = 0; l < 8; l++)
{
bool bin = buffer.at (i + l);
- temp += (uint8_t)(bin * pow (2, (7 - l)));
+ temp += (uint8_t)(bin * std::pow (2, (7 - l)));
}
*(pstart + j) = temp;
@@ -711,14 +712,14 @@
{
Time transmissionTime = Seconds ((double)(GetNrBlocks (size, modulationType) * GetFecBlockSize (modulationType))
/ DoGetDataRate (modulationType));
- return (uint64_t) ceil (transmissionTime.GetSeconds () / GetSymbolDuration ().GetSeconds ());
+ return (uint64_t) std::ceil (transmissionTime.GetSeconds () / GetSymbolDuration ().GetSeconds ());
}
uint64_t
SimpleOfdmWimaxPhy::DoGetNrBytes (uint32_t symbols, WimaxPhy::ModulationType modulationType) const
{
Time transmissionTime = Seconds (symbols * GetSymbolDuration ().GetSeconds ());
- return (uint64_t) floor ((transmissionTime.GetSeconds () * DoGetDataRate (modulationType)) / 8);
+ return (uint64_t) std::floor ((transmissionTime.GetSeconds () * DoGetDataRate (modulationType)) / 8);
}
uint32_t
--- a/src/wimax/model/snr-to-block-error-rate-manager.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/wimax/model/snr-to-block-error-rate-manager.cc Sat Sep 01 20:57:21 2012 +0200
@@ -19,7 +19,7 @@
* <amine.ismail@udcast.com>
*/
-#include <string.h>
+#include <cstring>
#include "ns3/snr-to-block-error-rate-manager.h"
#include "ns3/snr-to-block-error-rate-record.h"
#include "default-traces.h"
@@ -38,7 +38,7 @@
m_recordModulation[i] = new std::vector<SNRToBlockErrorRateRecord*> ();
}
m_activateLoss = false;
- strcpy (m_traceFilePath,"DefaultTraces");
+ std::strcpy (m_traceFilePath,"DefaultTraces");
}
SNRToBlockErrorRateManager::~SNRToBlockErrorRateManager (void)
@@ -273,7 +273,7 @@
void
SNRToBlockErrorRateManager::SetTraceFilePath (char *traceFilePath)
{
- strcpy (m_traceFilePath, traceFilePath);
+ std::strcpy (m_traceFilePath, traceFilePath);
}
std::string
--- a/src/wimax/model/ss-link-manager.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/wimax/model/ss-link-manager.cc Sat Sep 01 20:57:21 2012 +0200
@@ -337,8 +337,8 @@
void
SSLinkManager::ResetRangingRequestCW (void)
{
- m_rangingCW = (uint8_t) pow ((double) 2,
- (double) m_ss->GetCurrentUcd ().GetRangingBackoffStart ()) - 1;
+ m_rangingCW = (uint8_t) std::pow ((double) 2,
+ (double) m_ss->GetCurrentUcd ().GetRangingBackoffStart ()) - 1;
}
void
--- a/src/wimax/model/ss-net-device.cc Fri Aug 31 12:24:28 2012 +0200
+++ b/src/wimax/model/ss-net-device.cc Sat Sep 01 20:57:21 2012 +0200
@@ -1230,7 +1230,7 @@
}
SetCurrentUcd (ucd);
- m_linkManager->SetRangingCW ((uint8_t) pow ((double) 2, (double) ucd.GetRangingBackoffStart ()) - 1); // initializing ranging CW
+ m_linkManager->SetRangingCW ((uint8_t) std::pow ((double) 2, (double) ucd.GetRangingBackoffStart ()) - 1); // initializing ranging CW
OfdmUcdChannelEncodings ucdChnlEncodings = ucd.GetChannelEncodings ();
std::vector<OfdmUlBurstProfile> ulBurstProfiles = ucd.GetUlBurstProfiles ();
--- a/src/wimax/model/wimax-tlv.h Fri Aug 31 12:24:28 2012 +0200
+++ b/src/wimax/model/wimax-tlv.h Sat Sep 01 20:57:21 2012 +0200
@@ -25,7 +25,7 @@
#define WIMAX_TLV_EXTENDED_LENGTH_MASK 0x80
#include "ns3/ipv4-address.h"
-#include <stdlib.h>
+#include <cstdlib>
#include "ns3/log.h"
#include "ns3/assert.h"
#include "ns3/uinteger.h"