/* PSPP - a program for statistical analysis.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2009 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
Springer. 1998. ISBN 0-387-98542-5.
*/
+#include <config.h>
+
#include "sweep.h"
+#include <assert.h>
/*
The matrix A will be overwritten. In ordinary uses of the sweep
operator, A will be the matrix
The matrix A is assumed to be symmetric, so the sweep operation is
performed only for the upper triangle of A.
+
+ LAST_COL is considered to be the final column in the augmented matrix,
+ that is, the column to the right of the '=' sign of the system.
*/
int
-reg_sweep (gsl_matrix * A)
+reg_sweep (gsl_matrix * A, int last_col)
{
double sweep_element;
double tmp;
{
if (A->size1 == A->size2)
{
+ assert (last_col < A->size1);
+ gsl_matrix_swap_rows (A, A->size1 - 1, last_col);
+ gsl_matrix_swap_columns (A, A->size1 - 1 , last_col);
+
B = gsl_matrix_alloc (A->size1, A->size2);
for (k = 0; k < (A->size1 - 1); k++)
{
}
}
gsl_matrix_free (B);
+
+ gsl_matrix_swap_columns (A, A->size1 - 1 , last_col);
+ gsl_matrix_swap_rows (A, A->size1 - 1, last_col);
+
return GSL_SUCCESS;
}
return GSL_ENOTSQR;