Implement transformation into matrix multiplies