Execute tanh on a matrix