Update matching.cpp

Added ability to work on non-square matrices