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--help.lua 9
-rw-r--r--help/integ.lua 31
-rw-r--r--help/ode.lua 57
-rw-r--r--num.lua 3
4 files changed, 99 insertions, 1 deletions
diff --git a/help.lua b/help.lua
index cbc5fe3a..279ddc20 100644
--- a/help.lua
+++ b/help.lua
@@ -1,5 +1,10 @@
-local help_files = {'graphics', 'matrix', 'iter'}
+local help_files = {'graphics', 'matrix', 'iter', 'integ', 'ode'}
+
+local function help_init( ... )
+ local REG = debug.getregistry()
+ REG['GSL.help_hook'] = {}
+end
local function open_module(modname)
local fullname = string.format('help/%s.lua', modname)
@@ -17,6 +22,8 @@ local function search_help(func)
end
end
+help_init()
+
-- declare a global function
function help(func)
local txt = search_help(func) or "No help found for the given function"
diff --git a/help/integ.lua b/help/integ.lua
new file mode 100644
index 00000000..1373f3e5
--- /dev/null
+++ b/help/integ.lua
@@ -0,0 +1,31 @@
+local M = {
+ [num.integ] = [[
+num.integ(f, a, b[, epsabs, epsrel])
+
+ Compute the definite integral of the function "f" in the interval
+ specified by "a" and "b" within the requested precision given by
+ "epsabs" and "epsrel". This function always use the adaptive QAG
+ algorithm internally.
+]],
+
+ [num.quad_prepare] = [[
+num.quad_prepare(spec)
+
+ Returns a function that can perform a numeric integration based on
+ the method and parameters indicated with the table "spec". This
+ latter should have the following fields:
+
+ *method*
+ The quadrature algorithm. Available algorithms are "qng" and
+ "qag", the default is "qag".
+
+ *order*
+ The order of the integration rule. The default value is 21.
+
+ *limits*
+ The maximum number of subdivisions for adaptive algorithms.
+ The default value is 64.
+]],
+}
+
+return M
diff --git a/help/ode.lua b/help/ode.lua
new file mode 100644
index 00000000..adc12eac
--- /dev/null
+++ b/help/ode.lua
@@ -0,0 +1,57 @@
+
+local function get_ode()
+ local REG = debug.getregistry()
+ return REG['GSL.help_hook'].ODE
+end
+
+local ODE = get_ode()
+
+local M = {
+ [num.ode] = [[
+num.ode {N= <int>, eps_abs= <num>, eps_rel= <num>}
+
+ Return an ODE object to numerically integrate an ordinary
+ differential equation. N is the dimension of the system and
+ eps_abs, eps_rel are respectively the requested absolute and
+ relative precision.
+]]
+}
+
+if ODE then
+ M[ODE.init] = [[
+<ode>:init(t0, h0, f, y0_1, y0_2, ..., y0_N)
+
+ Initialize the state of the solver to the time t0 with initial
+ values y0_1, y0_2, ..., y0_N. The second argument h0 is the initial
+ step size that the integrator will try. The function f is the
+ function that defines the ODE system. It will be called like "f(t,
+ y_1, y_2, ..., y_N)" where t is the time and y_1, y_2, ... are the
+ values of the N independent values conventionally denoted here by
+ y. The function f should return N values that correspond to values
+ f_i(t, y_1, ..., y_N) for each component f_i of the ODE system
+ function.
+]]
+
+ M[ODE.step] = [[
+<ode>:step(t1)
+
+ Advance the solution of the system by a step chosen adaptively
+ based on the previous step size. The new values (t, y) are stored
+ internally by the solver and can be retrieved as properties with
+ the name "t" and "y" where the latter is a column matrix of size N.
+ The new values of t will be less than or equal to the value given
+ t1. If the value s.t is less then t1 then the function can
+ be called again to advance further the ODE system.
+]]
+
+ M[ODE.evolve] = [[
+ evolve(t1, t_step)
+
+ Returns a Lua iterator that advance the ODE system at each
+ iteration of a step t_step until the value t1 is reached. The
+ iterators returns the value t itself and all the system variables
+ y0, y1, ... up to y_N.
+]]
+end
+
+return M
diff --git a/num.lua b/num.lua
index 767afe13..af385bdf 100644
--- a/num.lua
+++ b/num.lua
@@ -23,6 +23,9 @@ function num.ode(spec)
local ode = template.load(method, spec)
+ local REG = debug.getregistry()
+ REG['GSL.help_hook'].ODE = ode
+
local mt = {
__index = {step = ode.step, init = ode.init, evolve = ode.evolve}
}
generated by cgit v1.2.3 (git 2.39.1) at 2025年10月03日 22:24:52 +0000

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