# HG changeset patch # User Mathieu Lacage # Date 1231251931 -3600 # Node ID d5d8f079f3bd11d432fecd6ac8726feb09322411 # Parent c52c1814bd5e308f990b3d034fef4d0fb54ec4d3 fix coding style diff -r c52c1814bd5e -r d5d8f079f3bd src/devices/wifi/jakes-propagation-loss-model.cc --- a/src/devices/wifi/jakes-propagation-loss-model.cc Tue Jan 06 15:23:49 2009 +0100 +++ b/src/devices/wifi/jakes-propagation-loss-model.cc Tue Jan 06 15:25:31 2009 +0100 @@ -31,8 +31,6 @@ namespace ns3 { - - class JakesPropagationLossModel::PathCoefficients { public: @@ -68,9 +66,10 @@ JakesPropagationLossModel::PathCoefficients::~PathCoefficients () { - for (uint8_t i = 0; i < m_nRays; i++) { - delete [] m_phases[i]; - } + for (uint8_t i = 0; i < m_nRays; i++) + { + delete [] m_phases[i]; + } delete [] m_phases; } @@ -78,12 +77,14 @@ JakesPropagationLossModel::PathCoefficients::DoConstruct () { m_phases = new double*[m_nRays]; - for (uint8_t i = 0; i < m_nRays; i++) { - m_phases[i] = new double[m_nOscillators + 1]; - for (uint8_t j = 0; j <= m_nOscillators; j++) { - m_phases[i][j] = 2.0 * JakesPropagationLossModel::PI * m_jakes->m_variable.GetValue (); + for (uint8_t i = 0; i < m_nRays; i++) + { + m_phases[i] = new double[m_nOscillators + 1]; + for (uint8_t j = 0; j <= m_nOscillators; j++) + { + m_phases[i][j] = 2.0 * JakesPropagationLossModel::PI * m_jakes->m_variable.GetValue (); + } } - } m_lastUpdate = Simulator::Now (); } @@ -101,19 +102,23 @@ ComplexNumber coef= {0.0, 0.0}; ComplexNumber fading; double norm = 0.0; - for (uint8_t i = 0; i < m_nRays; i++) { - fading.real = 0.0; - fading.imag = 0.0; - for (uint8_t j = 0; j <= m_nOscillators; j++) { - m_phases[i][j] += 2.0 * JakesPropagationLossModel::PI * cos (2.0 * JakesPropagationLossModel::PI * j / N) * m_jakes->m_fd * interval.GetSeconds (); - m_phases[i][j] -= 2.0 * JakesPropagationLossModel::PI * floor (m_phases[i][j] / 2.0 / JakesPropagationLossModel::PI); - fading.real += m_jakes->m_amp[j].real * cos (m_phases[i][j]); - fading.imag += m_jakes->m_amp[j].imag * cos (m_phases[i][j]); - norm += sqrt(pow (m_jakes->m_amp[j].real, 2) + pow(m_jakes->m_amp[j].imag, 2)); - } + for (uint8_t i = 0; i < m_nRays; i++) + { + fading.real = 0.0; + fading.imag = 0.0; + for (uint8_t j = 0; j <= m_nOscillators; j++) + { + m_phases[i][j] += 2.0 * JakesPropagationLossModel::PI * + cos (2.0 * JakesPropagationLossModel::PI * j / N) * m_jakes->m_fd * interval.GetSeconds (); + m_phases[i][j] -= 2.0 * JakesPropagationLossModel::PI * + floor (m_phases[i][j] / 2.0 / JakesPropagationLossModel::PI); + fading.real += m_jakes->m_amp[j].real * cos (m_phases[i][j]); + fading.imag += m_jakes->m_amp[j].imag * cos (m_phases[i][j]); + norm += sqrt(pow (m_jakes->m_amp[j].real, 2) + pow(m_jakes->m_amp[j].imag, 2)); + } coef.real += fading.real; coef.imag += fading.imag; - } + } m_lastUpdate = Simulator::Now (); double k = sqrt (pow (coef.real, 2) + pow (coef.imag, 2)) / norm; NS_LOG_DEBUG ("Jakes coef "<< k << " (" << 10 * log10 (k) << "dB)"); @@ -136,7 +141,8 @@ MakeUintegerAccessor (&JakesPropagationLossModel::m_nRays), MakeUintegerChecker ()) .AddAttribute ("NumberOfOscillatorsPerRay", - "The number of oscillators to use by default for compute the coeficent for a given ray of a given path (default is 4)", + "The number of oscillators to use by default for compute the coeficent for a given ray of a given " + "path (default is 4)", UintegerValue (4), MakeUintegerAccessor (&JakesPropagationLossModel::m_nOscillators), MakeUintegerChecker ()) @@ -162,14 +168,16 @@ JakesPropagationLossModel::~JakesPropagationLossModel () { delete [] m_amp; - for (PathsList::iterator i = m_paths.end (); i != m_paths.begin (); i--) { - PathsSet *ps = *i; - for (DestinationList::iterator r = ps->receivers.begin (); r != ps->receivers.end (); r++) { - PathCoefficients *pc = *r; - delete pc; + for (PathsList::iterator i = m_paths.end (); i != m_paths.begin (); i--) + { + PathsSet *ps = *i; + for (DestinationList::iterator r = ps->receivers.begin (); r != ps->receivers.end (); r++) + { + PathCoefficients *pc = *r; + delete pc; + } + delete ps; } - delete ps; - } } void @@ -179,11 +187,12 @@ m_amp = new ComplexNumber[m_nOscillators + 1]; m_amp[0].real = 2.0 * sqrt(2.0 / N) * cos (PI / 4.0); m_amp[0].imag = 2.0 * sqrt(2.0 / N) * sin (PI / 4.0); - for (uint8_t i = 1; i <= m_nOscillators; i++) { - double beta = PI * (double)i / m_nOscillators; - m_amp[i].real = 4.0 * cos (beta) / sqrt(N); - m_amp[i].imag = 4.0 * sin (beta) / sqrt(N); - } + for (uint8_t i = 1; i <= m_nOscillators; i++) + { + double beta = PI * (double)i / m_nOscillators; + m_amp[i].real = 4.0 * cos (beta) / sqrt(N); + m_amp[i].imag = 4.0 * sin (beta) / sqrt(N); + } } void @@ -203,25 +212,29 @@ Ptr b) const { PathsList::iterator i = m_paths.end (); - while (i != m_paths.begin ()) { - i--; - PathsSet *ps = *i; - if (PeekPointer (ps->sender) == PeekPointer(a)) { - m_paths.erase (i); - m_paths.push_back (ps); - for (DestinationList::iterator r = ps->receivers.begin (); r != ps->receivers.end (); r++) { - PathCoefficients *pc = *r; - if (PeekPointer (pc->GetReceiver ()) == PeekPointer (b)) { - ps->receivers.erase (r); - ps->receivers.push_back (pc); - return pc->GetLoss (); - } - } - PathCoefficients *pc = new PathCoefficients (this, b, m_nRays, m_nOscillators); - ps->receivers.push_back (pc); - return pc->GetLoss (); + while (i != m_paths.begin ()) + { + i--; + PathsSet *ps = *i; + if (PeekPointer (ps->sender) == PeekPointer(a)) + { + m_paths.erase (i); + m_paths.push_back (ps); + for (DestinationList::iterator r = ps->receivers.begin (); r != ps->receivers.end (); r++) + { + PathCoefficients *pc = *r; + if (PeekPointer (pc->GetReceiver ()) == PeekPointer (b)) + { + ps->receivers.erase (r); + ps->receivers.push_back (pc); + return pc->GetLoss (); + } + } + PathCoefficients *pc = new PathCoefficients (this, b, m_nRays, m_nOscillators); + ps->receivers.push_back (pc); + return pc->GetLoss (); + } } - } PathsSet *ps = new PathsSet; ps->sender = a; PathCoefficients *pc = new PathCoefficients (this, b, m_nRays, m_nOscillators); @@ -230,6 +243,5 @@ return pc->GetLoss (); } - } // namespace ns3