]> git.donarmstrong.com Git - samtools.git/commitdiff
this is interesting. multiplication is much faster than division, at least on my Mac
authorHeng Li <lh3@live.co.uk>
Tue, 28 Sep 2010 20:57:49 +0000 (20:57 +0000)
committerHeng Li <lh3@live.co.uk>
Tue, 28 Sep 2010 20:57:49 +0000 (20:57 +0000)
kaln.c

diff --git a/kaln.c b/kaln.c
index 3cf8f71cdd1f4096cdb852104c38fa0ad98eb3a8..cf03d89349f649d739eb2a748301899aa51a963e 100644 (file)
--- a/kaln.c
+++ b/kaln.c
@@ -471,7 +471,7 @@ int ka_prob_glocal(const uint8_t *_ref, int l_ref, const uint8_t *_query, int l_
                // rescale
                s[i] = sum;
                set_u(_beg, bw, i, beg); set_u(_end, bw, i, end); _end += 2;
-               for (k = _beg; k <= _end; ++k) fi[k] /= sum;
+               for (k = _beg, sum = 1./sum; k <= _end; ++k) fi[k] *= sum;
        }
        { // f[l_query+1]
                double sum;
@@ -511,7 +511,7 @@ int ka_prob_glocal(const uint8_t *_ref, int l_ref, const uint8_t *_query, int l_
                }
                // rescale
                set_u(_beg, bw, i, beg); set_u(_end, bw, i, end); _end += 2;
-               for (k = _beg; k <= _end; ++k) bi[k] /= s[i];
+               for (k = _beg, y = 1./s[i]; k <= _end; ++k) bi[k] *= y;
        }
        { // b[0]
                int beg = 1, end = l_ref < bw + 1? l_ref : bw + 1;