From ef77679d9fd51ac7a1a69e5a2635c2280856cd85 Mon Sep 17 00:00:00 2001 From: ellson Date: Mon, 3 Jul 2006 12:09:52 +0000 Subject: [PATCH] more sqrt --- lib/neatogen/matrix_ops.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/neatogen/matrix_ops.c b/lib/neatogen/matrix_ops.c index 1fce7fb4c..fbb64c180 100644 --- a/lib/neatogen/matrix_ops.c +++ b/lib/neatogen/matrix_ops.c @@ -738,10 +738,14 @@ void sqrt_vec(int n, float *vec) void sqrt_vecf(int n, float *source, float *target) { int i; + double d; float v; for (i = 0; i < n; i++) { - if ((v = source[i]) >= 0.0) - target[i] = (float) sqrt(v); + if ((v = source[i]) >= 0.0) { + /* do this in two steps to avoid a bug in gcc-4.00 on AIX */ + d = sqrt(v); + target[i] = (float) d; + } } } @@ -749,10 +753,14 @@ void sqrt_vecf(int n, float *source, float *target) void invert_sqrt_vec(int n, float *vec) { int i; + double d; float v; for (i = 0; i < n; i++) { - if ((v = vec[i]) > 0.0) - vec[i] = 1.0f / (float) sqrt(v); + if ((v = vec[i]) > 0.0) { + /* do this in two steps to avoid a bug in gcc-4.00 on AIX */ + d = 1. / sqrt(v); + vec[i] = (float) d; + } } } -- 2.40.0