Documentation and checking matrix invertible