[gnumeric] PERMUTATIONA



commit 975ae3e57cf3442f71fd2261b77a3979fe3c09fb
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Sat Aug 22 17:02:39 2009 -0600

    PERMUTATIONA
    
    2009-08-22  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* functions.c (help_permutationa): new
    	(gnumeric_permutationa): new
    	(stat_functions): add PERMUTATIONA
    	* plugin.xml.in: add PERMUTATIONA
    
    2009-08-22  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (oo_func_map_in): no need to map GAMMA and
    	  PERMUTATIONA
    	* openoffice-write.c (odf_expr_func_handler): we now have
    	  GAMMA and PERMUTATIONA

 plugins/fn-stat/ChangeLog             |    7 ++++++
 plugins/fn-stat/functions.c           |   36 +++++++++++++++++++++++++++++++++
 plugins/fn-stat/plugin.xml.in         |    1 +
 plugins/openoffice/ChangeLog          |    7 ++++++
 plugins/openoffice/openoffice-read.c  |    2 -
 plugins/openoffice/openoffice-write.c |    4 +-
 6 files changed, 53 insertions(+), 4 deletions(-)
---
diff --git a/plugins/fn-stat/ChangeLog b/plugins/fn-stat/ChangeLog
index 9ca1957..614cb7e 100644
--- a/plugins/fn-stat/ChangeLog
+++ b/plugins/fn-stat/ChangeLog
@@ -1,3 +1,10 @@
+2009-08-22  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* functions.c (help_permutationa): new
+	(gnumeric_permutationa): new
+	(stat_functions): add PERMUTATIONA
+	* plugin.xml.in: add PERMUTATIONA
+
 2009-08-15  Morten Welinder <terra gnome org>
 
 	* Release 1.9.10
diff --git a/plugins/fn-stat/functions.c b/plugins/fn-stat/functions.c
index 43e3159..39008df 100644
--- a/plugins/fn-stat/functions.c
+++ b/plugins/fn-stat/functions.c
@@ -4770,6 +4770,39 @@ gnumeric_laplace (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
 
 /***************************************************************************/
 
+static GnmFuncHelp const help_permutationa[] = {
+        { GNM_FUNC_HELP_NAME, F_("PERMUTATIONA:the number of permutations of @{y} objects chosen from @{x} objects with repetition allowed.")},
+        { GNM_FUNC_HELP_ARG, F_("x:total number of objects")},
+        { GNM_FUNC_HELP_ARG, F_("y:number of selected objects")},
+	{ GNM_FUNC_HELP_NOTE, F_("If both @{x} and @{y} equal 0, PERMUTATIONA returns 1.") },
+	{ GNM_FUNC_HELP_NOTE, F_("If @{x} < 0 or @{y} < 0, PERMUTATIONA returns #NUM!") },
+	{ GNM_FUNC_HELP_NOTE, F_("If @{x} or @{y} are not integers, they are truncated") },
+	{ GNM_FUNC_HELP_ODF, F_("This function is ODF compatible.") },
+        { GNM_FUNC_HELP_EXAMPLES, "=PERMUTATIONA(2,7)" },
+        { GNM_FUNC_HELP_EXAMPLES, "=PERMUTATIONA(2.3,7.6)" },
+        { GNM_FUNC_HELP_EXAMPLES, "=PERMUTATIONA(0,0)" },
+        { GNM_FUNC_HELP_SEEALSO, "POWER"},
+        { GNM_FUNC_HELP_END}
+};
+
+static GnmValue *
+gnumeric_permutationa (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
+{
+	gnm_float x = value_get_as_float (argv[0]);
+	gnm_float y = value_get_as_float (argv[1]);
+	int ix = (int) x;
+	int iy = (int) y;
+
+	if (ix < 0 || iy < 0)
+		return value_new_error_NUM (ei->pos);
+	else if (ix == 0 && iy == 0)
+		return value_new_float (0);
+	else
+		return value_new_float (gnm_pow (ix, iy));
+}
+
+/***************************************************************************/
+
 GnmFuncDescriptor const stat_functions[] = {
         { "avedev", NULL,      
 	  help_avedev, NULL, gnumeric_avedev, NULL, NULL, NULL,
@@ -5076,6 +5109,9 @@ GnmFuncDescriptor const stat_functions[] = {
 	{ "cronbach", NULL,      
 	  help_cronbach, NULL, gnumeric_cronbach, NULL, NULL, NULL,
 	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_UNIQUE_TO_GNUMERIC, GNM_FUNC_TEST_STATUS_NO_TESTSUITE },
+	{ "permutationa",   "ff",       help_permutationa,
+	  gnumeric_permutationa, NULL, NULL, NULL, NULL,
+	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_NO_TESTSUITE },
 
         {NULL}
 };
diff --git a/plugins/fn-stat/plugin.xml.in b/plugins/fn-stat/plugin.xml.in
index a4779c6..d46ea1a 100644
--- a/plugins/fn-stat/plugin.xml.in
+++ b/plugins/fn-stat/plugin.xml.in
@@ -32,6 +32,7 @@
 				<function name="devsq"/>
 				<function name="exppowdist"/>
 				<function name="permut"/>
+				<function name="permutationa"/>
 				<function name="poisson"/>
 				<function name="expondist"/>
 				<function name="fdist"/>
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 1501b26..98abd92 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,10 @@
+2009-08-22  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* openoffice-read.c (oo_func_map_in): no need to map GAMMA and 
+	  PERMUTATIONA
+	* openoffice-write.c (odf_expr_func_handler): we now have 
+	  GAMMA and PERMUTATIONA
+	
 2009-08-17 Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* openoffice-write.c (odf_expr_func_handler): we now have a
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 0e22920..11cc4c4 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -4571,7 +4571,6 @@ oo_func_map_in (GnmConventions const *convs, Workbook *scope,
 		{ "COUNTIFS","ODF.COUNTIFS" },
 		{ "DAYS","ODF.DAYS" },
 		{ "DDE","ODF.DDE" },
-		{ "GAMMA","ODF.GAMMA" },
 		{ "GAUSS","ODF.GAUSS" },
 		{ "IFNA","ODF.IFNA" },
 		{ "ISFORMULA","ODF.ISFORMULA" },
@@ -4579,7 +4578,6 @@ oo_func_map_in (GnmConventions const *convs, Workbook *scope,
 		{ "MUNIT","ODF.MUNIT" },
 		{ "NUMBERVALUE","ODF.NUMBERVALUE" },
 		{ "PDURATION","ODF.PDURATION" },
-		{ "PERMUTATIONA","ODF.PERMUTATIONA" },
 		{ "PHI","ODF.PHI" },
 		{ "REPLACEB","ODF.REPLACEB" },
 		{ "RRI","ODF.RRI" },
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index cb8d16f..ce01335 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -1702,7 +1702,7 @@ odf_expr_func_handler (GnmConventionsOut *out, GnmExprFunction const *func)
 		{ "FTEST","FTEST" },
 		{ "FV","FV" },
 		{ "FVSCHEDULE","FVSCHEDULE" },
-		/* { "GAMMA","GAMMA" },  not implemented */
+		{ "GAMMA","GAMMA" },
 		{ "GAMMADIST","GAMMADIST" },
 		{ "GAMMAINV","GAMMAINV" },
 		{ "GAMMALN","GAMMALN" },
@@ -1840,7 +1840,7 @@ odf_expr_func_handler (GnmConventionsOut *out, GnmExprFunction const *func)
 		{ "PERCENTILE","PERCENTILE" },
 		{ "PERCENTRANK","PERCENTRANK" },
 		{ "PERMUT","PERMUT" },
-		/* { "PERMUTATIONA","PERMUTATIONA" },  not implemented */
+		{ "PERMUTATIONA","PERMUTATIONA" },
 		/* { "PHI","PHI" },  not implemented */
 		{ "PI","PI" },
 		{ "PMT","PMT" },



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