From 1468dffb137fb31ced0221a8846d53b4a838e1b0 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Wed, 14 Oct 2020 18:59:51 -0700 Subject: [PATCH] inline some vector computations and fuse two loops This slightly accelerates a current test case by ~0.1%. Related to #1652. --- lib/neatogen/conjgrad.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/neatogen/conjgrad.c b/lib/neatogen/conjgrad.c index c1918e60b..1ede9897e 100644 --- a/lib/neatogen/conjgrad.c +++ b/lib/neatogen/conjgrad.c @@ -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]; + } + } } } -- 2.40.0