Syntax extensions to LuaJIT for scientific computing
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
__bin
LICENSE
README.md
__meta.lua
ast-boolean-const-eval.lua
ast-const-eval.lua
ast-validate.lua
bcread.lua
bcsave.lua
bytecode.lua
compile.lua
generator.lua
lexer.lua
lua-ast.lua
luacode-generator.lua
operator.lua
parser.lua
reader.lua
transform.lua
util.lua

README.md

SciLua-Lang: Syntax extensions to LuaJIT for scientific computing

Based on the LuaJIT Language Toolkit this executable introduces extensions to the LuaJIT syntax for algebra operations.

Features

  • algebra expressions constructed via empty bracket [] indexing
  • element-wise operations via plain Lua operators (+-*/^%)
  • matrix multiplication via **
  • matrix exponentiation via ^^
  • transposition via `
  • efficient implementation minimizes required allocations and loops
  • support for assignments
-- Replicate rand_mat_stat from Julia's benchmark suite:
local function randmatstat(t)
  local n = 5
  local v, w = alg.vec(t), alg.vec(t)
  for i=1,t do
      local a, b, c, d = randn(n, n), randn(n, n), randn(n, n), randn(n, n)
      local P = alg.join(a..b..c..d)
      local Q = alg.join(a..b, c..d)
      v[i] = alg.trace((P[]`**P[])^^4) -- Matrix transpose, product and power.
      w[i] = alg.trace((Q[]`**Q[])^^4) -- Matrix transpose, product and power.
  end
  return sqrt(stat.var(v))/stat.mean(v), sqrt(stat.var(w))/stat.mean(w)
end

Install

This module is included in the ULua distribution, to install it use:

upkg add sci-lang

Alternatively, manually install this module making sure that all dependencies listed in the require section of __meta.lua are installed as well (dependencies starting with clib_ are standard C dynamic libraries).

Documentation

Refer to the official documentation.