O(n6) and O(n5) can now handle rectangular matrices