gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
diff options
context:
space:
mode:
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.46.0) at 2025年10月03日 23:32:12 +0000

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