11#include "ns3/assert.h"
44 auto fromIt = txPsd->ConstValuesBegin();
45 auto toIt = convertedPsd->ValuesBegin();
46 auto fromBandIt = txSpectrumModel->Begin();
47 auto toBandIt = rxSpectrumModel->Begin();
49 while (fromBandIt != txSpectrumModel->End() && toBandIt != rxSpectrumModel->End())
51 if (fromBandIt->fh <= toBandIt->fl)
56 else if (toBandIt->fh <= fromBandIt->fl)
84 if (fromSpectrumModel->IsOrthogonal(*toSpectrumModel) ||
85 fromSpectrumModel->IsAligned(*toSpectrumModel))
92 m_conversionMatrix.reserve(fromSpectrumModel->GetNumBands() * toSpectrumModel->GetNumBands());
93 m_conversionColInd.reserve(fromSpectrumModel->GetNumBands() * toSpectrumModel->GetNumBands());
95 for (
auto toit = toSpectrumModel->Begin(); toit != toSpectrumModel->End(); ++toit)
98 auto bandInv = 1.0 / (toit->fh - toit->fl);
99 for (
auto fromit = fromSpectrumModel->Begin(); fromit != fromSpectrumModel->End(); ++fromit)
101 if (fromit->fh <= toit->fl || toit->fh <= fromit->fl)
106 const auto maxLow = (fromit->fl > toit->fl) ? fromit->fl : toit->fl;
107 const auto minHigh = (fromit->fh < toit->fh) ? fromit->fh : toit->fh;
108 const auto coeff = (minHigh - maxLow) * bandInv;
109 const auto c = (coeff > 1.0) ? 1.0 : coeff;
110 NS_LOG_LOGIC(
"(" << fromit->fl <<
"," << fromit->fh <<
")"
112 <<
"(" << toit->fl <<
"," << toit->fh <<
")"
145 auto tvit = tvvf->ValuesBegin();
Smart pointer class similar to boost::intrusive_ptr.
std::vector< double > m_conversionMatrix
matrix of conversion coefficients stored in Compressed Row Storage format
Ptr< const SpectrumModel > m_fromSpectrumModel
the SpectrumModel this SpectrumConverter instance can convert from
SpectrumConverter(Ptr< const SpectrumModel > fromSpectrumModel, Ptr< const SpectrumModel > toSpectrumModel)
Create a SpectrumConverter class that will be able to convert ValueVsFreq instances defined over one ...
Ptr< const SpectrumModel > m_toSpectrumModel
the SpectrumModel this SpectrumConverter instance can convert to
Ptr< SpectrumValue > Convert(Ptr< const SpectrumValue > vvf) const
Convert a particular ValueVsFreq instance to.
std::vector< size_t > m_conversionRowPtr
offset of rows in m_conversionMatrix
std::vector< size_t > m_conversionColInd
column of each non-zero element in m_conversionMatrix
#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_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Ptr< SpectrumValue > ConvertAlignedSpectrumModels(Ptr< const SpectrumValue > txPsd, Ptr< const SpectrumModel > txSpectrumModel, Ptr< const SpectrumModel > rxSpectrumModel)
This method converts the transmitted PSD from the TX SpectrumModel to the RX SpectrumModel in the cas...
Every class exported by the ns3 library is enclosed in the ns3 namespace.