From: John Darrington Date: Tue, 15 Nov 2011 14:47:10 +0000 (+0100) Subject: sweep.c: Use gsl_matrix_memcpy instead of element by element copying. X-Git-Tag: v0.7.9~86 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=019d870c9a961108b6b5e762ce968db2e06203a7;p=pspp-builds.git 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. --- diff --git a/lib/linreg/sweep.c b/lib/linreg/sweep.c index 7667e3a5..1eb466e9 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);