cached matrix functions