Skip to content

Conversation

@hayguen
Copy link
Collaborator

@hayguen hayguen commented Apr 10, 2022

for calculation of a spectrum, to be displayed,
usually a windowing is applied in time domain before calling fft() ..

c++ wrappers for windowing and complex options for the benchmark

Signed-off-by: hayati ayguen <h_ayguen@web.de>
@hayguen hayguen requested review from marton78 and unevens April 10, 2022 14:08


#ifdef __cplusplus
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this } probably doesn't belong here?

{
case pf_winRect:
break;
default: assert(0);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it permitted that the default case is not at the end? i have never seen it before. even if it is, i suggest moving it to the end as it's surprising otherwise.

Comment on lines +210 to +216
// pre-calculate small trig table - hope this allow SIMD parallelization
freal2 *trig_tab = wp.trig_tab;
const freal phi_inc = TWO_PI / wp.N_div;
const freal c_inc_cos = rcos(phi_inc);
const freal c_inc_sin = rsin(phi_inc);
freal cos_phi = trig_tab[0][0] = c1;
freal sin_phi = trig_tab[0][1] = c0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original PFFFT Author Julien Pommier also wrote some fast SIMD functions for sin / cos / exp / log, based on Cephes. You could consider using them, but probably this is not time sensitive code.

https://github.com/RJVB/sse_mathfun


const struct pf_windowing_param_tag * pf_window_alloc(pf_windowing_T win, int N, int w0, freal alpha)
{
struct pf_windowing_param_tag * param = new pf_windowing_param_t();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't gcc warn about using new in C instead of malloc? Well, it should.


void pf_window_free(const struct pf_windowing_param_tag * param)
{
delete param;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, this should be free.

pafWin[n] *= a0;
}
break;
default: assert(0);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to the end please

}
}
break;
default: assert(0);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Comment on lines +479 to +481
const freal mag = rsqrt(cos_phi0 * cos_phi0 + sin_phi0 * sin_phi0);
cos_phi0 /= mag;
sin_phi0 /= mag;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const freal mag = rsqrt(cos_phi0 * cos_phi0 + sin_phi0 * sin_phi0);
cos_phi0 /= mag;
sin_phi0 /= mag;
const freal inv_mag = 1.0f/rsqrt(cos_phi0 * cos_phi0 + sin_phi0 * sin_phi0);
cos_phi0 *= inv_mag;
sin_phi0 *= inv_mag;

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... if only C had a built-in for inverse square roots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants