[gnumeric] Really fix linear averaging interpolation. [#680918]



commit 3a880d2af19a96b96c46499e22aa5f852a17b14d
Author: Jean Brefort <jean brefort normalesup org>
Date:   Tue Jul 31 21:38:41 2012 +0200

    Really fix linear averaging interpolation. [#680918]

 NEWS                       |    2 +-
 plugins/fn-tsa/ChangeLog   |    6 ++++++
 plugins/fn-tsa/functions.c |    8 ++++----
 3 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/NEWS b/NEWS
index 754b8fb..8f9382b 100644
--- a/NEWS
+++ b/NEWS
@@ -11,7 +11,7 @@ Andreas:
 
 Jean:
 	* Fix component references issues. [#680190]
-	* Fix linear averaging interpolation. [#680723]
+	* Fix linear averaging interpolation. [#680723][#680918]
 
 Morten:
 	* Fix xls read crash.  [#679992]
diff --git a/plugins/fn-tsa/ChangeLog b/plugins/fn-tsa/ChangeLog
index f3cd570..1ce8c10 100644
--- a/plugins/fn-tsa/ChangeLog
+++ b/plugins/fn-tsa/ChangeLog
@@ -5,6 +5,12 @@
 
 2012-07-31  Jean Brefort  <jean brefort normalesup org>
 
+	reviewed by: <delete if not using a buddy>
+
+	* functions.c (linear_averaging):
+
+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>
diff --git a/plugins/fn-tsa/functions.c b/plugins/fn-tsa/functions.c
index 899eb19..8da15a1 100644
--- a/plugins/fn-tsa/functions.c
+++ b/plugins/fn-tsa/functions.c
@@ -234,10 +234,10 @@ linear_averaging (const gnm_float *absc, const gnm_float *ord, int nb_knots,
 		if (j > k + 1) {
 			k = j - 1;
 			slope = (ord[j] - ord[k]) / (absc[j] - absc[k]) / 2.;
-			j = k;
-		}
-		x0 = targets[i] - absc[j];
-		res[i - 1] += x0 * (slope * x0 + ord[j]);
+		} else
+			k = j;
+		x0 = targets[i] - absc[k];
+		res[i - 1] += x0 * (slope * x0 + ord[k]);
 		res[i - 1] /= (targets[i] - targets[i - 1]);
 	}
 	return res;



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