added check or return code in matrix LU_inverse routine - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
diff options
context:
space:
mode:
authorfrancesco <francesco.bbt@gmail.com>2010年11月01日 20:46:30 +0100
committerfrancesco <francesco.bbt@gmail.com>2010年11月01日 20:46:30 +0100
commit580a2c02593ff5562da407fadf2b240e08fe10b4 (patch)
tree16c9084aed8d3bb3f51d5a97f4deb62fbf2e1cdd
parent8a8f45e28e5add12b5f662a0a43f3368f28b4cb3 (diff)
downloadgsl-shell-580a2c02593ff5562da407fadf2b240e08fe10b4.tar.gz
added check or return code in matrix LU_inverse routine
Diffstat
-rw-r--r--matrix_source.c 10
1 files changed, 8 insertions, 2 deletions
diff --git a/matrix_source.c b/matrix_source.c
index d8d46ca4..357f702c 100644
--- a/matrix_source.c
+++ b/matrix_source.c
@@ -255,7 +255,7 @@ FUNCTION(matrix, inverse_raw) (lua_State *L, const TYPE (gsl_matrix) *a)
TYPE (gsl_matrix) *lu, *inverse;
gsl_permutation *p;
size_t n = a->size1;
- int sign;
+ int status, sign;
if (a->size2 != n)
luaL_typerror (L, 1, "square matrix");
@@ -268,11 +268,17 @@ FUNCTION(matrix, inverse_raw) (lua_State *L, const TYPE (gsl_matrix) *a)
inverse = FUNCTION (matrix, push_raw) (L, n, n);
FUNCTION (gsl_linalg, LU_decomp) (lu, p, &sign);
- FUNCTION (gsl_linalg, LU_invert) (lu, p, inverse);
+ status = FUNCTION (gsl_linalg, LU_invert) (lu, p, inverse);
FUNCTION (gsl_matrix, free) (lu);
gsl_permutation_free (p);
+ if (status)
+ {
+ return luaL_error (L, "error during matrix inversion: %s",
+ gsl_strerror (status));
+ }
+
return 1;
}
int
generated by cgit v1.2.3 (git 2.39.1) at 2025年10月05日 06:05:58 +0000

AltStyle によって変換されたページ (->オリジナル) /