X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Flinreg%2Fsweep.c;h=62dda200701ceda43e4040e3128b1b8121b9e279;hb=refs%2Fbuilds%2F20131002030504%2Fpspp;hp=c218456418c75ccc450d452eeba21f1fcbbf5cda;hpb=b8f1c67b087b875d45c28bcae330910e7723d6c6;p=pspp diff --git a/lib/linreg/sweep.c b/lib/linreg/sweep.c index c218456418..62dda20070 100644 --- a/lib/linreg/sweep.c +++ b/lib/linreg/sweep.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2005, 2009 Free Software Foundation, Inc. + Copyright (C) 2005, 2009, 2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -69,17 +69,16 @@ int reg_sweep (gsl_matrix * A, int last_col) { - if (A == NULL) - return GSL_EFAULT; - - if (A->size1 != A->size2) - return GSL_ENOTSQR; - int i; int j; int k; gsl_matrix *B; + if (A == NULL) + return GSL_EFAULT; + + if (A->size1 != A->size2) + return GSL_ENOTSQR; assert (last_col < A->size1); gsl_matrix_swap_rows (A, A->size1 - 1, last_col); @@ -106,20 +105,18 @@ reg_sweep (gsl_matrix * A, int last_col) tmp = gsl_matrix_get (A, i, j) - gsl_matrix_get (A, i, k) * gsl_matrix_get (A, j, k) / sweep_element; - gsl_matrix_set (B, i, j, tmp); } else if (j > k) { tmp = gsl_matrix_get (A, i, j) - gsl_matrix_get (A, i, k) * gsl_matrix_get (A, k, j) / sweep_element; - gsl_matrix_set (B, i, j, tmp); } else { tmp = gsl_matrix_get (A, i, k) / sweep_element; - gsl_matrix_set (B, i, j, tmp); } + gsl_matrix_set (B, i, j, tmp); } } /* @@ -144,11 +141,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);