Implemented cached matrix functions