cached matrix computation