Add Rectangular Matrix Support

The original documentation mentions support for rectangular matrices, but it gets into an infinite loop if one is used.  I added support for rectangular matrices, documented the changes, made a few minor cosmetic changes, and added a main method to test it all out.  This code has served me well for shape matching!