[gnumeric] Gamma: simplify code a tiny bit.



commit 9730fe8a186ff9bd10253d44d21dfdba2a3c3356
Author: Morten Welinder <terra gnome org>
Date:   Tue Dec 17 13:56:54 2013 -0500

    Gamma: simplify code a tiny bit.

 ChangeLog      |    5 +++++
 src/sf-gamma.c |   11 ++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c705fd8..be319a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-12-17  Morten Welinder  <terra gnome org>
+
+       * src/sf-gamma.c (complex_gamma): Turn a complex division into a
+       multiplication.
+
 2013-12-14  Morten Welinder  <terra gnome org>
 
        * src/sf-gamma.c (complex_igamma): New function.
diff --git a/src/sf-gamma.c b/src/sf-gamma.c
index bba0783..f03510e 100644
--- a/src/sf-gamma.c
+++ b/src/sf-gamma.c
@@ -1196,7 +1196,7 @@ complex_gamma (complex_t *dst, complex_t const *src)
 
                complex_div (dst, &b, &a);
        } else {
-               complex_t zmh, zmhd2, zmhpg, f, g, p, q, pq;
+               complex_t zmh, zmhd2, zmhpg, f, f2, p, q, pq;
                int i;
 
                i = G_N_ELEMENTS(lanczos_num) - 1;
@@ -1215,11 +1215,12 @@ complex_gamma (complex_t *dst, complex_t const *src)
                complex_init (&zmhd2, zmh.re * 0.5, zmh.im * 0.5);
                complex_pow (&f, &zmhpg, &zmhd2);
 
-               complex_exp (&g, &zmh);
-               complex_div (&g, &f, &g);
-               complex_mul (&g, &g, &f);
+               zmh.re = -zmh.re; zmh.im = -zmh.im;
+               complex_exp (&f2, &zmh);
+               complex_mul (&f2, &f, &f2);
+               complex_mul (&f2, &f2, &f);
 
-               complex_mul (dst, &g, &pq);
+               complex_mul (dst, &f2, &pq);
        }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]