The various implementations of the Matrix interface share large code blocks that need to be extracted into a suitable base class.