[gnumeric] Fix linear averaging interpolation. [#680723]
- From: Jean BrÃfort <jbrefort src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Fix linear averaging interpolation. [#680723]
- Date: Tue, 31 Jul 2012 13:44:03 +0000 (UTC)
commit 9c63b608867ecd2697fe671d1ef4bf1f7a9bc835
Author: Jean Brefort <jean brefort normalesup org>
Date: Tue Jul 31 15:43:45 2012 +0200
Fix linear averaging interpolation. [#680723]
NEWS | 1 +
plugins/fn-tsa/ChangeLog | 4 ++++
plugins/fn-tsa/functions.c | 10 ++++++----
3 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/NEWS b/NEWS
index 7eb164d..754b8fb 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ Andreas:
Jean:
* Fix component references issues. [#680190]
+ * Fix linear averaging interpolation. [#680723]
Morten:
* Fix xls read crash. [#679992]
diff --git a/plugins/fn-tsa/ChangeLog b/plugins/fn-tsa/ChangeLog
index 932f6e7..3e2e63f 100644
--- a/plugins/fn-tsa/ChangeLog
+++ b/plugins/fn-tsa/ChangeLog
@@ -1,3 +1,7 @@
+2012-07-31 Jean Brefort <jean brefort normalesup org>
+
+ * functions.c (linear_averaging): fixed it. [#680723]
+
2012-07-27 Andreas J. Guelzow <aguelzow pyrshep ca>
* functions.c (gnumeric_interpolation): check for target size
diff --git a/plugins/fn-tsa/functions.c b/plugins/fn-tsa/functions.c
index 5ba4947..5dd3a4a 100644
--- a/plugins/fn-tsa/functions.c
+++ b/plugins/fn-tsa/functions.c
@@ -231,12 +231,13 @@ linear_averaging (const gnm_float *absc, const gnm_float *ord, int nb_knots,
slope = (ord[j] - ord[k]) / x0 / 2.;
res[i - 1] += x0 * (slope * x0 + ord[k]);
}
- if (j > k - 1) {
+ if (j > k + 1) {
k = j - 1;
slope = (ord[j] - ord[k]) / (absc[j] - absc[k]) / 2.;
+ j = k;
}
- x0 = targets[i] - absc[k];
- res[i - 1] += x0 * (slope * x0 + ord[k]);
+ x0 = targets[i] - absc[j];
+ res[i - 1] += x0 * (slope * x0 + ord[j]);
res[i - 1] /= (targets[i] - targets[i - 1]);
}
return res;
@@ -391,7 +392,8 @@ static GnmFuncHelp const help_interpolation[] = {
"('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.") },
+ "values must be given in increasing order. The interpolated values returned"
+ "are the averages of the interpolation on each interval.") },
{ GNM_FUNC_HELP_NOTE, F_("Strings and empty cells in @{abscissae} and @{ordinates} are ignored.") },
{ GNM_FUNC_HELP_NOTE, F_("If several target data are provided they must be in the same column in consecutive cells.") },
{ GNM_FUNC_HELP_SEEALSO, "PERIODOGRAM" },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]