|
|
| 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); |
|
|
| 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 |
} |
|
|
| 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.at (i)] * m_conversionMatrix.at (i); |
| 96 |
sum += (*fvit) * (*fromit); |
96 |
i++; |
| 97 |
++fvit; |
|
|
| 98 |
} |
97 |
} |
| 99 |
*tvit = sum; |
98 |
*tvit = sum; |
| 100 |
++tvit; |
99 |
++tvit; |