[gnumeric] Cleanup.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Cleanup.
- Date: Mon, 18 Nov 2013 18:07:17 +0000 (UTC)
commit bfc8c91adae6899feedc82eee6a85474bf10f810
Author: Morten Welinder <terra gnome org>
Date: Mon Nov 18 13:06:47 2013 -0500
Cleanup.
plugins/fn-math/functions.c | 4 ++--
src/gutils.c | 22 ++++++++++++++++++++++
src/gutils.h | 3 +++
src/mathfunc.c | 19 -------------------
src/mathfunc.h | 3 ---
src/rangefunc.c | 2 ++
src/sf-gamma.c | 10 +++++-----
src/sf-gamma.h | 4 ++--
8 files changed, 36 insertions(+), 31 deletions(-)
---
diff --git a/plugins/fn-math/functions.c b/plugins/fn-math/functions.c
index 34fb8c3..8d31129 100644
--- a/plugins/fn-math/functions.c
+++ b/plugins/fn-math/functions.c
@@ -990,7 +990,7 @@ gnumeric_beta (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float a = value_get_as_float (argv[0]);
gnm_float b = value_get_as_float (argv[1]);
- return value_new_float (beta (a, b));
+ return value_new_float (gnm_beta (a, b));
}
/***************************************************************************/
@@ -1015,7 +1015,7 @@ gnumeric_betaln (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float b = value_get_as_float (argv[1]);
int sign;
- return value_new_float (lbeta3 (a, b, &sign));
+ return value_new_float (gnm_lbeta3 (a, b, &sign));
}
/***************************************************************************/
diff --git a/src/gutils.c b/src/gutils.c
index adf8275..9b54974 100644
--- a/src/gutils.c
+++ b/src/gutils.c
@@ -647,3 +647,25 @@ gnm_object_get_bool (gpointer o, const char *name)
g_object_get (o, name, &b, NULL);
return b;
}
+
+gint
+gnm_float_equal (gnm_float const *a, const gnm_float *b)
+{
+ return (*a == *b);
+}
+
+/* ------------------------------------------------------------------------- */
+
+guint
+gnm_float_hash (gnm_float const *d)
+{
+ int expt;
+ gnm_float mant = gnm_frexp (gnm_abs (*d), &expt);
+ guint h = ((guint)(0x80000000u * mant)) ^ expt;
+ if (*d >= 0)
+ h ^= 0x55555555;
+ return h;
+}
+
+/* ------------------------------------------------------------------------- */
+
diff --git a/src/gutils.h b/src/gutils.h
index 07c06e6..7a88408 100644
--- a/src/gutils.h
+++ b/src/gutils.h
@@ -44,6 +44,9 @@ void gnm_insert_meta_date (GODoc *doc, char const *name);
gboolean gnm_object_get_bool (gpointer o, const char *name);
+gint gnm_float_equal (gnm_float const *a, const gnm_float *b);
+guint gnm_float_hash (gnm_float const *d);
+
G_END_DECLS
#endif /* _GNM_GUTILS_H_ */
diff --git a/src/mathfunc.c b/src/mathfunc.c
index c5ef536..f625ec2 100644
--- a/src/mathfunc.c
+++ b/src/mathfunc.c
@@ -7869,25 +7869,6 @@ lgamma_r (double x, int *signp)
/* ------------------------------------------------------------------------- */
-gint
-gnm_float_equal (gnm_float const *a, const gnm_float *b)
-{
- return (*a == *b);
-}
-
-guint
-gnm_float_hash (gnm_float const *d)
-{
- int expt;
- gnm_float mant = gnm_frexp (gnm_abs (*d), &expt);
- guint h = ((guint)(0x80000000u * mant)) ^ expt;
- if (*d >= 0)
- h ^= 0x55555555;
- return h;
-}
-
-/* ------------------------------------------------------------------------- */
-
static gnm_float
gnm_owent_T1 (gnm_float h, gnm_float a, int order)
{
diff --git a/src/mathfunc.h b/src/mathfunc.h
index d5f3ab6..c224556 100644
--- a/src/mathfunc.h
+++ b/src/mathfunc.h
@@ -166,9 +166,6 @@ void gnm_matrix_multiply (GnmMatrix *C, const GnmMatrix *A, const GnmMatrix *B);
gboolean gnm_matrix_eigen (GnmMatrix const *m, GnmMatrix *EIG, gnm_float *eigenvalues);
/* ------------------------------------------------------------------------- */
-gint gnm_float_equal (gnm_float const *a, const gnm_float *b);
-guint gnm_float_hash (gnm_float const *d);
-
void mathfunc_init (void);
/* ------------------------------------------------------------------------- */
diff --git a/src/rangefunc.c b/src/rangefunc.c
index 44c7bb3..be46a83 100644
--- a/src/rangefunc.c
+++ b/src/rangefunc.c
@@ -13,10 +13,12 @@
#include "mathfunc.h"
#include "sf-gamma.h"
+#include "gutils.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "tools/analysis-tools.h"
+
int
gnm_range_count (G_GNUC_UNUSED gnm_float const *xs, int n, gnm_float *res)
{
diff --git a/src/sf-gamma.c b/src/sf-gamma.c
index 7cd0bd7..bf7fb5a 100644
--- a/src/sf-gamma.c
+++ b/src/sf-gamma.c
@@ -491,23 +491,23 @@ gnm_fact (gnm_float x)
/* ------------------------------------------------------------------------- */
/**
- * beta:
+ * gnm_beta:
* @a: a number
* @b: a number
*
* Returns: the Beta function evaluated at @a and @b.
*/
gnm_float
-beta (gnm_float a, gnm_float b)
+gnm_beta (gnm_float a, gnm_float b)
{
int sign;
- gnm_float absres = gnm_exp (lbeta3 (a, b, &sign));
+ gnm_float absres = gnm_exp (gnm_lbeta3 (a, b, &sign));
return sign == -1 ? -absres : absres;
}
/**
- * lbeta3:
+ * gnm_lbeta3:
* @a: a number
* @b: a number
* @sign: (out): the sign
@@ -518,7 +518,7 @@ beta (gnm_float a, gnm_float b)
* function can be too large for doubles.
*/
gnm_float
-lbeta3 (gnm_float a, gnm_float b, int *sign)
+gnm_lbeta3 (gnm_float a, gnm_float b, int *sign)
{
int sign_a, sign_b, sign_ab;
gnm_float ab = a + b;
diff --git a/src/sf-gamma.h b/src/sf-gamma.h
index 1f8a6c6..21bc872 100644
--- a/src/sf-gamma.h
+++ b/src/sf-gamma.h
@@ -11,8 +11,8 @@ gnm_float gnm_fact (gnm_float x);
int qfactf (gnm_float x, GnmQuad *mant, int *exp2);
gnm_float gnm_lbeta (gnm_float a, gnm_float b);
-gnm_float beta (gnm_float a, gnm_float b);
-gnm_float lbeta3 (gnm_float a, gnm_float b, int *sign);
+gnm_float gnm_beta (gnm_float a, gnm_float b);
+gnm_float gnm_lbeta3 (gnm_float a, gnm_float b, int *sign);
gnm_float pochhammer (gnm_float x, gnm_float n, gboolean give_log);
gnm_float combin (gnm_float n, gnm_float k);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]