Make DMat able to represent rectangular matrices.

The code is largely untested.