View | Details | Raw Unified | Return to bug 2464
Collapse All | Expand All

(-)a/src/spectrum/model/spectrum-converter.cc (-18 / +17 lines)
 Lines 39-48    Link Here 
39
  m_fromSpectrumModel = fromSpectrumModel;
39
  m_fromSpectrumModel = fromSpectrumModel;
40
  m_toSpectrumModel = toSpectrumModel;
40
  m_toSpectrumModel = toSpectrumModel;
41
41
42
  size_t rowPtr = 0;
42
  for (Bands::const_iterator toit = toSpectrumModel->Begin (); toit != toSpectrumModel->End (); ++toit)
43
  for (Bands::const_iterator toit = toSpectrumModel->Begin (); toit != toSpectrumModel->End (); ++toit)
43
    {
44
    {
44
      std::vector<double> coeffs;
45
      size_t colInd = 0;
45
46
      for (Bands::const_iterator fromit = fromSpectrumModel->Begin (); fromit != fromSpectrumModel->End (); ++fromit)
46
      for (Bands::const_iterator fromit = fromSpectrumModel->Begin (); fromit != fromSpectrumModel->End (); ++fromit)
47
        {
47
        {
48
          double c = GetCoefficient (*fromit, *toit);
48
          double c = GetCoefficient (*fromit, *toit);
 Lines 50-59    Link Here 
50
                            << " --> " <<
50
                            << " --> " <<
51
                        "(" << toit->fl << "," << toit->fh << ")"
51
                        "(" << toit->fl << "," << toit->fh << ")"
52
                            << " = " << c);
52
                            << " = " << c);
53
          coeffs.push_back (c);
53
          if (c > 0)
54
            {
55
              m_conversionMatrix.push_back (c);
56
              m_conversionColInd.push_back (colInd);
57
              rowPtr++;
58
            }
59
          colInd++;
54
        }
60
        }
55
61
      m_conversionRowPtr.push_back (rowPtr);
56
      m_conversionMatrix.push_back (coeffs);
57
    }
62
    }
58
63
59
}
64
}
 Lines 78-100    Link Here 
78
  Ptr<SpectrumValue> tvvf = Create<SpectrumValue> (m_toSpectrumModel);
83
  Ptr<SpectrumValue> tvvf = Create<SpectrumValue> (m_toSpectrumModel);
79
84
80
  Values::iterator tvit = tvvf->ValuesBegin ();
85
  Values::iterator tvit = tvvf->ValuesBegin ();
86
  size_t i = 0; // Index of conversion coefficient
81
87
82
88
  for (std::vector<size_t>::const_iterator convIt = m_conversionRowPtr.begin ();
83
  for (std::vector<std::vector<double> >::const_iterator toit = m_conversionMatrix.begin ();
89
       convIt != m_conversionRowPtr.end ();
84
       toit != m_conversionMatrix.end ();
90
       ++convIt)
85
       ++toit)
86
    {
91
    {
87
      NS_ASSERT (tvit != tvvf->ValuesEnd ());
88
      Values::const_iterator fvit = fvvf->ConstValuesBegin ();
89
90
      double sum = 0;
92
      double sum = 0;
91
      for (std::vector<double>::const_iterator fromit = toit->begin ();
93
      while (i < *convIt)
92
           fromit != toit->end ();
93
           ++fromit)
94
        {
94
        {
95
          NS_ASSERT (fvit != fvvf->ConstValuesEnd ());
95
          sum += (*fvvf)[m_conversionColInd[i]] * m_conversionMatrix[i];
96
          sum += (*fvit) * (*fromit);
96
          i++;
97
          ++fvit;
98
        }
97
        }
99
      *tvit = sum;
98
      *tvit = sum;
100
      ++tvit;
99
      ++tvit;
(-)a/src/spectrum/model/spectrum-converter.h (-1 / +4 lines)
 Lines 78-84    Link Here 
78
   */
78
   */
79
  double GetCoefficient (const BandInfo& from, const BandInfo& to) const;
79
  double GetCoefficient (const BandInfo& from, const BandInfo& to) const;
80
80
81
  std::vector<std::vector<double> > m_conversionMatrix; //!< matrix of conversion coefficients
81
  std::vector<double> m_conversionMatrix; //!< matrix of conversion coefficients stored in Compressed Row Storage format
82
  std::vector<size_t> m_conversionRowPtr; //!< offset of rows in m_conversionMatrix
83
  std::vector<size_t> m_conversionColInd; //!< column of each non-zero element in m_conversionMatrix
84
82
  Ptr<const SpectrumModel> m_fromSpectrumModel;  //!<  the SpectrumModel this SpectrumConverter instance can convert from
85
  Ptr<const SpectrumModel> m_fromSpectrumModel;  //!<  the SpectrumModel this SpectrumConverter instance can convert from
83
  Ptr<const SpectrumModel> m_toSpectrumModel;    //!<  the SpectrumModel this SpectrumConverter instance can convert to
86
  Ptr<const SpectrumModel> m_toSpectrumModel;    //!<  the SpectrumModel this SpectrumConverter instance can convert to
84
87

Return to bug 2464