Commit dda795f9 authored by Armin Erraji's avatar Armin Erraji

Added function Sub() in ITASpectrum and changed function names in ITAISO9613.

parent d52c746c
......@@ -67,10 +67,10 @@ namespace ITABase
* \param fHumidity Relative humidity [%]
* \param fStaticPressure Static air pressure [kPa]
*/
ITA_BASE_API void AtmosphericAbsorptionLevel( ITABase::CThirdOctaveDecibelMagnitudeSpectrum& oA_atm_dB, double dDistance, double dTemperature, double dHumidity, double dStaticPressure = 101.325);
ITA_BASE_API void AtmosphericAbsorption( ITABase::CThirdOctaveDecibelMagnitudeSpectrum& oA_atm_dB, double dDistance, double dTemperature, double dHumidity, double dStaticPressure = 101.325);
//! Calculates the atmospheric absorption in linear factors (instead of decibels)
ITA_BASE_API void AtmosphericAbsorptionFactor( ITABase::CThirdOctaveFactorMagnitudeSpectrum& oA_atm_factor, double dDistance, double dTemperature, double dHumidity, double dStaticPressure = 101.325);
ITA_BASE_API void AtmosphericAbsorption( ITABase::CThirdOctaveFactorMagnitudeSpectrum& oA_atm_factor, double dDistance, double dTemperature, double dHumidity, double dStaticPressure = 101.325);
}
}
......
......@@ -78,6 +78,9 @@ public:
//! Element-wise addition
void Add( const CITASpectrum& oOtherSpetrum );
//! Element-wise subtraction
void Sub(const CITASpectrum& oOtherSpetrum);
//! Compare equality of values (ignores center frequencies, but requires matching number of bands)
bool CompareEqualValues( const CITASpectrum& oOtherSpectrum, const float fThreshold = 10.0e-10 ) const;
......
......@@ -68,13 +68,13 @@ double ISO9613::AtmosphericAbsorptionFactor(double dFrequency, double dDistance,
{
double dAirAbsorptionDecibel = AtmosphericAbsorptionLevel(dFrequency, dDistance, dTemperature, dHumidity, dStaticPressure);
//Factor of absorped signal energy [0:1]
//Factor of absorbed signal energy [0:1]
double dAirAbsorptionFactor = 1 - pow(10, -dAirAbsorptionDecibel / 10.0);
return dAirAbsorptionFactor;
}
void ISO9613::AtmosphericAbsorptionLevel(ITABase::CThirdOctaveDecibelMagnitudeSpectrum& oA_atm_dB, double dDistance, double dTemperature, double dHumidity, double dStaticPressure/*= 101.325*/)
void ISO9613::AtmosphericAbsorption(ITABase::CThirdOctaveDecibelMagnitudeSpectrum& oA_atm_dB, double dDistance, double dTemperature, double dHumidity, double dStaticPressure/*= 101.325*/)
{
// loop over all frequencies
for (int i = 0; i < oA_atm_dB.GetNumBands(); i++)
......@@ -85,7 +85,7 @@ void ISO9613::AtmosphericAbsorptionLevel(ITABase::CThirdOctaveDecibelMagnitudeSp
}
}
void ISO9613::AtmosphericAbsorptionFactor(ITABase::CThirdOctaveFactorMagnitudeSpectrum& oA_atm_factor, double dDistance, double dTemperature, double dHumidity, double dStaticPressure/*= 101.325*/)
void ISO9613::AtmosphericAbsorption(ITABase::CThirdOctaveFactorMagnitudeSpectrum& oA_atm_factor, double dDistance, double dTemperature, double dHumidity, double dStaticPressure/*= 101.325*/)
{
// loop over all frequencies and converting from decibel to a factor between 0 and 1
for (int i = 0; i < oA_atm_factor.GetNumBands(); i++)
......
......@@ -96,13 +96,22 @@ void CITASpectrum::Add( const float fSummand )
m_vfValues[ n ] += fSummand;
}
void CITASpectrum::Add( const CITASpectrum& oOtherSpetrum )
void CITASpectrum::Add( const CITASpectrum& oOtherSpectrum )
{
if( GetNumBands() != oOtherSpetrum.GetNumBands() )
if( GetNumBands() != oOtherSpectrum.GetNumBands() )
ITA_EXCEPT1( INVALID_PARAMETER, "Number of bands mismatching, can not add spectra" );
for( size_t n = 0; n < m_vfValues.size(); n++ )
m_vfValues[ n ] += oOtherSpetrum[ int( n ) ];
m_vfValues[ n ] += oOtherSpectrum[ int( n ) ];
}
void CITASpectrum::Sub(const CITASpectrum& oOtherSpectrum)
{
if (GetNumBands() != oOtherSpectrum.GetNumBands())
ITA_EXCEPT1(INVALID_PARAMETER, "Number of bands mismatching, can not sub spectra");
for (size_t n = 0; n < m_vfValues.size(); n++)
m_vfValues[n] -= oOtherSpectrum[int(n)];
}
bool CITASpectrum::CompareEqualValues( const CITASpectrum& oOtherSpectrum, const float fThreshold /*= 10.0e-10 */ ) const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment