From fa45bd3be7eaec41a767e99591b69f2d543eddbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Sch=C3=A4fer?= <philipp.schaefer@akustik.rwth-aachen.de> Date: Fri, 28 Aug 2020 11:38:07 +0200 Subject: [PATCH] ITASpectrum - defined +=, *= and -= operators --- include/ITASpectrum.h | 8 ++++++++ src/ITASpectrum.cpp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/include/ITASpectrum.h b/include/ITASpectrum.h index 6fd2209..3e674d5 100644 --- a/include/ITASpectrum.h +++ b/include/ITASpectrum.h @@ -95,6 +95,14 @@ public: //! Set entire values of the spectrum by extrapolating range void SetValuesExtrapolated( const std::vector< float >& vfProvidedFrequencies, const std::vector< float >& vfProvidedValues, const int iStrategy = ITABase::InterpolationFunctions::NONE ); + + + CITASpectrum& operator*=(const float rhs); + CITASpectrum& operator*=(const CITASpectrum& rhs); + CITASpectrum& operator+=(const float rhs); + CITASpectrum& operator+=(const CITASpectrum& rhs); + CITASpectrum& operator-=(const float rhs); + CITASpectrum& operator-=(const CITASpectrum& rhs); protected: std::vector< float > m_vfValues; //!< Scalar spectrum values of any kind diff --git a/src/ITASpectrum.cpp b/src/ITASpectrum.cpp index f9c7599..61a8d73 100644 --- a/src/ITASpectrum.cpp +++ b/src/ITASpectrum.cpp @@ -194,6 +194,39 @@ void CITASpectrum::SetValuesExtrapolated( const std::vector< float >& vfProvided } } + +CITASpectrum& CITASpectrum::operator*=(const float rhs) +{ + this->Multiply(rhs); + return *this; +} +CITASpectrum& CITASpectrum::operator*=(const CITASpectrum& rhs) +{ + this->Multiply(rhs); + return *this; +} +CITASpectrum& CITASpectrum::operator+=(const float rhs) +{ + this->Add(rhs); + return *this; +} +CITASpectrum& CITASpectrum::operator+=(const CITASpectrum& rhs) +{ + this->Add(rhs); + return *this; +} +CITASpectrum& CITASpectrum::operator-=(const float rhs) +{ + (*this) += (-rhs); + return *this; +} +CITASpectrum& CITASpectrum::operator-=(const CITASpectrum& rhs) +{ + this->Sub(rhs); + return *this; +} + + std::ostream& operator<<( std::ostream& os, const CITASpectrum& oSpectrum ) { std::string sName = "Unnamed spectrum"; -- GitLab