Skip to content

Commit

Permalink
Stats remove ns3 nan symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredivey authored and edalm committed Dec 12, 2024
1 parent 5380877 commit 86fb3ce
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ This file is a best-effort approach to solving this issue; we will do our best b

* (applications) Deprecated attributes `RemoteAddress` and `RemotePort` in UdpClient, UdpTraceClient and UdpEchoClient. They have been combined into a single `Remote` attribute.
* (applications) Deprecated attributes `ThreeGppHttpClient::RemoteServerAddress` and `ThreeGppHttpClient::RemoteServerPort`. They have been combined into a single `ThreeGppHttpClient::Remote` attribute.
* (stats) Deprecated ns3::NaN and ns3::isNaN to use std::nan and std::isnan in their place
* (wifi) Added a new **ProtectedIfResponded** attribute to `FrameExchangeManager` to disable RTS/CTS protection for stations that have already responded to a frame requiring acknowledgment in the same TXOP, even if such frame had not been protected by RTS/CTS. The default value is true, even though it represents a change with respect to the previous behavior, because it is likely a more realistic choice.
* (wifi) Deprecated setters/getters of the {Ht,Vht,He}Configuration classes that trivially set/get member variables, which have been made public and hence accessible to users.

Expand Down
20 changes: 10 additions & 10 deletions src/stats/model/basic-data-calculators.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ MinMaxAvgTotalCalculator<T>::MinMaxAvgTotalCalculator()
m_total = 0;
m_squareTotal = 0;

m_meanCurr = NaN;
m_sCurr = NaN;
m_varianceCurr = NaN;
m_meanCurr = std::nan("");
m_sCurr = std::nan("");
m_varianceCurr = std::nan("");

m_meanPrev = NaN;
m_sPrev = NaN;
m_meanPrev = std::nan("");
m_sPrev = std::nan("");
}

template <typename T>
Expand Down Expand Up @@ -261,12 +261,12 @@ MinMaxAvgTotalCalculator<T>::Reset()
m_total = 0;
m_squareTotal = 0;

m_meanCurr = NaN;
m_sCurr = NaN;
m_varianceCurr = NaN;
m_meanCurr = std::nan("");
m_sCurr = std::nan("");
m_varianceCurr = std::nan("");

m_meanPrev = NaN;
m_sPrev = NaN;
m_meanPrev = std::nan("");
m_sPrev = std::nan("");
// end MinMaxAvgTotalCalculator::Reset
}

Expand Down
4 changes: 2 additions & 2 deletions src/stats/model/data-calculator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ using namespace ns3;

NS_LOG_COMPONENT_DEFINE("DataCalculator");

static double zero = 0;
const double ns3::NaN = zero / zero;
// NS_DEPRECATED_3_44
const double ns3::NaN = std::nan("");

//--------------------------------------------------------------
//----------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion src/stats/model/data-calculator.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,27 @@
#ifndef DATA_CALCULATOR_H
#define DATA_CALCULATOR_H

#include "ns3/deprecated.h"
#include "ns3/nstime.h"
#include "ns3/object.h"
#include "ns3/simulator.h"

namespace ns3
{
NS_DEPRECATED_3_44("Use std::nan(\"\") instead")
extern const double NaN; //!< Stored representation of NaN

/**
* @brief true if x is NaN
* @param x
* @return whether x is NaN
*/
NS_DEPRECATED_3_44("Use std::isnan() instead")

inline bool
isNaN(double x)
{
return x != x;
return std::isnan(x);
}

class DataOutputCallback;
Expand Down
14 changes: 7 additions & 7 deletions src/stats/model/omnet-data-output.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,31 +157,31 @@ OmnetDataOutput::OmnetOutputCallback::OutputStatistic(std::string context,
name = "\"\"";
}
(*m_scalar) << "statistic " << context << " " << name << std::endl;
if (!isNaN(statSum->getCount()))
if (!std::isnan(statSum->getCount()))
{
(*m_scalar) << "field count " << statSum->getCount() << std::endl;
}
if (!isNaN(statSum->getSum()))
if (!std::isnan(statSum->getSum()))
{
(*m_scalar) << "field sum " << statSum->getSum() << std::endl;
}
if (!isNaN(statSum->getMean()))
if (!std::isnan(statSum->getMean()))
{
(*m_scalar) << "field mean " << statSum->getMean() << std::endl;
}
if (!isNaN(statSum->getMin()))
if (!std::isnan(statSum->getMin()))
{
(*m_scalar) << "field min " << statSum->getMin() << std::endl;
}
if (!isNaN(statSum->getMax()))
if (!std::isnan(statSum->getMax()))
{
(*m_scalar) << "field max " << statSum->getMax() << std::endl;
}
if (!isNaN(statSum->getSqrSum()))
if (!std::isnan(statSum->getSqrSum()))
{
(*m_scalar) << "field sqrsum " << statSum->getSqrSum() << std::endl;
}
if (!isNaN(statSum->getStddev()))
if (!std::isnan(statSum->getStddev()))
{
(*m_scalar) << "field stddev " << statSum->getStddev() << std::endl;
}
Expand Down
10 changes: 5 additions & 5 deletions src/stats/model/sqlite-data-output.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,23 +158,23 @@ SqliteDataOutput::SqliteOutputCallback::OutputStatistic(std::string key,
NS_LOG_FUNCTION(this << key << variable << statSum);

OutputSingleton(key, variable + "-count", static_cast<double>(statSum->getCount()));
if (!isNaN(statSum->getSum()))
if (!std::isnan(statSum->getSum()))
{
OutputSingleton(key, variable + "-total", statSum->getSum());
}
if (!isNaN(statSum->getMax()))
if (!std::isnan(statSum->getMax()))
{
OutputSingleton(key, variable + "-max", statSum->getMax());
}
if (!isNaN(statSum->getMin()))
if (!std::isnan(statSum->getMin()))
{
OutputSingleton(key, variable + "-min", statSum->getMin());
}
if (!isNaN(statSum->getSqrSum()))
if (!std::isnan(statSum->getSqrSum()))
{
OutputSingleton(key, variable + "-sqrsum", statSum->getSqrSum());
}
if (!isNaN(statSum->getStddev()))
if (!std::isnan(statSum->getStddev()))
{
OutputSingleton(key, variable + "-stddev", statSum->getStddev());
}
Expand Down

0 comments on commit 86fb3ce

Please sign in to comment.