void FHT::transform(float *p) { if (m_num == 8) transform8(p); else _transform(p, m_num, 0); }
void FastFourierTransformation::_transform( float *p, int n, int k ) { if(n == 8) { transform8( p + k ); return; } int i, j, ndiv2 = n / 2; float a, *t1, *t2, *t3, *t4, *ptab, *pp; for( i = 0, t1 = m_buf, t2 = m_buf + ndiv2, pp = &p[k]; i < ndiv2; i++ ) { *t1++ = *pp++, *t2++ = *pp++; } memcpy( p + k, m_buf, sizeof( float ) * n ); _transform( p, ndiv2, k ); _transform( p, ndiv2, k + ndiv2 ); j = m_num / ndiv2 - 1; t1 = m_buf; t2 = t1 + ndiv2; t3 = p + k + ndiv2; ptab = m_tab; pp = p + k; a = *ptab++ * *t3++; a += *ptab * *pp; ptab += j; *t1++ = *pp + a; *t2++ = *pp++ - a; for ( i = 1, t4 = p + k + n; i < ndiv2; i++, ptab += j ) { a = *ptab++ * *t3++; a += *ptab * *--t4; *t1++ = *pp + a; *t2++ = *pp++ - a; } memcpy( p + k, m_buf, sizeof(float) * n ); }
void FHT::_transform(float* p, int n, int k) { if (n == 8) { transform8(p + k); return; } int i, j, ndiv2 = n / 2; float a, *t1, *t2, *t3, *t4, *ptab, *pp; for (i = 0, t1 = buf_(), t2 = buf_() + ndiv2, pp = &p[k]; i < ndiv2; i++) *t1++ = *pp++, *t2++ = *pp++; std::copy(buf_(), buf_() + n, p + k); _transform(p, ndiv2, k); _transform(p, ndiv2, k + ndiv2); j = num_ / ndiv2 - 1; t1 = buf_(); t2 = t1 + ndiv2; t3 = p + k + ndiv2; ptab = tab_(); pp = p + k; a = *ptab++ * *t3++; a += *ptab * *pp; ptab += j; *t1++ = *pp + a; *t2++ = *pp++ - a; for (i = 1, t4 = p + k + n; i < ndiv2; i++, ptab += j) { a = *ptab++ * *t3++; a += *ptab * *--t4; *t1++ = *pp + a; *t2++ = *pp++ - a; } std::copy(buf_(), buf_() + n, p + k); }
void FHT::transform(float* p) { if (num_ == 8) transform8(p); else _transform(p, num_, 0); }