Numerical helpers
gsl.root
Four multidimensional root finders from GSL. Each is a factory: call it with a table of settings and it returns the solver.
gsl.root.dnewton
gsl.root.dnewton(settings) --> function
gsl.root.broyden
gsl.root.broyden(settings) --> function
gsl.root.hybrid
gsl.root.hybrid(settings) --> function
gsl.root.hybrids
gsl.root.hybrids(settings) --> function
The settings are MaxIterations, Logging, RelativeError and AbsoluteError. The returned function is called as
solver(f, x0) --> x, report
where f takes a list of n numbers and returns a list of n numbers, and x0 is the starting point. x is the solution as a list; report is a table with Name, Status ("OK" or "FAILED") and Iterations, and with Logging set also Logs.x and Logs.f, the iterates and the residuals.
local solve = gsl.root.hybrids{MaxIterations = 100, RelativeError = 1e-10}
local x, r = solve(function(v) return {v[1]*v[1] - 2, v[2] - 1} end, {1, 0})
print(x[1], r.Status, r.Iterations) --> 1.4142... OK ...
gsl.min
Three simplex minimizers, with the same factory shape.
gsl.min.nmsimplex
gsl.min.nmsimplex(settings) --> function
gsl.min.nmsimplex2
gsl.min.nmsimplex2(settings) --> function
gsl.min.nmsimplex2rand
gsl.min.nmsimplex2rand(settings) --> function
The settings are the root finders' four plus StepSize. The returned function takes a scalar-valued f and a starting point and returns the minimizer and the same kind of report.
steepest_descent, conjugate_fr, conjugate_pr, vector_bfgs and vector_bfgs2 appear in the source but are inside #if 0: the derivative-using minimizers are in no build.
openmp
Present when qlua was built with OpenMP, which the reference build was. Each function reads its setting when called with no arguments and sets it when called with one.
openmp.num_threads
openmp.num_threads() --> number
openmp.num_threads(n) --> nothing
openmp.dynamic
openmp.dynamic() --> boolean
openmp.dynamic(flag) --> nothing
openmp.nested
openmp.nested() --> boolean
openmp.nested(flag) --> nothing
openmp.levels
openmp.levels() --> number
openmp.levels(n) --> nothing
openmp.thread_limit
openmp.thread_limit() --> number
Read-only.
openmp.schedule
openmp.schedule() --> kind, modifier
openmp.schedule(kind, modifier) --> nothing
kind is "static", "dynamic", "guided" or "auto".
openmp.version
The OpenMP version the binary was compiled against, as a string.
xml
xml.parse
xml.parse(text) --> table
Parses an XML document into nested tables. An element becomes a table whose $tag field is the tag name, whose other string keys are the attributes, and whose array part holds the children — strings for text, tables for elements.
local t = xml.parse("<a x='1'><b>text</b></a>")
print(t["$tag"], t.x, t[1]["$tag"], t[1][1]) --> a 1 b text
xml.unparse
xml.unparse(table) --> string
The inverse, with an XML declaration and indentation.
Run-control parameters
_rcParam is a global table that the C code consults for settings a script may want to change without an argument reaching every call site — which back end a contraction or a solver should use, for instance. It starts with one sub-table, offload.
require "rcparam" installs the Lua-level view of it: the same table under the name rcparams, with defaults for backend.laplacian, backend.dslash_solver and backend.qbarq, and the two accessors rcparams.get("a.b.c") and rcparams.set("a.b.c", v) which walk the dotted path.
|