matrix in-place transformation