quick fixes

fixed the sgn function, and added error checking for non square matrices