[gnumeric] IMLOG10: Improve accuracy.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] IMLOG10: Improve accuracy.
- Date: Mon, 7 Mar 2016 15:35:58 +0000 (UTC)
commit 237bdf0410420de25a6c4de8648b1e8afd49599c
Author: Morten Welinder <terra gnome org>
Date: Mon Mar 7 10:33:02 2016 -0500
IMLOG10: Improve accuracy.
Use direct approximation to 1/log(10) instead of approximating log(10)
and doing the division. Mostly by chance, this turns out to be a good
deal more accurate.
NEWS | 1 +
plugins/fn-complex/ChangeLog | 4 ++++
plugins/fn-complex/functions.c | 2 +-
src/mathfunc.h | 1 +
4 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/NEWS b/NEWS
index 0b313c2..7715024 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ Morten:
* Fix bounds problem with cplex exporter.
* Fix IMARCCOSH(1).
* Add more tests for complex number evaluation.
+ * Improve accuracy of IMLOG10.
--------------------------------------------------------------------------
Gnumeric 1.12.27
diff --git a/plugins/fn-complex/ChangeLog b/plugins/fn-complex/ChangeLog
index ec8f409..ac0a99d 100644
--- a/plugins/fn-complex/ChangeLog
+++ b/plugins/fn-complex/ChangeLog
@@ -1,3 +1,7 @@
+2016-03-07 Morten Welinder <terra gnome org>
+
+ * functions.c (gnumeric_imlog10): Improve accuracy.
+
2016-03-05 Morten Welinder <terra gnome org>
* gsl-complex.c (gsl_complex_arccosh): Return +0, not -0 for
diff --git a/plugins/fn-complex/functions.c b/plugins/fn-complex/functions.c
index 2d004c3..03bc26d 100644
--- a/plugins/fn-complex/functions.c
+++ b/plugins/fn-complex/functions.c
@@ -498,7 +498,7 @@ gnumeric_imlog10 (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
if (value_get_as_complex (argv[0], &c, &imunit))
return value_new_error_NUM (ei->pos);
- return value_new_complexv (GNM_CSCALE (GNM_CLN (c), 1 / M_LN10gnum), imunit);
+ return value_new_complexv (GNM_CSCALE (GNM_CLN (c), M_LN10INVgnum), imunit);
}
/***************************************************************************/
diff --git a/src/mathfunc.h b/src/mathfunc.h
index 173cc0d..8512f50 100644
--- a/src/mathfunc.h
+++ b/src/mathfunc.h
@@ -21,6 +21,7 @@ G_BEGIN_DECLS
/* The following are very good given a good compiler. */
#define M_LN2gnum
GNM_const(0.693147180559945309417232121458176568075500134360255254120680009493393621969694715605863326996419)
#define M_LN10gnum
GNM_const(2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598)
+#define M_LN10INVgnum GNM_const(0.434294481903251827651128918916605082294397005803666566114)
#define M_SQRT2gnum
GNM_const(1.414213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327642)
#define M_Egnum GNM_const(2.718281828459045235360287471352662497757247)
#define M_LN_SQRT_2PI GNM_const(0.918938533204672741780329736406) /* log(sqrt(2*pi)) */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]