I have to subtract 1 from all the columnwise max values and use log1p for the function to be numerically stable. By sorting I know all the columnwise max values are the last row so I can easily subtract -1 from them. The change you made makes the function underflow.
mat = [1e-20 1e-20; log(1e-20) log(1e-20)] check it for this array.