11#include "ns3/assert.h"
36 m_bands.reserve(centerFreqs.size());
37 for (
auto it = centerFreqs.begin(); it != centerFreqs.end(); ++it)
41 if (it == centerFreqs.begin())
43 double delta = ((*(it + 1)) - (*it)) / 2;
47 else if (it == centerFreqs.end() - 1)
49 double delta = ((*it) - (*(it - 1))) / 2;
55 e.
fl = ((*it) + (*(it - 1))) / 2;
56 e.
fh = ((*(it + 1)) + (*it)) / 2;
90 auto currentFh = it->fh;
91 for (++it; it !=
m_bands.cend(); ++it)
93 if (it->fl > currentFh + std::numeric_limits<double>::epsilon())
98 if (it->fh > currentFh)
105 const auto bandSize =
m_bands.cbegin()->fh -
m_bands.cbegin()->fl;
108 std::all_of(
m_bands.cbegin(),
m_bands.cend(), [bandSize](
const auto& b) {
109 return std::abs((b.fh - b.fl) - bandSize) <= std::numeric_limits<double>::epsilon();
145 for (
auto myIt =
Begin(); myIt !=
End(); ++myIt)
147 for (
auto otherIt = other.
Begin(); otherIt != other.
End(); ++otherIt)
149 if (!(myIt->fh <= otherIt->fl || otherIt->fh <= myIt->fl))
164 const auto bandBandWidth =
m_bands.begin()->fh -
m_bands.begin()->fl;
165 const auto otherBandWidth = other.
m_bands.begin()->fh - other.
m_bands.begin()->fl;
166 return std::abs(bandBandWidth - otherBandWidth) <= std::numeric_limits<double>::epsilon();
169 auto otherIt = other.
Begin();
170 while (myIt !=
End() && otherIt != other.
End())
172 while (otherIt != other.
End() && otherIt->fh <= myIt->fl)
176 if (otherIt == other.
End())
180 if (std::abs(myIt->fl - otherIt->fl) > std::numeric_limits<double>::epsilon() ||
181 std::abs(myIt->fh - otherIt->fh) > std::numeric_limits<double>::epsilon())
void InitModel()
Initialize internal variables.
bool IsOrthogonal(const SpectrumModel &other) const
Check if another SpectrumModel has bands orthogonal to our bands.
static SpectrumModelUid_t m_uidCount
counter to assign m_uids
bool m_contiguousBands
Whether the bands are contiguous (i.e., no gap between adjacent bands).
SpectrumModelUid_t m_uid
unique id for a given set of frequencies
SpectrumModel(const std::vector< double > ¢erFreqs)
This constructs a SpectrumModel based on a given set of frequencies, which is assumed to be sorted by...
Bands::const_iterator End() const
Const Iterator to the model Bands container end, i.e.
size_t GetNumBands() const
bool IsAligned(const SpectrumModel &other) const
Check if another SpectrumModel is aligned with our bands.
Bands::const_iterator Begin() const
Const Iterator to the model Bands container start, i.e.
SpectrumModelUid_t GetUid() const
bool m_uniqueBandSize
Whether all bands have the same size.
Bands m_bands
Actual definition of frequency bands within this SpectrumModel.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool operator==(const EventId &a, const EventId &b)
std::vector< BandInfo > Bands
Container of BandInfo.
uint32_t SpectrumModelUid_t
Uid for SpectrumModels.
The building block of a SpectrumModel.
double fc
center frequency
double fl
lower limit of subband
double fh
upper limit of subband