Updated matrix functions to have diagonal from top-left to bottom-right