-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added windowing functions #61
base: master
Are you sure you want to change the base?
Conversation
c++ wrappers for windowing and complex options for the benchmark Signed-off-by: hayati ayguen <[email protected]>
|
||
|
||
#ifdef __cplusplus | ||
} |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
// 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; |
There was a problem hiding this comment.
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.
|
||
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(); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
const freal mag = rsqrt(cos_phi0 * cos_phi0 + sin_phi0 * sin_phi0); | ||
cos_phi0 /= mag; | ||
sin_phi0 /= mag; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
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.
for calculation of a spectrum, to be displayed,
usually a windowing is applied in time domain before calling fft() ..