Matrix.lua
This feature applies a given function to every element in a matrix, returning a new matrix with the results.
While the existing library supports basic arithmetic, a dedicated mapping function fills the gap for non-linear operations. matrix.lua
: It moves beyond standard arithmetic (add/sub/mul) to support any mathematical transformation. This feature applies a given function to every
: It prevents users from writing repetitive nested for loops, making the code cleaner and less error-prone. 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