[gnumeric] Add FLIP function. [#680511]



commit 10cddefadbc9e673fcb4e16c57bc7d9cb2857637
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Thu Jul 26 11:29:06 2012 -0600

    Add FLIP function. [#680511]
    
    2012-07-26  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* func.defs: update
    	* functions.xml: update
    
    2012-07-26  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* functions.c (help_transpose): add FLIP to SEEALSO
    	(help_flip): new
    	(gnumeric_flip): new
    	(lookup_functions): add FLIP
    	* plugin.xml.in: add FLIP

 NEWS                            |    1 +
 doc/C/ChangeLog                 |    5 +
 doc/C/func.defs                 |   77 +++++++++++++++-
 doc/C/functions.xml             |  196 ++++++++++++++++++++++++++++++++++++++-
 plugins/fn-lookup/ChangeLog     |    8 ++
 plugins/fn-lookup/functions.c   |   53 ++++++++++-
 plugins/fn-lookup/plugin.xml.in |    1 +
 7 files changed, 338 insertions(+), 3 deletions(-)
---
diff --git a/NEWS b/NEWS
index 4a97ddf..19ec7df 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ Gnumeric 1.11.6
 Andreas:
 	* Some documentation updates.
 	* Fix implicit ')' for array functions. [#680548]
+	* Add FLIP function. [#680511]
 
 Jean:
 	* Fix component references issues. [#680190]
diff --git a/doc/C/ChangeLog b/doc/C/ChangeLog
index d143218..3bc1185 100644
--- a/doc/C/ChangeLog
+++ b/doc/C/ChangeLog
@@ -1,3 +1,8 @@
+2012-07-26  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* func.defs: update
+	* functions.xml: update
+
 2012-07-25  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* figures/menu-statistics-labelled.png: new
diff --git a/doc/C/func.defs b/doc/C/func.defs
index bd5d0fa..660bea6 100644
--- a/doc/C/func.defs
+++ b/doc/C/func.defs
@@ -2892,6 +2892,14 @@ The depreciation coefficient used is:
 @SEEALSO=COLUMN,ROW,ROWS
 
 @CATEGORY=Lookup
+ FUNCTION=FLIP
+ SHORTDESC=@{matrix} flipped
+ SYNTAX=FLIP(matrix,vertical)
+ ARGUMENTDESCRIPTION=@{matrix}: range
+ {vertical}: if true, @{matrix} is flipped vertically, otherwise horizontally; defaults to TRUE
+ SEEALSO=TRANSPOSE
+
+ CATEGORY=Lookup
 @FUNCTION=HLOOKUP
 @SHORTDESC=search the first row of @{range} for @{value}
 @SYNTAX=HLOOKUP(value,range,row,approximate,as_index)
@@ -3014,7 +3022,7 @@ The depreciation coefficient used is:
 @SHORTDESC=the transpose of @{matrix}
 @SYNTAX=TRANSPOSE(matrix)
 @ARGUMENTDESCRIPTION= {matrix}: range
- SEEALSO=MMULT
+ SEEALSO=FLIP,MMULT
 
 @CATEGORY=Lookup
 @FUNCTION=VLOOKUP
@@ -6160,3 +6168,70 @@ The distinction between half-width and full-width characters is described in htt
 @EXCEL=This function is Excel compatible.
 @SEEALSO=DOLLAR,FIXED,TEXT
 
+ CATEGORY=Time Series Analysis
+ FUNCTION=FOURIER
+ SHORTDESC=Fourier or inverse Fourier transform
+ SYNTAX=FOURIER(Sequence,Inverse,Separate)
+ ARGUMENTDESCRIPTION=@{Sequence}: the data sequence to be transformed
+ {Inverse}: if true, the inverse Fourier transform is calculated, defaults to false
+ {Separate}: if true, the real and imaginary parts are given separately, defaults to false
+ DESCRIPTION=This array function returns the Fourier or inverse Fourier transform of the given data sequence.
+The output consists of one column of complex numbers if @{Separate} is false and of two columns of real numbers if @{Separate} is true.
+If @{Separate} is true the first output column contains the real parts and the second column the imaginary parts.
+ NOTE=If @{Sequence} is neither an n by 1 nor 1 by n array, this function returns #VALUE!
+
+ CATEGORY=Time Series Analysis
+ FUNCTION=HPFILTER
+ SHORTDESC=Hodrick Prescott Filter
+ SYNTAX=HPFILTER(Sequence,Î)
+ ARGUMENTDESCRIPTION=@{Sequence}: the data sequence to be transformed
+ {Î}: filter parameter Î, defaults to 1600
+ DESCRIPTION=This array function returns the trend and cyclical components obtained by applying the Hodrick Prescott Filter with parameter @{Î} to the given data sequence.
+The output consists of two columns of numbers, the first containing the trend component, the second the cyclical component.
+ NOTE=If @{Sequence} is neither an n by 1 nor 1 by n array, this function returns #VALUE! If @{Sequence} contians less than 6 numerical values, this function returns #VALUE!
+
+ CATEGORY=Time Series Analysis
+ FUNCTION=INTERPOLATION
+ SHORTDESC=interpolated values corresponding to the given abscissa targets
+ SYNTAX=INTERPOLATION(abscissae,ordinates,targets,interpolation)
+ ARGUMENTDESCRIPTION=@{abscissae}: ordered abscissae of the given data points
+ {ordinates}: ordinates of the given data points
+ {targets}: abscissae of the interpolated data
+ {interpolation}: method of interpolation, defaults to 0 ('linear')
+ DESCRIPTION=The output consists always of one column of numbers.
+Possible interpolation methods are:
+0: linear;
+1: linear with averaging;
+2: staircase;
+3: staircase with averaging;
+4: natural cubic spline;
+5: natural cubic spline with averaging.
+ NOTE=The @{abscissae} must be given in increasing order. If any of interpolation methods 1 ('linear with averaging'), 3 ('staircase with averaging'), and 5 ('natural cubic spline with averaging') is used, the number of returned values is one less than the number of targets and the targets values must be given in increasing order. Strings and empty cells in @{abscissae} and @{ordinates} are ignored. If several target data are provided they must be in the same column in consecutive cells.
+ SEEALSO=PERIODOGRAM
+
+ CATEGORY=Time Series Analysis
+ FUNCTION=PERIODOGRAM
+ SHORTDESC=periodogram of the given data
+ SYNTAX=PERIODOGRAM(ordinates,filter,abscissae,interpolation,number)
+ ARGUMENTDESCRIPTION=@{ordinates}: ordinates of the given data
+ {filter}: windowing function to  be used, defaults to no filter
+ {abscissae}: abscissae of the given data, defaults to regularly spaced abscissae
+ {interpolation}: method of interpolation, defaults to none
+ {number}: number of interpolated data points
+ DESCRIPTION=If an interpolation method is used, the number of returned values is one less than the number of targets and the targets values must be given in increasing order.
+The output consists always of one column of numbers.
+Possible interpolation methods are:
+0: linear;
+1: linear with averaging;
+2: staircase;
+3: staircase with averaging;
+4: natural cubic spline;
+5: natural cubic spline with averaging.
+Possible window functions are:
+0: no filter (rectangular window)
+1: Bartlett (triangular window)
+2: Hahn (cosine window)
+3: Welch (parabolic window)
+ NOTE=Strings and empty cells in @{abscissae} and @{ordinates} are ignored. If several target data are provided they must be in the same column in consecutive cells.
+ SEEALSO=INTERPOLATION
+
diff --git a/doc/C/functions.xml b/doc/C/functions.xml
index f1190ab..6335ad7 100644
--- a/doc/C/functions.xml
+++ b/doc/C/functions.xml
@@ -9489,6 +9489,33 @@
       </para>
       </refsect1>
     </refentry>
+    <refentry id="gnumeric-function-FLIP">
+      <refmeta>
+        <refentrytitle>
+          <function>FLIP</function>
+        </refentrytitle>
+      </refmeta>
+      <refnamediv>
+        <refname>
+          <function>FLIP</function>
+        </refname>
+        <refpurpose><parameter>matrix</parameter> flipped
+      </refpurpose>
+      </refnamediv>
+      <refsynopsisdiv>
+        <synopsis><function>FLIP</function>(<parameter>matrix</parameter>,<parameter>vertical</parameter>)</synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+        <title>Arguments</title>
+        <para><parameter>matrix</parameter>: range</para>
+        <para><parameter>vertical</parameter>: if true, <parameter>matrix</parameter> is flipped vertically, otherwise horizontally; defaults to TRUE</para>
+      </refsect1>
+      <refsect1>
+        <title>See also</title>
+        <para><link linkend="gnumeric-function-TRANSPOSE"><function>TRANSPOSE</function></link>.
+      </para>
+      </refsect1>
+    </refentry>
     <refentry id="gnumeric-function-HLOOKUP">
       <refmeta>
         <refentrytitle>
@@ -9931,7 +9958,8 @@
       </refsect1>
       <refsect1>
         <title>See also</title>
-        <para><link linkend="gnumeric-function-MMULT"><function>MMULT</function></link>.
+        <para><link linkend="gnumeric-function-FLIP"><function>FLIP</function></link>,
+        <link linkend="gnumeric-function-MMULT"><function>MMULT</function></link>.
       </para>
       </refsect1>
     </refentry>
@@ -21244,4 +21272,170 @@
       </refsect1>
     </refentry>
   </sect1>
+  <sect1 id="CATEGORY_Time_Series_Analysis">
+    <title>Time Series Analysis</title>
+    <refentry id="gnumeric-function-FOURIER">
+      <refmeta>
+        <refentrytitle>
+          <function>FOURIER</function>
+        </refentrytitle>
+      </refmeta>
+      <refnamediv>
+        <refname>
+          <function>FOURIER</function>
+        </refname>
+        <refpurpose>
+        Fourier or inverse Fourier transform
+      </refpurpose>
+      </refnamediv>
+      <refsynopsisdiv>
+        <synopsis><function>FOURIER</function>(<parameter>Sequence</parameter>,<parameter>Inverse</parameter>,<parameter>Separate</parameter>)</synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+        <title>Arguments</title>
+        <para><parameter>Sequence</parameter>: the data sequence to be transformed</para>
+        <para><parameter>Inverse</parameter>: if true, the inverse Fourier transform is calculated, defaults to false</para>
+        <para><parameter>Separate</parameter>: if true, the real and imaginary parts are given separately, defaults to false</para>
+      </refsect1>
+      <refsect1>
+        <title>Description</title>
+        <para>This array function returns the Fourier or inverse Fourier transform of the given data sequence.</para>
+        <para>The output consists of one column of complex numbers if <parameter>Separate</parameter> is false and of two columns of real numbers if <parameter>Separate</parameter> is true.</para>
+        <para>If <parameter>Separate</parameter> is true the first output column contains the real parts and the second column the imaginary parts.</para>
+      </refsect1>
+      <refsect1>
+        <title>Note</title>
+        <para>If <parameter>Sequence</parameter> is neither an n by 1 nor 1 by n array, this function returns #VALUE!</para>
+      </refsect1>
+    </refentry>
+    <refentry id="gnumeric-function-HPFILTER">
+      <refmeta>
+        <refentrytitle>
+          <function>HPFILTER</function>
+        </refentrytitle>
+      </refmeta>
+      <refnamediv>
+        <refname>
+          <function>HPFILTER</function>
+        </refname>
+        <refpurpose>
+        Hodrick Prescott Filter
+      </refpurpose>
+      </refnamediv>
+      <refsynopsisdiv>
+        <synopsis><function>HPFILTER</function>(<parameter>Sequence</parameter>,<parameter/>Î)</synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+        <title>Arguments</title>
+        <para><parameter>Sequence</parameter>: the data sequence to be transformed</para>
+        <para><parameter>Î</parameter>: filter parameter Î, defaults to 1600</para>
+      </refsect1>
+      <refsect1>
+        <title>Description</title>
+        <para>This array function returns the trend and cyclical components obtained by applying the Hodrick Prescott Filter with parameter <parameter>Î</parameter> to the given data sequence.</para>
+        <para>The output consists of two columns of numbers, the first containing the trend component, the second the cyclical component.</para>
+      </refsect1>
+      <refsect1>
+        <title>Note</title>
+        <para>If <parameter>Sequence</parameter> is neither an n by 1 nor 1 by n array, this function returns #VALUE! If <parameter>Sequence</parameter> contians less than 6 numerical values, this function returns #VALUE!</para>
+      </refsect1>
+    </refentry>
+    <refentry id="gnumeric-function-INTERPOLATION">
+      <refmeta>
+        <refentrytitle>
+          <function>INTERPOLATION</function>
+        </refentrytitle>
+      </refmeta>
+      <refnamediv>
+        <refname>
+          <function>INTERPOLATION</function>
+        </refname>
+        <refpurpose>
+        interpolated values corresponding to the given abscissa targets
+      </refpurpose>
+      </refnamediv>
+      <refsynopsisdiv>
+        <synopsis><function>INTERPOLATION</function>(<parameter>abscissae</parameter>,<parameter>ordinates</parameter>,<parameter>targets</parameter>,<parameter>interpolation</parameter>)</synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+        <title>Arguments</title>
+        <para><parameter>abscissae</parameter>: ordered abscissae of the given data points</para>
+        <para><parameter>ordinates</parameter>: ordinates of the given data points</para>
+        <para><parameter>targets</parameter>: abscissae of the interpolated data</para>
+        <para><parameter>interpolation</parameter>: method of interpolation, defaults to 0 ('linear')</para>
+      </refsect1>
+      <refsect1>
+        <title>Description</title>
+        <para>The output consists always of one column of numbers.</para>
+        <para>Possible interpolation methods are:</para>
+        <para>0: linear;</para>
+        <para>1: linear with averaging;</para>
+        <para>2: staircase;</para>
+        <para>3: staircase with averaging;</para>
+        <para>4: natural cubic spline;</para>
+        <para>5: natural cubic spline with averaging.</para>
+      </refsect1>
+      <refsect1>
+        <title>Note</title>
+        <para>The <parameter>abscissae</parameter> must be given in increasing order. If any of interpolation methods 1 ('linear with averaging'), 3 ('staircase with averaging'), and 5 ('natural cubic spline with averaging') is used, the number of returned values is one less than the number of targets and the targets values must be given in increasing order. Strings and empty cells in <parameter>abscissae</parameter> and <parameter>ordinates</parameter> are ignored. If several target data are provided they must be in the same column in consecutive cells.</para>
+      </refsect1>
+      <refsect1>
+        <title>See also</title>
+        <para><link linkend="gnumeric-function-PERIODOGRAM"><function>PERIODOGRAM</function></link>.
+      </para>
+      </refsect1>
+    </refentry>
+    <refentry id="gnumeric-function-PERIODOGRAM">
+      <refmeta>
+        <refentrytitle>
+          <function>PERIODOGRAM</function>
+        </refentrytitle>
+      </refmeta>
+      <refnamediv>
+        <refname>
+          <function>PERIODOGRAM</function>
+        </refname>
+        <refpurpose>
+        periodogram of the given data
+      </refpurpose>
+      </refnamediv>
+      <refsynopsisdiv>
+        <synopsis><function>PERIODOGRAM</function>(<parameter>ordinates</parameter>,<parameter>filter</parameter>,<parameter>abscissae</parameter>,<parameter>interpolation</parameter>,<parameter>number</parameter>)</synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+        <title>Arguments</title>
+        <para><parameter>ordinates</parameter>: ordinates of the given data</para>
+        <para><parameter>filter</parameter>: windowing function to  be used, defaults to no filter</para>
+        <para><parameter>abscissae</parameter>: abscissae of the given data, defaults to regularly spaced abscissae</para>
+        <para><parameter>interpolation</parameter>: method of interpolation, defaults to none</para>
+        <para><parameter>number</parameter>: number of interpolated data points</para>
+      </refsect1>
+      <refsect1>
+        <title>Description</title>
+        <para>If an interpolation method is used, the number of returned values is one less than the number of targets and the targets values must be given in increasing order.</para>
+        <para>The output consists always of one column of numbers.</para>
+        <para>Possible interpolation methods are:</para>
+        <para>0: linear;</para>
+        <para>1: linear with averaging;</para>
+        <para>2: staircase;</para>
+        <para>3: staircase with averaging;</para>
+        <para>4: natural cubic spline;</para>
+        <para>5: natural cubic spline with averaging.</para>
+        <para>Possible window functions are:</para>
+        <para>0: no filter (rectangular window)</para>
+        <para>1: Bartlett (triangular window)</para>
+        <para>2: Hahn (cosine window)</para>
+        <para>3: Welch (parabolic window)</para>
+      </refsect1>
+      <refsect1>
+        <title>Note</title>
+        <para>Strings and empty cells in <parameter>abscissae</parameter> and <parameter>ordinates</parameter> are ignored. If several target data are provided they must be in the same column in consecutive cells.</para>
+      </refsect1>
+      <refsect1>
+        <title>See also</title>
+        <para><link linkend="gnumeric-function-INTERPOLATION"><function>INTERPOLATION</function></link>.
+      </para>
+      </refsect1>
+    </refentry>
+  </sect1>
 </appendix>
diff --git a/plugins/fn-lookup/ChangeLog b/plugins/fn-lookup/ChangeLog
index 005e048..1a98daa 100644
--- a/plugins/fn-lookup/ChangeLog
+++ b/plugins/fn-lookup/ChangeLog
@@ -1,3 +1,11 @@
+2012-07-26  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* functions.c (help_transpose): add FLIP to SEEALSO
+	(help_flip): new
+	(gnumeric_flip): new
+	(lookup_functions): add FLIP
+	* plugin.xml.in: add FLIP
+
 2012-07-15  Morten Welinder <terra gnome org>
 
 	* Release 1.11.5
diff --git a/plugins/fn-lookup/functions.c b/plugins/fn-lookup/functions.c
index c6ca7cd..27dcdda 100644
--- a/plugins/fn-lookup/functions.c
+++ b/plugins/fn-lookup/functions.c
@@ -1696,7 +1696,7 @@ gnumeric_hyperlink (GnmFuncEvalInfo *ei, GnmValue const * const *args)
 static GnmFuncHelp const help_transpose[] = {
 	{ GNM_FUNC_HELP_NAME, F_("TRANSPOSE:the transpose of @{matrix}")},
         { GNM_FUNC_HELP_ARG, F_("matrix:range")},
-        { GNM_FUNC_HELP_SEEALSO, "MMULT"},
+        { GNM_FUNC_HELP_SEEALSO, "FLIP,MMULT"},
         { GNM_FUNC_HELP_END}
 };
 
@@ -1730,6 +1730,54 @@ gnumeric_transpose (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
 }
 
 /***************************************************************************/
+
+static GnmFuncHelp const help_flip[] = {
+	{ GNM_FUNC_HELP_NAME, F_("FLIP:@{matrix} flipped")},
+        { GNM_FUNC_HELP_ARG, F_("matrix:range")},
+        { GNM_FUNC_HELP_ARG, F_("vertical:if true, @{matrix} is flipped vertically, "
+				"otherwise horizontally; defaults to TRUE")},
+        { GNM_FUNC_HELP_SEEALSO, "TRANSPOSE"},
+        { GNM_FUNC_HELP_END}
+};
+
+
+static GnmValue *
+gnumeric_flip (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
+{
+	GnmEvalPos const * const ep = ei->pos;
+        GnmValue const * const matrix = argv[0];
+	int	r, c;
+        GnmValue *res;
+	gboolean vertical = argv[1] ? value_get_as_checked_bool (argv[1]) : TRUE;
+
+	int const cols = value_area_get_width (matrix, ep);
+	int const rows = value_area_get_height (matrix, ep);
+
+	/* Return the value directly for a singleton */
+	if (rows == 1 && cols == 1)
+		return value_dup (value_area_get_x_y (matrix, 0, 0, ep));
+
+	res = value_new_array_non_init (cols, rows);
+
+	if (vertical)
+		for (c = 0; c < cols; ++c) {
+			res->v_array.vals [c] = g_new (GnmValue *, rows);
+			for (r = 0; r < rows; ++r)
+				res->v_array.vals[c][rows - r - 1] = value_dup
+					(value_area_get_x_y (matrix, c, r, ep));
+		}
+	else
+		for (c = 0; c < cols; ++c) {
+			res->v_array.vals [c] = g_new (GnmValue *, rows);
+			for (r = 0; r < rows; ++r)
+				res->v_array.vals[c][r] = value_dup
+					(value_area_get_x_y (matrix, cols - c - 1, r, ep));
+		}
+
+	return res;
+}
+
+/***************************************************************************/
 static GnmFuncHelp const help_array[] = {
         { GNM_FUNC_HELP_NAME, F_("ARRAY:vertical array of the arguments")},
         { GNM_FUNC_HELP_ARG, F_("v:value")},
@@ -1902,6 +1950,9 @@ GnmFuncDescriptor const lookup_functions[] = {
 	{ "array", NULL,
 	  help_array, NULL, gnumeric_array, NULL, NULL,
 	  GNM_FUNC_RETURNS_NON_SCALAR, GNM_FUNC_IMPL_STATUS_UNIQUE_TO_GNUMERIC, GNM_FUNC_TEST_STATUS_NO_TESTSUITE },
+	{ "flip", "A|b",
+	  help_flip, gnumeric_flip, NULL, NULL, NULL, 
+	  GNM_FUNC_RETURNS_NON_SCALAR, GNM_FUNC_IMPL_STATUS_UNIQUE_TO_GNUMERIC, GNM_FUNC_TEST_STATUS_NO_TESTSUITE },
 
         {NULL}
 };
diff --git a/plugins/fn-lookup/plugin.xml.in b/plugins/fn-lookup/plugin.xml.in
index 8e3d4cc..9c75203 100644
--- a/plugins/fn-lookup/plugin.xml.in
+++ b/plugins/fn-lookup/plugin.xml.in
@@ -18,6 +18,7 @@
 				<function name="column"/>
 				<function name="columnnumber"/>
 				<function name="columns"/>
+				<function name="flip"/>
 				<function name="hlookup"/>
 				<function name="hyperlink"/>
 				<function name="indirect"/>



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