The shortest distance from the same element in a matrix

[[1,0,1,0], =>[[1.414,0,1.414,0], caculate the ‘1’ element shortest distance
[0,1,0,0]] =>[0,1.414, 0 ,0]]

[[1,0,1,1], =>[[1.414,0, 1,1], caculate the ‘1’ element shortest distance
[0,1,0,0]] =>[0,1.414,0,0]]