[goffice] go_range_sumsq: use extended precision.



commit 039b4dd5ced5beec121889dd84608562e820c9cb
Author: Morten Welinder <terra gnome org>
Date:   Sun May 23 10:36:15 2010 -0400

    go_range_sumsq: use extended precision.

 ChangeLog                   |    5 +++++
 goffice/math/go-rangefunc.c |   10 ++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c0a0c8c..f1669d1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-05-23  Morten Welinder  <terra gnome org>
+
+	* goffice/math/go-rangefunc.c (go_range_sumsq): Do square in
+	extended precision if we are summing in extended precision.
+
 2010-05-20  Morten Welinder <terra gnome org>
 
 	* configure.in: Post-release bump.
diff --git a/goffice/math/go-rangefunc.c b/goffice/math/go-rangefunc.c
index 9a76b06..a9239b7 100644
--- a/goffice/math/go-rangefunc.c
+++ b/goffice/math/go-rangefunc.c
@@ -70,14 +70,16 @@ SUFFIX(go_range_sumsq) (DOUBLE const *xs, int n, DOUBLE *res)
 {
 	/* http://bugzilla.gnome.org/show_bug.cgi?id=131588 */
 #ifdef HAVE_LONG_DOUBLE
-	long double sum = 0;
+	long double x, sum = 0;
 #else
-	DOUBLE sum = 0;
+	DOUBLE x, sum = 0;
 #endif
 	int i;
 
-	for (i = 0; i < n; i++)
-		sum += xs[i] * xs[i];
+	for (i = 0; i < n; i++) {
+		x = xs[i];
+		sum += x * x;
+	}
 
 	*res = sum;
 	return 0;



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