A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
spectrum-model.cc
Go to the documentation of this file.
1
2
/*
3
* Copyright (c) 2009 CTTC
4
*
5
* SPDX-License-Identifier: GPL-2.0-only
6
*
7
* Author: Nicola Baldo <nbaldo@cttc.es>
8
*/
9
10
#include "
spectrum-model.h
"
11
12
#include <ns3/assert.h>
13
#include <ns3/log.h>
14
15
#include <cmath>
16
#include <cstddef>
17
18
namespace
ns3
19
{
20
21
NS_LOG_COMPONENT_DEFINE
(
"SpectrumModel"
);
22
23
bool
24
operator==
(
const
SpectrumModel
& lhs,
const
SpectrumModel
& rhs)
25
{
26
return
(lhs.
m_uid
== rhs.
m_uid
);
27
}
28
29
SpectrumModelUid_t
SpectrumModel::m_uidCount
= 0;
30
31
SpectrumModel::SpectrumModel
(
const
std::vector<double>& centerFreqs)
32
{
33
NS_ASSERT
(centerFreqs.size() > 1);
34
m_uid
= ++
m_uidCount
;
35
36
for
(
auto
it = centerFreqs.begin(); it != centerFreqs.end(); ++it)
37
{
38
BandInfo
e;
39
e.
fc
= *it;
40
if
(it == centerFreqs.begin())
41
{
42
double
delta = ((*(it + 1)) - (*it)) / 2;
43
e.
fl
= *it - delta;
44
e.
fh
= *it + delta;
45
}
46
else
if
(it == centerFreqs.end() - 1)
47
{
48
double
delta = ((*it) - (*(it - 1))) / 2;
49
e.
fl
= *it - delta;
50
e.
fh
= *it + delta;
51
}
52
else
53
{
54
e.
fl
= ((*it) + (*(it - 1))) / 2;
55
e.
fh
= ((*(it + 1)) + (*it)) / 2;
56
}
57
m_bands
.push_back(e);
58
}
59
}
60
61
SpectrumModel::SpectrumModel
(
const
Bands
& bands)
62
{
63
m_uid
= ++
m_uidCount
;
64
NS_LOG_INFO
(
"creating new SpectrumModel, m_uid="
<<
m_uid
);
65
m_bands
= bands;
66
}
67
68
SpectrumModel::SpectrumModel
(
Bands
&& bands)
69
: m_bands(
std
::move(bands))
70
{
71
m_uid
= ++
m_uidCount
;
72
NS_LOG_INFO
(
"creating new SpectrumModel, m_uid="
<<
m_uid
);
73
}
74
75
Bands::const_iterator
76
SpectrumModel::Begin
()
const
77
{
78
return
m_bands
.begin();
79
}
80
81
Bands::const_iterator
82
SpectrumModel::End
()
const
83
{
84
return
m_bands
.end();
85
}
86
87
size_t
88
SpectrumModel::GetNumBands
()
const
89
{
90
return
m_bands
.size();
91
}
92
93
SpectrumModelUid_t
94
SpectrumModel::GetUid
()
const
95
{
96
return
m_uid
;
97
}
98
99
bool
100
SpectrumModel::IsOrthogonal
(
const
SpectrumModel
& other)
const
101
{
102
for
(
auto
myIt =
Begin
(); myIt !=
End
(); ++myIt)
103
{
104
for
(
auto
otherIt = other.
Begin
(); otherIt != other.
End
(); ++otherIt)
105
{
106
if
(std::max(myIt->fl, otherIt->fl) < std::min(myIt->fh, otherIt->fh))
107
{
108
return
false
;
109
}
110
}
111
}
112
return
true
;
113
}
114
115
}
// namespace ns3
ns3::SpectrumModel
Set of frequency values implementing the domain of the functions in the Function Space defined by Spe...
Definition
spectrum-model.h:62
ns3::SpectrumModel::IsOrthogonal
bool IsOrthogonal(const SpectrumModel &other) const
Check if another SpectrumModels has bands orthogonal to our bands.
Definition
spectrum-model.cc:100
ns3::SpectrumModel::m_uidCount
static SpectrumModelUid_t m_uidCount
counter to assign m_uids
Definition
spectrum-model.h:136
ns3::SpectrumModel::m_uid
SpectrumModelUid_t m_uid
unique id for a given set of frequencies
Definition
spectrum-model.h:135
ns3::SpectrumModel::SpectrumModel
SpectrumModel(const std::vector< double > ¢erFreqs)
This constructs a SpectrumModel based on a given set of frequencies, which is assumed to be sorted by...
Definition
spectrum-model.cc:31
ns3::SpectrumModel::End
Bands::const_iterator End() const
Const Iterator to the model Bands container end.
Definition
spectrum-model.cc:82
ns3::SpectrumModel::GetNumBands
size_t GetNumBands() const
Definition
spectrum-model.cc:88
ns3::SpectrumModel::Begin
Bands::const_iterator Begin() const
Const Iterator to the model Bands container start.
Definition
spectrum-model.cc:76
ns3::SpectrumModel::GetUid
SpectrumModelUid_t GetUid() const
Definition
spectrum-model.cc:94
ns3::SpectrumModel::m_bands
Bands m_bands
Actual definition of frequency bands within this SpectrumModel.
Definition
spectrum-model.h:134
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition
assert.h:55
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition
log.h:264
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::operator==
bool operator==(const EventId &a, const EventId &b)
Definition
event-id.h:155
ns3::Bands
std::vector< BandInfo > Bands
Container of BandInfo.
Definition
spectrum-model.h:49
ns3::SpectrumModelUid_t
uint32_t SpectrumModelUid_t
Uid for SpectrumModels.
Definition
spectrum-model.h:52
std
STL namespace.
spectrum-model.h
ns3::BandInfo
The building block of a SpectrumModel.
Definition
spectrum-model.h:42
ns3::BandInfo::fc
double fc
center frequency
Definition
spectrum-model.h:44
ns3::BandInfo::fl
double fl
lower limit of subband
Definition
spectrum-model.h:43
ns3::BandInfo::fh
double fh
upper limit of subband
Definition
spectrum-model.h:45
src
spectrum
model
spectrum-model.cc
Generated on Mon Dec 2 2024 09:20:47 for ns-3 by
1.11.0