refactor matcha.math.matrix package