From 019d870c9a961108b6b5e762ce968db2e06203a7 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Tue, 15 Nov 2011 15:47:10 +0100 Subject: [PATCH 5/5] sweep.c: Use gsl_matrix_memcpy instead of element by element copying. Although only the upper triangle needs to be copied, there is no disadvantage copying the entire matrix (the lower triangle is never read) and the expense of using two loops is likely to outweigh the saving achieved by avoiding the other triangle. --- lib/linreg/sweep.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-) diff --git a/lib/linreg/sweep.c b/lib/linreg/sweep.c index 7667e3a..1eb466e 100644 --- a/lib/linreg/sweep.c +++ b/lib/linreg/sweep.c @@ -142,11 +142,7 @@ reg_sweep (gsl_matrix * A, int last_col) } } } - for (i = 0; i < A->size1; i++) - for (j = i; j < A->size2; j++) - { - gsl_matrix_set (A, i, j, gsl_matrix_get (B, i, j)); - } + gsl_matrix_memcpy (A, B); } gsl_matrix_free (B); -- 1.7.2.5