projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
matrix: Avoid gsl_linalg_LU_invx() because it was new in GSL 2.6.
[pspp]
/
src
/
language
/
stats
/
matrix.c
diff --git
a/src/language/stats/matrix.c
b/src/language/stats/matrix.c
index 64d8dd92f83873465a0727415c1604c3843a452c..8a08740183a54f72dba21798abae29d9fa42d6c1 100644
(file)
--- a/
src/language/stats/matrix.c
+++ b/
src/language/stats/matrix.c
@@
-1851,21
+1851,24
@@
matrix_eval_IDENT (double s1, double s2)
return m;
}
return m;
}
+/* Inverts X, storing the inverse into INVERSE. As a side effect, replaces X
+ by its LU decomposition. */
static void
static void
-invert_matrix (gsl_matrix *x)
+invert_matrix (gsl_matrix *x
, gsl_matrix *inverse
)
{
gsl_permutation *p = gsl_permutation_alloc (x->size1);
int signum;
gsl_linalg_LU_decomp (x, p, &signum);
{
gsl_permutation *p = gsl_permutation_alloc (x->size1);
int signum;
gsl_linalg_LU_decomp (x, p, &signum);
- gsl_linalg_LU_inv
x (x, p
);
+ gsl_linalg_LU_inv
ert (x, p, inverse
);
gsl_permutation_free (p);
}
static gsl_matrix *
gsl_permutation_free (p);
}
static gsl_matrix *
-matrix_eval_INV (gsl_matrix *
m
)
+matrix_eval_INV (gsl_matrix *
src
)
{
{
- invert_matrix (m);
- return m;
+ gsl_matrix *dst = gsl_matrix_alloc (src->size1, src->size2);
+ invert_matrix (src, dst);
+ return dst;
}
static gsl_matrix *
}
static gsl_matrix *
@@
-3405,7
+3408,10
@@
matrix_expr_evaluate_exp_mat (const struct matrix_expr *e,
mul_matrix (&y, x, y, &t);
if (bf < 0)
mul_matrix (&y, x, y, &t);
if (bf < 0)
- invert_matrix (y);
+ {
+ invert_matrix (y, x);
+ swap_matrix (&x, &y);
+ }
/* Garbage collection.
/* Garbage collection.