Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void COM::ReadAndFuse(uint8_t nCapacityBit, uint8_t nValueSelectOption, uint8_t nSDSelectOption, uint8_t nSlot) {
- int32_t nValue, nStdDev;
- bool bFirst = true;
- if (m_anSlotListPerCapacity[nCapacityBit] & (1UL << nSlot)) {
- nValue = m_cSPIProtocol.ReadLongViaSPI(nValueSelectOption, nSlot);
- nStdDev = m_cSPIProtocol.ReadLongViaSPI(nSDSelectOption, nSlot);
- if (bFirst) {
- bFirst = false;
- m_anDataArray[nValueSelectOption] = nValue;
- m_anDataArray[nSDSelectOption] = nStdDev;
- }
- else {
- int32_t nFusedSigma;
- m_anDataArray[nValueSelectOption] = FuseValues(m_anDataArray[nValueSelectOption],
- m_anDataArray[nSDSelectOption],
- nValue,
- nStdDev,
- nFusedSigma);
- m_anDataArray[nSDSelectOption] = nFusedSigma;
- }
- }
- }
- int32_t COM::FuseValues(int32_t nZ1, int32_t nSigma1, int32_t nZ2, int32_t nSigma2, int32_t &nFusedSigma) {
- int32_t nVariance1 = pow(nSigma1, 2);
- int32_t nVariance2 = pow(nSigma2, 2);
- int32_t nSumVariances = nVariance1 + nVariance2;
- int32_t nFusedVariance = (nVariance1 * nVariance2) / (nVariance1 + nVariance2);
- nFusedSigma = isqrt(nFusedVariance);
- return ((nVariance2 / nSumVariances) * nZ1 + (nVariance1 / nSumVariances) * nZ2);
- }
Advertisement
Add Comment
Please, Sign In to add comment