Matrix.lua 🔥

-- Example: Apply a sigmoid function to all elements local sigmoid = function(x) return 1 / (1 + math.exp(-x)) end local activated_matrix = matrix.map(my_matrix, sigmoid) Use code with caution. Why this is a "Good" Feature

: It fits the library's design of returning a new matrix rather than modifying the original, maintaining "immutability". davidm/lua-matrix - GitHub matrix.lua

While the existing library supports basic arithmetic, a dedicated mapping function fills the gap for non-linear operations. -- Example: Apply a sigmoid function to all

This feature applies a given function to every element in a matrix, returning a new matrix with the results. matrix.lua