[gimp] app: improve stability of Gaussian elimination in transform-utils
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: improve stability of Gaussian elimination in transform-utils
- Date: Sat, 27 Jan 2018 12:31:29 +0000 (UTC)
commit e7b6103cc8eeb8ed4fced874f42f92c0fecfae96
Author: Ell <ell_se yahoo com>
Date: Sat Jan 27 05:49:11 2018 -0500
app: improve stability of Gaussian elimination in transform-utils
When picking a row whose leading coefficient is nonzero, use fuzzy
comparison against an epsilon, instead of exact comparison against
zero, to minimize the effect of numerical errors.
app/core/gimp-transform-utils.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/app/core/gimp-transform-utils.c b/app/core/gimp-transform-utils.c
index 4cd11db..93bc640 100644
--- a/app/core/gimp-transform-utils.c
+++ b/app/core/gimp-transform-utils.c
@@ -26,6 +26,9 @@
#include "gimp-transform-utils.h"
+#define EPSILON 1e-6
+
+
void
gimp_transform_get_rotate_center (gint x,
gint y,
@@ -363,7 +366,7 @@ mod_gauss (gdouble matrix[],
for (r = 0; r < s; r++)
{
/* make sure that (r,r) is not 0 */
- if (matrix[p[r] * t + r] == 0.0)
+ if (fabs (matrix[p[r] * t + r]) <= EPSILON)
{
/* we need to permutate rows */
for (i = r + 1; i <= s; i++)
@@ -376,7 +379,7 @@ mod_gauss (gdouble matrix[],
return FALSE;
}
- if (matrix[p[i] * t + r] != 0.0)
+ if (fabs (matrix[p[i] * t + r]) > EPSILON)
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]