Fix bugs of log and exp function on matrix