Skip to content

stepelu/lua-sci-lang

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

About

Syntax extensions to LuaJIT for scientific computing

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages