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--graph-init.lua 2
-rw-r--r--gslext.lua 6
-rw-r--r--iter.lua (renamed from base.lua)11
-rw-r--r--lua-graph.c 6
-rw-r--r--lua-graph.h 2
-rw-r--r--lua-gsl.c 19
-rw-r--r--lua-gsl.h 3
-rw-r--r--lua-rng.c 1
-rw-r--r--matrix.lua (renamed from matrix-init.lua)7
-rw-r--r--num.lua (renamed from misc.lua)4
-rw-r--r--randist.c 1
-rw-r--r--sf.c 1
12 files changed, 30 insertions, 33 deletions
diff --git a/graph-init.lua b/graph-init.lua
index f6e63c5f..e0933e99 100644
--- a/graph-init.lua
+++ b/graph-init.lua
@@ -1,7 +1,7 @@
local floor = math.floor
-local lua_index_style = config.lua_index_style
+local lua_index_style = gslsh.lua_index_style
function graph.ipath(f)
local ln = graph.path(f())
diff --git a/gslext.lua b/gslext.lua
index 21f6e2ef..3ded2d77 100644
--- a/gslext.lua
+++ b/gslext.lua
@@ -1,8 +1,8 @@
-- load initialization files for GSL Shell
-require('base')
-require('matrix-init')
-require('misc')
+require('iter')
+require('matrix')
+require('num')
require('integ-init')
require('fft-init')
require('graph-init')
diff --git a/base.lua b/iter.lua
index 6c1962d5..c6173fbb 100644
--- a/base.lua
+++ b/iter.lua
@@ -20,11 +20,9 @@
local cat = table.concat
local fmt = string.format
-local gsl_type = num.type
+local gsl_type = gslsh.type
-config = {
- lua_index_style = true,
-}
+gslsh.lua_index_style = true
function math.divmod(n, p)
local r = n % p
@@ -62,7 +60,8 @@ tos = function (t, maxdepth)
elseif tp == 'string' then
return fmt('%q', t)
elseif tp == 'userdata' then
- local ftostr = getmetatable(t).__tostring
+ local mt = getmetatable(t)
+ local ftostr = mt and mt.__tostring
if ftostr then return ftostr(t) else
if gsl_type then
return fmt('<%s: %p>', gsl_type(t), t)
@@ -138,4 +137,4 @@ iter = {
isum = isum,
}
-package.loaded['iter'] = iter
+return iter
diff --git a/lua-graph.c b/lua-graph.c
index a35c8aeb..161330ba 100644
--- a/lua-graph.c
+++ b/lua-graph.c
@@ -30,8 +30,8 @@
static const struct luaL_Reg methods_dummy[] = {{NULL, NULL}};
-int
-luaopen_graph (lua_State *L)
+void
+register_graph (lua_State *L)
{
window_registry_prepare (L);
@@ -42,5 +42,5 @@ luaopen_graph (lua_State *L)
window_register (L);
plot_register (L);
- return 1;
+ lua_pop(L, 1);
}
diff --git a/lua-graph.h b/lua-graph.h
index b6f49ed1..3faeb21a 100644
--- a/lua-graph.h
+++ b/lua-graph.h
@@ -5,6 +5,6 @@
#define MLUA_GRAPHLIBNAME "graph"
#endif
-extern int luaopen_graph (lua_State *L);
+extern void register_graph (lua_State *L);
#endif
diff --git a/lua-gsl.c b/lua-gsl.c
index 1a91a950..82687f11 100644
--- a/lua-gsl.c
+++ b/lua-gsl.c
@@ -34,30 +34,25 @@
static int gsl_shell_lua_registry (lua_State *L);
#endif
-static const struct luaL_Reg gsl_shell_functions[] = {
#ifdef GSL_SHELL_DEBUG
+static const struct luaL_Reg gsl_shell_functions[] = {
{"registry", gsl_shell_lua_registry},
-#endif
- {NULL, NULL}
-};
-
-static const struct luaL_Reg matrix_functions[] = {
{NULL, NULL}
};
+#endif
int
luaopen_gsl (lua_State *L)
{
gsl_set_error_handler_off ();
- luaopen_graph (L);
- lua_pop (L, 1);
-
- luaL_register (L, MLUA_GSLLIBNAME, gsl_shell_functions);
- luaL_register (L, NULL, gs_type_functions);
-
+ luaL_register (L, "gslsh", gs_type_functions);
+#ifdef GSL_SHELL_DEBUG
+ luaL_register (L, NULL, gsl_shell_functions);
+#endif
lua_pop (L, 1);
+ register_graph (L);
rng_register (L);
randist_register (L);
sf_register (L);
diff --git a/lua-gsl.h b/lua-gsl.h
index 702f885c..70a4b3cb 100644
--- a/lua-gsl.h
+++ b/lua-gsl.h
@@ -1,9 +1,6 @@
#ifndef LUA_GSL_H
#define LUA_GSL_H
-#define MLUA_GSLLIBNAME "num"
-#define MLUA_MATRIXLIBNAME "matrix"
-
extern int luaopen_gsl (lua_State *L);
#endif
diff --git a/lua-rng.c b/lua-rng.c
index 803e1d0c..248b4788 100644
--- a/lua-rng.c
+++ b/lua-rng.c
@@ -165,4 +165,5 @@ rng_register (lua_State *L)
/* gsl module registration */
luaL_register (L, "rng", rng_functions);
+ lua_pop(L, 1);
}
diff --git a/matrix-init.lua b/matrix.lua
index aba049c1..04ad6973 100644
--- a/matrix-init.lua
+++ b/matrix.lua
@@ -1,5 +1,5 @@
-local ffi = require 'ffi'
+local ffi = require 'ffi'
local gsl = require 'gsl'
local sqrt, abs = math.sqrt, math.abs
@@ -8,7 +8,7 @@ local format = string.format
local check = require 'check'
local is_integer, is_real = check.is_integer, check.is_real
-local lua_index_style = config.lua_index_style
+local lua_index_style = gslsh.lua_index_style
local gsl_matrix = ffi.typeof('gsl_matrix')
local gsl_matrix_complex = ffi.typeof('gsl_matrix_complex')
@@ -603,7 +603,6 @@ local function matrix_new_copy(m)
return m:copy()
end
-
matrix = {
new = matrix_new,
cnew = matrix_cnew,
@@ -933,4 +932,4 @@ matrix.tr = function(a)
matrix.def = matrix_def
matrix.cdef = matrix_cdef
-package.loaded['matrix'] = matrix
+return matrix
diff --git a/misc.lua b/num.lua
index c4b2d1cf..0319cfae 100644
--- a/misc.lua
+++ b/num.lua
@@ -1,6 +1,8 @@
local template = require 'template'
+num = {}
+
function num.ode(spec)
local required = {N= 'number', eps_abs= 'number'}
local defaults = {eps_rel = 0, a_y = 1, a_dydt = 0}
@@ -57,3 +59,5 @@ function num.nlinfit(spec)
return s
end
+
+return num
diff --git a/randist.c b/randist.c
index 5f8ef462..1b51bb88 100644
--- a/randist.c
+++ b/randist.c
@@ -151,4 +151,5 @@ void
randist_register (lua_State *L)
{
luaL_register (L, "rnd", randist_functions);
+ lua_pop(L, 1);
}
diff --git a/sf.c b/sf.c
index 503d884d..e9c6ca15 100644
--- a/sf.c
+++ b/sf.c
@@ -86,4 +86,5 @@ void
sf_register (lua_State *L)
{
luaL_register (L, "sf", sf_functions);
+ lua_pop(L, 1);
}
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月21日 14:26:03 +0000

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