[gnumeric] Functions: add TANPI and COTPI.



commit 3d5d8827fb544cc11c5599b38cf1a64da8393d23
Author: Morten Welinder <terra gnome org>
Date:   Wed Apr 15 13:32:07 2015 -0400

    Functions: add TANPI and COTPI.

 NEWS                          |    1 +
 plugins/fn-math/functions.c   |   39 +++++++++++++++++++++++++++++++++++++++
 plugins/fn-math/plugin.xml.in |    2 ++
 3 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/NEWS b/NEWS
index 0913182..e05987e 100644
--- a/NEWS
+++ b/NEWS
@@ -39,6 +39,7 @@ Morten:
        * Minor R.DNORM improvement.
        * Improve RAYLEIGH accuracy.
        * Improve R.QCAUCHY accuracy.
+       * Add TANPI and COTPI functions.
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.21
diff --git a/plugins/fn-math/functions.c b/plugins/fn-math/functions.c
index 6b0d001..d0a1fcc 100644
--- a/plugins/fn-math/functions.c
+++ b/plugins/fn-math/functions.c
@@ -835,6 +835,23 @@ gnumeric_cot (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
 
 /***************************************************************************/
 
+static GnmFuncHelp const help_cotpi[] = {
+       { GNM_FUNC_HELP_NAME, F_("COTPI:the cotangent of Pi* {x}")},
+       { GNM_FUNC_HELP_ARG, F_("x:number of half turns")},
+       { GNM_FUNC_HELP_EXAMPLES, "=COTPI(0.5)" },
+       { GNM_FUNC_HELP_EXAMPLES, "=COTPI(0.25)" },
+       { GNM_FUNC_HELP_SEEALSO, "COT" },
+       { GNM_FUNC_HELP_END }
+};
+
+static GnmValue *
+gnumeric_cotpi (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
+{
+       return value_new_float (gnm_cotpi (value_get_as_float (argv[0])));
+}
+
+/***************************************************************************/
+
 static GnmFuncHelp const help_coth[] = {
        { GNM_FUNC_HELP_NAME, F_("COTH:the hyperbolic cotangent of @{x}")},
        { GNM_FUNC_HELP_ARG, F_("x:number")},
@@ -1692,6 +1709,22 @@ gnumeric_tan (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
 
 /***************************************************************************/
 
+static GnmFuncHelp const help_tanpi[] = {
+       { GNM_FUNC_HELP_NAME, F_("TANPI:the tangent of Pi* {x}")},
+       { GNM_FUNC_HELP_ARG, F_("x:number of half turns")},
+       { GNM_FUNC_HELP_EXAMPLES, "=TANPI(1)" },
+       { GNM_FUNC_HELP_EXAMPLES, "=TANPI(0.25)" },
+       { GNM_FUNC_HELP_SEEALSO, "TAN" },
+       { GNM_FUNC_HELP_END }
+};
+
+static GnmValue *
+gnumeric_tanpi (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
+{
+       return value_new_float (gnm_tanpi (value_get_as_float (argv[0])));
+}
+
+/***************************************************************************/
 static GnmFuncHelp const help_tanh[] = {
        { GNM_FUNC_HELP_NAME, F_("TANH:the hyperbolic tangent of @{x}")},
        { GNM_FUNC_HELP_ARG, F_("x:number")},
@@ -3300,6 +3333,9 @@ GnmFuncDescriptor const math_functions[] = {
        { "cot",     "f",     help_cot,
          gnumeric_cot, NULL, NULL, NULL,
          GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_NO_TESTSUITE },
+       { "cotpi",   "f",     help_cotpi,
+         gnumeric_cotpi, NULL, NULL, NULL,
+         GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_NO_TESTSUITE },
        { "coth",     "f",     help_coth,
          gnumeric_coth, NULL, NULL, NULL,
          GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_NO_TESTSUITE },
@@ -3499,6 +3535,9 @@ GnmFuncDescriptor const math_functions[] = {
        { "tan",     "f",     help_tan,
          gnumeric_tan, NULL, NULL, NULL,
          GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_EXHAUSTIVE },
+       { "tanpi",   "f",     help_tanpi,
+         gnumeric_tanpi, NULL, NULL, NULL,
+         GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_EXHAUSTIVE },
        { "tanh",    "f",     help_tanh,
          gnumeric_tanh, NULL, NULL, NULL,
          GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_EXHAUSTIVE },
diff --git a/plugins/fn-math/plugin.xml.in b/plugins/fn-math/plugin.xml.in
index 9d84371..4180f9b 100644
--- a/plugins/fn-math/plugin.xml.in
+++ b/plugins/fn-math/plugin.xml.in
@@ -35,6 +35,7 @@
                                <function name="cospi"/>
                                <function name="cot"/>
                                <function name="coth"/>
+                               <function name="cotpi"/>
                                <function name="countif"/>
                                <function name="csc"/>
                                <function name="csch"/>
@@ -99,6 +100,7 @@
                                <function name="sumxmy2"/>
                                <function name="tan"/>
                                <function name="tanh"/>
+                               <function name="tanpi"/>
                                <function name="trunc"/>
                                <!-- <function name="logmdeterm"/> -->
                        </functions>


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