Commit bfc8c91a authored by Morten Welinder's avatar Morten Welinder

Cleanup.

parent cc6bd2f2
...@@ -990,7 +990,7 @@ gnumeric_beta (GnmFuncEvalInfo *ei, GnmValue const * const *argv) ...@@ -990,7 +990,7 @@ gnumeric_beta (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float a = value_get_as_float (argv[0]); gnm_float a = value_get_as_float (argv[0]);
gnm_float b = value_get_as_float (argv[1]); 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) ...@@ -1015,7 +1015,7 @@ gnumeric_betaln (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float b = value_get_as_float (argv[1]); gnm_float b = value_get_as_float (argv[1]);
int sign; int sign;
return value_new_float (lbeta3 (a, b, &sign)); return value_new_float (gnm_lbeta3 (a, b, &sign));
} }
/***************************************************************************/ /***************************************************************************/
......
...@@ -647,3 +647,25 @@ gnm_object_get_bool (gpointer o, const char *name) ...@@ -647,3 +647,25 @@ gnm_object_get_bool (gpointer o, const char *name)
g_object_get (o, name, &b, NULL); g_object_get (o, name, &b, NULL);
return b; 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;
}
/* ------------------------------------------------------------------------- */
...@@ -44,6 +44,9 @@ void gnm_insert_meta_date (GODoc *doc, char const *name); ...@@ -44,6 +44,9 @@ void gnm_insert_meta_date (GODoc *doc, char const *name);
gboolean gnm_object_get_bool (gpointer o, const char *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 G_END_DECLS
#endif /* _GNM_GUTILS_H_ */ #endif /* _GNM_GUTILS_H_ */
...@@ -7869,25 +7869,6 @@ lgamma_r (double x, int *signp) ...@@ -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 static gnm_float
gnm_owent_T1 (gnm_float h, gnm_float a, int order) gnm_owent_T1 (gnm_float h, gnm_float a, int order)
{ {
......
...@@ -166,9 +166,6 @@ void gnm_matrix_multiply (GnmMatrix *C, const GnmMatrix *A, const GnmMatrix *B); ...@@ -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); 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); void mathfunc_init (void);
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
......
...@@ -13,10 +13,12 @@ ...@@ -13,10 +13,12 @@
#include "mathfunc.h" #include "mathfunc.h"
#include "sf-gamma.h" #include "sf-gamma.h"
#include "gutils.h"
#include <math.h> #include <math.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "tools/analysis-tools.h" #include "tools/analysis-tools.h"
int int
gnm_range_count (G_GNUC_UNUSED gnm_float const *xs, int n, gnm_float *res) gnm_range_count (G_GNUC_UNUSED gnm_float const *xs, int n, gnm_float *res)
{ {
......
...@@ -491,23 +491,23 @@ gnm_fact (gnm_float x) ...@@ -491,23 +491,23 @@ gnm_fact (gnm_float x)
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/** /**
* beta: * gnm_beta:
* @a: a number * @a: a number
* @b: a number * @b: a number
* *
* Returns: the Beta function evaluated at @a and @b. * Returns: the Beta function evaluated at @a and @b.
*/ */
gnm_float gnm_float
beta (gnm_float a, gnm_float b) gnm_beta (gnm_float a, gnm_float b)
{ {
int sign; 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; return sign == -1 ? -absres : absres;
} }
/** /**
* lbeta3: * gnm_lbeta3:
* @a: a number * @a: a number
* @b: a number * @b: a number
* @sign: (out): the sign * @sign: (out): the sign
...@@ -518,7 +518,7 @@ beta (gnm_float a, gnm_float b) ...@@ -518,7 +518,7 @@ beta (gnm_float a, gnm_float b)
* function can be too large for doubles. * function can be too large for doubles.
*/ */
gnm_float 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; int sign_a, sign_b, sign_ab;
gnm_float ab = a + b; gnm_float ab = a + b;
......
...@@ -11,8 +11,8 @@ gnm_float gnm_fact (gnm_float x); ...@@ -11,8 +11,8 @@ gnm_float gnm_fact (gnm_float x);
int qfactf (gnm_float x, GnmQuad *mant, int *exp2); int qfactf (gnm_float x, GnmQuad *mant, int *exp2);
gnm_float gnm_lbeta (gnm_float a, gnm_float b); gnm_float gnm_lbeta (gnm_float a, gnm_float b);
gnm_float beta (gnm_float a, gnm_float b); gnm_float gnm_beta (gnm_float a, gnm_float b);
gnm_float lbeta3 (gnm_float a, gnm_float b, int *sign); 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 pochhammer (gnm_float x, gnm_float n, gboolean give_log);
gnm_float combin (gnm_float n, gnm_float k); gnm_float combin (gnm_float n, gnm_float k);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment