[gnumeric] Functions: add new GD function.



commit e537e88edbc23c0e23c3e361a96f63b064bec235
Author: Morten Welinder <terra gnome org>
Date:   Mon Jun 15 12:03:13 2009 -0400

    Functions: add new GD function.

 NEWS                          |    1 +
 plugins/fn-math/functions.c   |   26 ++++++++++++++++++++++++++
 plugins/fn-math/plugin.xml.in |    1 +
 3 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/NEWS b/NEWS
index 3eb62cb..e5edae5 100644
--- a/NEWS
+++ b/NEWS
@@ -41,6 +41,7 @@ Morten:
 	* Fix text import problem.  [#135523]
 	* Fix problem loading very old .gnumeric files.
 	* Implement new-from-template.  [#303657]
+	* Add Gudermannian function GD.
 
 --------------------------------------------------------------------------
 Gnumeric 1.9.8
diff --git a/plugins/fn-math/functions.c b/plugins/fn-math/functions.c
index da9f5cf..8b185fb 100644
--- a/plugins/fn-math/functions.c
+++ b/plugins/fn-math/functions.c
@@ -183,6 +183,28 @@ gnumeric_lcm (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv)
 
 /***************************************************************************/
 
+static GnmFuncHelp const help_gd[] = {
+	{ GNM_FUNC_HELP_NAME, F_("GD:Gudermannian function")},
+	{ GNM_FUNC_HELP_ARG, F_("x:value")},
+	{ GNM_FUNC_HELP_SEEALSO, "TAN,TANH"},
+	{ GNM_FUNC_HELP_END }
+
+};
+
+static gnm_float
+gnm_gd (gnm_float x)
+{
+	return 2 * gnm_atan (gnm_tanh (x / 2));
+}
+
+static GnmValue *
+gnumeric_gd (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
+{
+	return value_new_float (gnm_gd (value_get_as_float (argv [0])));
+}
+
+/***************************************************************************/
+
 static GnmFuncHelp const help_hypot[] = {
 	{ GNM_FUNC_HELP_OLD,
 	F_("@FUNCTION=HYPOT\n"
@@ -3219,6 +3241,10 @@ GnmFuncDescriptor const math_functions[] = {
 	{ "gcd", NULL, N_("number,number"), help_gcd,
 	  NULL, gnumeric_gcd, NULL, NULL, NULL,
 	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
+	{ "gd",   "f", N_("number"),  help_gd,
+	  gnumeric_gd, NULL, NULL, NULL, NULL,
+	  GNM_FUNC_SIMPLE,
+	  GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_NO_TESTSUITE },
 	{ "hypot", NULL, "",            help_hypot,
 	  NULL, gnumeric_hypot, NULL, NULL, NULL,
 	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_UNIQUE_TO_GNUMERIC, GNM_FUNC_TEST_STATUS_NO_TESTSUITE },
diff --git a/plugins/fn-math/plugin.xml.in b/plugins/fn-math/plugin.xml.in
index ad519bb..2e3a518 100644
--- a/plugins/fn-math/plugin.xml.in
+++ b/plugins/fn-math/plugin.xml.in
@@ -38,6 +38,7 @@
 				<function name="combin"/>
 				<function name="floor"/>
 				<function name="gcd"/>
+				<function name="gd"/>
 				<function name="hypot"/>
 				<function name="int"/>
 				<function name="lcm"/>



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