Update matrix.cpp

Few more bug fixes and added invertible() function