add error check to ensure matrix is supplied to function
add square matrix to checking
test code