Skip to content

Commit

Permalink
Change FDIV to FMUL
Browse files Browse the repository at this point in the history
Some small performance improvement from safely changing a
couple floating point divides to floating point multiplies.
  • Loading branch information
heshpdx committed Sep 2, 2024
1 parent 8f4ba40 commit a3ae2ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/lib/alp/sls_basic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Contents: Some basic functions and types
namespace Sls {

const double pi=3.1415926535897932384626433832795;
const double invsqrttwo=0.707106769084930419921875;
const double const_val=1/sqrt(2.0*pi);
const long int quick_tests_trials_number=100;

Expand Down Expand Up @@ -189,7 +190,7 @@ namespace Sls {

static double normal_probability(double x_)
{
return 0.5*erfc(-sqrt(0.5)*x_);
return 0.5*erfc(-invsqrttwo*x_);
}

static double normal_probability(
Expand Down
3 changes: 2 additions & 1 deletion src/masking/tantan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,13 @@ Mask::Ranges mask(Letter *seq,
}

const float z = b * b2b + f.sum() * p_repeat_end;
const float zinv = 1.0/z;
b = b2b;
f = p_repeat_end;
Mask::Ranges ranges;

for (int i = len - 1; i >= 0; --i) {
const float pf = 1 - (pb[i] * b / z);
const float pf = 1 - (pb[i] * b * zinv);

if ((i & 15) == 15) {
const float s = scale[i / 16];
Expand Down

0 comments on commit a3ae2ae

Please sign in to comment.