Hello,
Im trying to understand the following legacy code:
Not sure why the following array indexing is made so complicated.
Could some experts explain help me understand the logic behind
And this table is being filled in the folowing function:
thanks a lot
pdk
Im trying to understand the following legacy code:
Not sure why the following array indexing is made so complicated.
Could some experts explain help me understand the logic behind
Code:
COverlapTableRSSI& GetTableRSSI(bool b15kHzA, bool b15kHzB, bool bNormalA, bool bNormalB, int nNonMbsfnA, int nNonMbsfnB, int numTxA, int numTxB) const
{
ASSERT_ONCE(m_pTablesRSSI);
const size_t iSA = GetSubCarrierTypeIndex(b15kHzA);
const size_t iSB = GetSubCarrierTypeIndex(b15kHzB);
const size_t iCA = GetCyclicPrefixTypeIndex(bNormalA);
const size_t iCB = GetCyclicPrefixTypeIndex(bNormalB);
const size_t iNA = GetNonMbsfnIndex(nNonMbsfnA);
const size_t iNB = GetNonMbsfnIndex(nNonMbsfnB);
const size_t iTA = GetTxTypeIndex(numTxA);
const size_t iTB = GetTxTypeIndex(numTxB);
const size_t index = iSA + GetNumSubCarrierTypes()
* ( iSB + GetNumSubCarrierTypes()
* ( iCA + GetNumCyclicPrefixTypes()
* ( iCB + GetNumCyclicPrefixTypes()
* ( iNA + GetNumNonMbsfnTypes()
* ( iNB + GetNumNonMbsfnTypes()
* ( iTA + GetNumTxTypes()
* ( iTB )))))));
ASSERT_ONCE(index >= 0 && index < GetSizeRSSI());
return m_pTablesRSSI[index];
And this table is being filled in the folowing function:
Code:
void Populate()
{
if ( m_pTables || m_pTablesRSSI ) return; // Already populated !!!
#ifdef DUMP_TABLES_TO_FILE
std::ofstream os;
os.open("C:\\SubFramePatterns.txt", std::ios::out);
#endif
const size_t iSize = GetSize();
m_pTables = new COverlapTable[iSize];
const size_t iSizeRSSI = GetSizeRSSI();
m_pTablesRSSI = new COverlapTableRSSI[iSizeRSSI];
CSubFrame A, B; // Working objects for calculating overlaps in the loop (Think of A as victim and B as aggressor)
// We should only ever be comparing subframes on the same carrier with the same SYNC Id and the same subframe number
for (size_t iSA = 0; iSA < GetNumSubCarrierTypes(); iSA++)
{
const bool b15kHzA = Get15kHz(iSA);
for (size_t iSB = 0; iSB < GetNumSubCarrierTypes(); iSB++)
{
const bool b15kHzB = Get15kHz(iSB);
for (size_t iCA = 0; iCA < GetNumCyclicPrefixTypes(); iCA++)
{
const bool bNormalA = GetNormalCP(iCA);
for (size_t iCB = 0; iCB < GetNumCyclicPrefixTypes(); iCB++)
{
const bool bNormalB = GetNormalCP(iCB);
for (size_t iNonA = 0; iNonA < GetNumNonMbsfnTypes(); iNonA++)
{
const int nNonMbsfnA = GetNonMbsfn(iNonA);
for (size_t iNonB = 0; iNonB < GetNumNonMbsfnTypes(); iNonB++)
{
const int nNonMbsfnB = GetNonMbsfn(iNonB);
for (size_t iTA = 0; iTA < GetNumTxTypes(); iTA++)
{
const int numTxA = GetNumTx(iTA);
for (size_t iTB = 0; iTB < GetNumTxTypes(); iTB++)
{
const int numTxB = GetNumTx(iTB);
// Keep the PCI loops innermost so we can do the averaging easily
for (int iPciA = 0; iPciA < 6; iPciA++) // Omit "Unknown" PCI index of 6
{
A.Make(b15kHzA, bNormalA, iPciA, numTxA, nNonMbsfnA);
#ifdef DUMP_TABLES_TO_FILE
if ( iPciA == 0 && iSB == 0 && iCB == 0 && iNonB == 0 && iTB == 0 ) A.Dump(os); // Only dump for PCI0 and skip loops through B
#endif
for (int iPciB = 0; iPciB < 6; iPciB++)
{
B.Make(b15kHzB, bNormalB, iPciB, numTxB, nNonMbsfnB);
COverlapTable& s = GetTable(b15kHzA, b15kHzB, bNormalA, bNormalB, nNonMbsfnA, nNonMbsfnB, numTxA, numTxB, iPciA, iPciB);
COverlapTable& avgA = GetTable(b15kHzA, b15kHzB, bNormalA, bNormalB, nNonMbsfnA, nNonMbsfnB, numTxA, numTxB, PCI_UNKNOWN, iPciB); // B has known PCI. A is unknown, so sum over all 6 possibilities
COverlapTable& avgB = GetTable(b15kHzA, b15kHzB, bNormalA, bNormalB, nNonMbsfnA, nNonMbsfnB, numTxA, numTxB, iPciA, PCI_UNKNOWN); // A has known PCI. B is unknown, so sum over all 6 possibilities
COverlapTable& avgAB = GetTable(b15kHzA, b15kHzB, bNormalA, bNormalB, nNonMbsfnA, nNonMbsfnB, numTxA, numTxB, PCI_UNKNOWN, PCI_UNKNOWN); // A and B have unknown PCI so sum over all 36 possibilities
if ( iPciA == iPciB == 0 ) // We can calculate RSSI overlap tables just for this case w.l.o.g.
{
COverlapTableRSSI& t = GetTableRSSI(b15kHzA, b15kHzB, bNormalA, bNormalB, nNonMbsfnA, nNonMbsfnB, numTxA, numTxB);
t.Populate(A,B);
}
s.Populate(A, B);
avgA += s;
avgB += s;
avgAB += s;
}
}
// Now do the final scaling to get averages over PCIs for the special case when a PCI is unknown
const double dSixth = 1.0 / 6.0;
for (int iPci = 0; iPci < GetNumPciTypes(); iPci++) // Includes "Unknown" PCI index of PCI_UNKNOWN
{
GetTable(b15kHzA, b15kHzB, bNormalA, bNormalB, nNonMbsfnA, nNonMbsfnB, numTxA, numTxB, iPci, PCI_UNKNOWN) *= dSixth;
GetTable(b15kHzA, b15kHzB, bNormalA, bNormalB, nNonMbsfnA, nNonMbsfnB, numTxA, numTxB, PCI_UNKNOWN, iPci) *= dSixth;
}
}
}
}
}
}
}
}
}
pdk