Skip to content

Commit

Permalink
powf() has to handle the general case of any floating-point x,y - as …
Browse files Browse the repository at this point in the history
…a result it's comparatively very slow in the special case y == 2. Replace with a simple multiply.
  • Loading branch information
9pt7 committed Feb 27, 2015
1 parent 6c4e435 commit 284edae
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mbelib.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ mbe_spectralAmpEnhance (mbe_parms * cur_mp)
Rm1 = 0;
for (l = 1; l <= cur_mp->L; l++)
{
Rm0 = Rm0 + powf (cur_mp->Ml[l], (float) 2);
Rm1 = Rm1 + (powf (cur_mp->Ml[l], (float) 2) * cosf (cur_mp->w0 * (float) l));
Rm0 = Rm0 + (cur_mp->Ml[l] * cur_mp->Ml[l]);
Rm1 = Rm1 + ((cur_mp->Ml[l] * cur_mp->Ml[l]) * cosf (cur_mp->w0 * (float) l));
}

R2m0 = powf (Rm0, (float) 2);
R2m1 = powf (Rm1, (float) 2);
R2m0 = (Rm0*Rm0);
R2m1 = (Rm1*Rm1);

for (l = 1; l <= cur_mp->L; l++)
{
Expand Down Expand Up @@ -166,7 +166,7 @@ mbe_spectralAmpEnhance (mbe_parms * cur_mp)
{
M = -M;
}
sum += powf (M, 2);
sum += (M*M);
}
if (sum == 0)
{
Expand Down

0 comments on commit 284edae

Please sign in to comment.