Consider the matrix m:
let m = [ [ 1 , 2 ] , [ 3 , 4 ] ]
Apply the exponentiation function to m:
let mexp = math.exp(m)
Now JSON.stringify(mexp)
outputs:
"[[2.718281828459045,7.38905609893065],[20.085536923187668,54.598150033144236]]"
So the built in exponentiation function was applied elementwise to the matrix and the result is a matrix.
Let's say I have a custom scalar function sigmoid
:
let sigmoid = x => 1 / ( 1 + Math.exp(-x) )
Now I would like to apply sigmoid
elementwise to the matrix as if it was a math.js built in function:
math.sigmoid(m)
How can I implement this?