Skip to content

Numerical luau for all your scientific urges.

Numerical luau is a runtime agnostic library for safer, simpler code.

Bring scientific computing in a way easy to understand and predict. Compress large computations filled with loops and table allocations into simple vectorised operations. Prototype and Build mathematical models, for any tasks in a typesafe manner.

In Addition, numluau also comes with submodules for linear algebra, polynomials and randomness.

Vectorised operations

Numeric luau introduces N-Dimensional arrays, Simple but allows you to simplify repetitive code.


Turn what would be tedious for loops, table allocations and indexing.
Into a single addition.

local a = numluau.array({1,2,3,4,5})
local b = numluau.array({10,20,30,40,50})

local c = a + b
print(c) -- array([11 22 33 44 55])
local a = {1,2,3,4,5}
local b = {10,20,30,40,50}

local c = {}
for i = 1,5 do
    c[i] = a[i] + b[i]
end

print(c) -- array([11 22 33 44 55])

Broadcasting

Want to multiply 2 arrays, they're sizes dont match.
Well thats not going to stop you.


when performing arithmetic between 2 arrays, numluau will automatically stretch them to fit according to special rules .

local a = numluau.array({
    {1,2,3},
})
local b = numluau.array({
    {0, 0, 0},
    {10,10,10},
    {20,20,20},
    {30,30,30},
})

print(a * b)
> array([
    [0 0 0]
    [10 20 30]
    [20 40 60]
    [30 60 90]
])

Slicing

If you need to only access a section of the array.
Simply slice the array just by indexing.


local a = numluau.array({
    {1,2,3,4},
    {5,6,7,8},
    {9,10,11,12},
    {13,14,15,16},
})

print(a["1:2, 1:2"])
print(a["1:2, 1:3:2"])
> array([ 
    [1 2] 
    [5 6] 
])

> array([ 
    [1 3] 
    [5 7] 
])

Interested?

If you want a more indepth tutorial Theres a comprehensive beginner's tutorial complete with examples and code.