From d336cdacee0d51e0974c67010cb4d4a86c526e9c Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Wed, 14 Oct 2020 19:32:58 -0700 Subject: [PATCH] inline and fuse a number of loops in majorization code This accelerates the Neato example from #1652 by ~9.5%. --- lib/neatogen/stress.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/neatogen/stress.c b/lib/neatogen/stress.c index f43ecb39b..8d840e895 100644 --- a/lib/neatogen/stress.c +++ b/lib/neatogen/stress.c @@ -1166,12 +1166,11 @@ int stress_majorization_kD_mkernel(vtx_data * graph, /* Input graph in sparse re /* put into 'dist_accumulator' all squared distances between 'i' and 'i'+1,...,'n'-1 */ for (k = 0; k < dim; k++) { - set_vector_valf(len, coords[k][i], tmp_coords); - vectors_mult_additionf(len, tmp_coords, -1, - coords[k] + i + 1); - square_vec(len, tmp_coords); - vectors_additionf(len, tmp_coords, dist_accumulator, - dist_accumulator); + size_t x; + for (x = 0; x < (size_t)len; ++x) { + float tmp = coords[k][i] + -1.0f * (coords[k] + i + 1)[x]; + dist_accumulator[x] += tmp * tmp; + } } /* convert to 1/d_{ij} */ -- 2.40.0