How do I apply function f over the diagonal and g over off-diagonal of a matrix, and more generally over indices I and J? Here I and J are subsets of product of the row and column index sets.
matrix = rand(3,3)
result = [i==j ? f(m[i,j]) : g(m[i,j]) for i in 1:size(matrix,1), j in 1:size(matrix,2)]