[gnumeric] Add argument to FOURIER to separate parts.
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Add argument to FOURIER to separate parts.
- Date: Sat, 2 Oct 2010 21:15:04 +0000 (UTC)
commit d3745f934e768ab345fb6d3ede92e13e71e399c1
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Sat Oct 2 15:14:57 2010 -0600
Add argument to FOURIER to separate parts.
2010-10-02 Andreas J. Guelzow <aguelzow pyrshep ca>
* func.defs: update
* functions.xml: update
2010-10-02 Andreas J. Guelzow <aguelzow pyrshep ca>
* functions.c (help_fourier): add description of new argumen
(gnumeric_fourier): handle new argument
(TimeSeriesAnalysis_functions): add new argument to FOURIER
NEWS | 3 +++
doc/C/ChangeLog | 5 +++++
doc/C/func.defs | 14 ++++++++++++--
doc/C/functions.xml | 36 ++++++++++++++++++++++++++++++++++--
plugins/fn-tsa/ChangeLog | 6 ++++++
plugins/fn-tsa/functions.c | 20 +++++++++++++++++---
6 files changed, 77 insertions(+), 7 deletions(-)
---
diff --git a/NEWS b/NEWS
index e020373..de8c291 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
Gnumeric 1.10.12
+Andreas:
+ * Add argument to FOURIER to separate parts.
+
--------------------------------------------------------------------------
Gnumeric 1.10.11
diff --git a/doc/C/ChangeLog b/doc/C/ChangeLog
index d9a3128..dc6c355 100644
--- a/doc/C/ChangeLog
+++ b/doc/C/ChangeLog
@@ -1,3 +1,8 @@
+2010-10-02 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * func.defs: update
+ * functions.xml: update
+
2010-10-01 Morten Welinder <terra gnome org>
* Release 1.10.11
diff --git a/doc/C/func.defs b/doc/C/func.defs
index 3b4042d..b7df4cd 100644
--- a/doc/C/func.defs
+++ b/doc/C/func.defs
@@ -1373,6 +1373,14 @@ Otherwise ACCRINT returns the sum of the interest accrued in all coupon periods
@SEEALSO=AMORDEGRC
@CATEGORY=Finance
+ FUNCTION=ATL_LAST
+ SHORTDESC=sample real-time data source
+ SYNTAX=ATL_LAST(tag)
+ ARGUMENTDESCRIPTION=@{tag}: tag to watch
+ DESCRIPTION=ATL_LAST is a sample implementation of a real time data source. It takes a string tag and monitors the named pipe ~/atl for changes to the value of that tag.
+ NOTE=This is not intended to be generally enabled and is OFF by default.
+
+ CATEGORY=Finance
@FUNCTION=COUPDAYBS
@SHORTDESC=number of days from coupon period to settlement
@SYNTAX=COUPDAYBS(settlement,maturity,frequency,basis,eom)
@@ -6101,11 +6109,13 @@ The distinction between half-width and full-width characters is described in htt
@CATEGORY=Time Series Analysis
@FUNCTION=FOURIER
@SHORTDESC=Fourier or inverse Fourier transform
- SYNTAX=FOURIER(Sequence,Inverse)
+ 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 always of one column of complex numbers.
+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 #NUM!
@CATEGORY=Time Series Analysis
diff --git a/doc/C/functions.xml b/doc/C/functions.xml
index ea1d420..91e56d2 100644
--- a/doc/C/functions.xml
+++ b/doc/C/functions.xml
@@ -4768,6 +4768,36 @@
</para>
</refsect1>
</refentry>
+ <refentry id="gnumeric-ATL_LAST">
+ <refmeta>
+ <refentrytitle>
+ <function>ATL_LAST</function>
+ </refentrytitle>
+ </refmeta>
+ <refnamediv>
+ <refname>
+ <function>ATL_LAST</function>
+ </refname>
+ <refpurpose>
+ sample real-time data source
+ </refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <synopsis><function>ATL_LAST</function>(<parameter>tag</parameter>)</synopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Arguments</title>
+ <para><parameter>tag</parameter>: tag to watch</para>
+ </refsect1>
+ <refsect1>
+ <title>Description</title>
+ <para><function>ATL_LAST</function> is a sample implementation of a real time data source. It takes a string tag and monitors the named pipe ~/atl for changes to the value of that tag.</para>
+ </refsect1>
+ <refsect1>
+ <title>Note</title>
+ <para>This is not intended to be generally enabled and is OFF by default.</para>
+ </refsect1>
+ </refentry>
<refentry id="gnumeric-COUPDAYBS">
<refmeta>
<refentrytitle>
@@ -21048,17 +21078,19 @@
</refpurpose>
</refnamediv>
<refsynopsisdiv>
- <synopsis><function>FOURIER</function>(<parameter>Sequence</parameter>,<parameter>Inverse</parameter>)</synopsis>
+ <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 always of one column of complex numbers.</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>
diff --git a/plugins/fn-tsa/ChangeLog b/plugins/fn-tsa/ChangeLog
index ef704c9..defef4a 100644
--- a/plugins/fn-tsa/ChangeLog
+++ b/plugins/fn-tsa/ChangeLog
@@ -1,3 +1,9 @@
+2010-10-02 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * functions.c (help_fourier): add description of new argumen
+ (gnumeric_fourier): handle new argument
+ (TimeSeriesAnalysis_functions): add new argument to FOURIER
+
2010-10-01 Morten Welinder <terra gnome org>
* Release 1.10.11
diff --git a/plugins/fn-tsa/functions.c b/plugins/fn-tsa/functions.c
index 4ae678a..bcbfd32 100644
--- a/plugins/fn-tsa/functions.c
+++ b/plugins/fn-tsa/functions.c
@@ -797,8 +797,10 @@ static GnmFuncHelp const help_fourier[] = {
{ GNM_FUNC_HELP_NAME, F_("FOURIER:Fourier or inverse Fourier transform") },
{ GNM_FUNC_HELP_ARG, F_("Sequence:the data sequence to be transformed") },
{ GNM_FUNC_HELP_ARG, F_("Inverse:if true, the inverse Fourier transform is calculated, defaults to false") },
+ { GNM_FUNC_HELP_ARG, F_("Separate:if true, the real and imaginary parts are given separately, defaults to false") },
{ GNM_FUNC_HELP_DESCRIPTION, F_("This array function returns the Fourier or inverse Fourier transform of the given data sequence.") },
- { GNM_FUNC_HELP_DESCRIPTION, F_("The output consists always of one column of complex numbers.") },
+ { GNM_FUNC_HELP_DESCRIPTION, F_("The output consists of one column of complex numbers if @{Separate} is false and of two columns of real numbers if @{Separate} is true.") },
+{ GNM_FUNC_HELP_DESCRIPTION, F_("If @{Separate} is true the first output column contains the real parts and the second column the imaginary parts.") },
{ GNM_FUNC_HELP_NOTE, F_("If @{Sequence} is neither an n by 1 nor 1 by n array, this function returns #NUM!") },
{ GNM_FUNC_HELP_END }
};
@@ -808,6 +810,7 @@ gnumeric_fourier (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
gnm_float *ord;
gboolean inverse = FALSE;
+ gboolean sep_columns = FALSE;
int n0, nb;
GnmValue *error = NULL;
GnmValue *res;
@@ -844,6 +847,10 @@ gnumeric_fourier (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
if (argv[1]) {
inverse = 0 != (int) gnm_floor (value_get_as_float (argv[1]));
+ if (argv[2]) {
+ sep_columns = (0 != (int)
+ gnm_floor (value_get_as_float (argv[2])));
+ }
}
if (missing0) {
@@ -863,13 +870,20 @@ gnumeric_fourier (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_fourier_fft (in, nb, 1, &out, inverse);
g_free (in);
- if (out) {
+ if (out && !sep_columns) {
res = value_new_array_empty (1 , nb);
sprintf (f, "%%.%d" GNM_FORMAT_g, GNM_DIG);
for (i = 0; i < nb; i++)
res->v_array.vals[0][i] = value_new_string_nocopy
(complex_to_string (&(out[i]), f, f, 'i'));
g_free (out);
+ } else if (out && sep_columns) {
+ res = value_new_array_empty (2 , nb);
+ for (i = 0; i < nb; i++) {
+ res->v_array.vals[0][i] = value_new_float (out[i].re);
+ res->v_array.vals[1][i] = value_new_float (out[i].im);
+ }
+ g_free (out);
} else
res = value_new_error_std (ei->pos, GNM_ERROR_VALUE);
@@ -887,7 +901,7 @@ const GnmFuncDescriptor TimeSeriesAnalysis_functions[] = {
help_periodogram, gnumeric_periodogram, NULL, NULL, NULL, NULL,
GNM_FUNC_RETURNS_NON_SCALAR, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
- { "fourier", "A|b",
+ { "fourier", "A|bb",
help_fourier, gnumeric_fourier, NULL, NULL, NULL, NULL,
GNM_FUNC_RETURNS_NON_SCALAR, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]