minor generalization to MatType