Commit 06cab9ae authored by Michael Kohnen's avatar Michael Kohnen

added getEnergy function

parent 43b802ea
......@@ -207,7 +207,14 @@ public:
//! Zeichenkette mit den Werten zurckgeben
std::string toString();
//! Calculates the energy of the spectrum
/**
* Returns the energy of a HDFTSpectrum as a float
*/
float getEnergy() const;
private:
int m_iSize;
int m_iDFTSize;
......
......@@ -451,6 +451,16 @@ std::string ITAHDFTSpectrum::toString() {
return s;
}
float ITAHDFTSpectrum::getEnergy() const
{
float energy=0;
for (int i = 0; i < m_iSize; i++) {
float mags = cabsf(m_pfData[2 * i], m_pfData[2 * i + 1]);
energy += mags*mags;
}
return energy/((float)m_iSize);
}
void ITAHDFTSpectrum::copy( const ITAHDFTSpectrum* pSource )
{
// TODO: FastMath? Jetzt gibt es Probleme mit SIMD-Alignment?
......
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