]> granicus.if.org Git - graphviz/commitdiff
inline some vector computations and fuse two loops
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 15 Oct 2020 01:59:51 +0000 (18:59 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 22 Oct 2020 00:08:43 +0000 (17:08 -0700)
This slightly accelerates a current test case by ~0.1%. Related to #1652.

lib/neatogen/conjgrad.c

index c1918e60be9fc87866e401272c6389f5ccc9b847..1ede9897e1126f002b765daec375fdd95a9f3e21 100644 (file)
@@ -226,9 +226,12 @@ conjugate_gradient_mkernel(float *A, float *x, float *b, int n,
            beta = r_r_new / r_r;
            r_r = r_r_new;
 
-           vectors_scalar_multf(n, p, (float) beta, p);
-
-           vectors_additionf(n, r, p, p);
+           {
+               size_t j;
+               for (j = 0; j < (size_t)n; ++j) {
+                       p[j] = (float)beta * p[j] + r[j];
+               }
+           }
        }
     }