]> granicus.if.org Git - graphviz/commitdiff
neatogen: replace float-casted calls to 'sqrt' with calls to 'sqrtf'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 15 Feb 2022 08:18:31 +0000 (19:18 +1100)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 16 Feb 2022 10:08:56 +0000 (21:08 +1100)
This is simpler, more efficient, and clearer to the compiler.

lib/neatogen/matrix_ops.c

index 85d8ab370b7e288995405a3a3aafd2303f1dec83..d13ced562e3798608e97c86e60c009ee8201e2d4 100644 (file)
@@ -612,7 +612,7 @@ void sqrt_vec(int n, float *vec)
 {
     int i;
     for (i = 0; i < n; i++) {
-       vec[i] = (float) sqrt(vec[i]);
+       vec[i] = sqrtf(vec[i]);
     }
 }
 
@@ -622,7 +622,7 @@ void sqrt_vecf(int n, float *source, float *target)
     float v;
     for (i = 0; i < n; i++) {
        if ((v = source[i]) >= 0.0) {
-           target[i] = (float) sqrt(v);
+           target[i] = sqrtf(v);
        }
     }
 }
@@ -633,7 +633,7 @@ void invert_sqrt_vec(int n, float *vec)
     float v;
     for (i = 0; i < n; i++) {
        if ((v = vec[i]) > 0.0) {
-           vec[i] = 1.0f / (float) sqrt(v);
+           vec[i] = 1.0f / sqrtf(v);
        }
     }
 }